|
|
@@ -3,7 +3,7 @@ import contextlib |
|
|
|
import functools |
|
|
|
import json |
|
|
|
import unittest |
|
|
|
from unittest.mock import Mock, AsyncMock |
|
|
|
from unittest.mock import patch, Mock, AsyncMock |
|
|
|
|
|
|
|
PIPE = object() |
|
|
|
|
|
|
@@ -271,6 +271,15 @@ class WSFWDCommon: |
|
|
|
async def __aexit__(self, exc_type, exc, tb): |
|
|
|
self._task.cancel() |
|
|
|
|
|
|
|
await self.shutdown() |
|
|
|
|
|
|
|
async def shutdown(self): |
|
|
|
''' |
|
|
|
Called to clean up resources allocated. |
|
|
|
''' |
|
|
|
|
|
|
|
pass |
|
|
|
|
|
|
|
async def _sendcmd(self, cmd): |
|
|
|
''' |
|
|
|
Internal function for sending the dict in cmd. This |
|
|
@@ -396,6 +405,16 @@ class Test(unittest.IsolatedAsyncioTestCase): |
|
|
|
def runFakeServer(self, func): |
|
|
|
return asyncio.create_task(func(self.toserver.get, self.toclient.put)) |
|
|
|
|
|
|
|
@timeout(2) |
|
|
|
@patch('wsfwd.WSFWDCommon.shutdown') |
|
|
|
async def test_shutdown(self, shut): |
|
|
|
# make sure that a with block |
|
|
|
async with WSFWDCommon(None, None) as st: |
|
|
|
pass |
|
|
|
|
|
|
|
# calls shutdown |
|
|
|
shut.assert_called() |
|
|
|
|
|
|
|
@timeout(2) |
|
|
|
async def test_authfail(self): |
|
|
|
async def fake_server(reader, writer): |
|
|
|