Format with black
Formatting code with black - pipenv update
This commit is contained in:
parent
401af5652f
commit
c3098e03e4
8 changed files with 741 additions and 663 deletions
|
|
@ -12,14 +12,15 @@ confserver = bumper.ConfServer("127.0.0.1:11111", False, mock.MagicMock)
|
|||
confserver.confserver_app()
|
||||
app = confserver.app
|
||||
|
||||
|
||||
def async_return(result):
|
||||
f = asyncio.Future()
|
||||
f.set_result(result)
|
||||
return f
|
||||
return f
|
||||
|
||||
|
||||
def test_disconnect():
|
||||
|
||||
async def test_disconnect_async():
|
||||
async def test_disconnect_async():
|
||||
await confserver.disconnect()
|
||||
|
||||
loop = asyncio.get_event_loop()
|
||||
|
|
@ -513,6 +514,7 @@ def test_postLookup():
|
|||
client.close()
|
||||
) # Close test server after all tests are done
|
||||
|
||||
|
||||
def test_devmgr():
|
||||
if os.path.exists("tests/tmp.db"):
|
||||
os.remove("tests/tmp.db") # Remove existing db
|
||||
|
|
@ -536,7 +538,7 @@ def test_devmgr():
|
|||
if jsonresp["ret"] == "ok":
|
||||
assert jsonresp["resp"]
|
||||
else:
|
||||
assert jsonresp["errno"]
|
||||
assert jsonresp["errno"]
|
||||
else:
|
||||
assert jsonresp
|
||||
|
||||
|
|
@ -549,23 +551,33 @@ def test_devmgr():
|
|||
bumper.bot_add("sn_1234", "did_1234", "dev_1234", "res_1234", "eco-ng")
|
||||
bumper.bot_set_mqtt("did_1234", True)
|
||||
postbody = {"toId": "did_1234"}
|
||||
|
||||
|
||||
# Test return get status
|
||||
command_getstatus_resp = { "id": "resp_1234", "resp": "<ctl ret='ok' status='idle'/>", "ret": "ok" }
|
||||
confserver.helperbot.send_command = mock.MagicMock(return_value=async_return(command_getstatus_resp))
|
||||
# Test
|
||||
command_getstatus_resp = {
|
||||
"id": "resp_1234",
|
||||
"resp": "<ctl ret='ok' status='idle'/>",
|
||||
"ret": "ok",
|
||||
}
|
||||
confserver.helperbot.send_command = mock.MagicMock(
|
||||
return_value=async_return(command_getstatus_resp)
|
||||
)
|
||||
# Test
|
||||
loop.run_until_complete(test_devmanager(postbody, command=True))
|
||||
|
||||
# Test return fail timeout
|
||||
command_timeout_resp = {"id": "resp_1234", "errno": "timeout", "ret": "fail"}
|
||||
confserver.helperbot.send_command = mock.MagicMock(return_value=async_return(command_timeout_resp))
|
||||
# Test
|
||||
confserver.helperbot.send_command = mock.MagicMock(
|
||||
return_value=async_return(command_timeout_resp)
|
||||
)
|
||||
# Test
|
||||
loop.run_until_complete(test_devmanager(postbody, command=True))
|
||||
|
||||
# Set bot not on mqtt
|
||||
bumper.bot_set_mqtt("did_1234", False)
|
||||
confserver.helperbot.send_command = mock.MagicMock(return_value=async_return(command_getstatus_resp))
|
||||
# Test
|
||||
confserver.helperbot.send_command = mock.MagicMock(
|
||||
return_value=async_return(command_getstatus_resp)
|
||||
)
|
||||
# Test
|
||||
loop.run_until_complete(test_devmanager(postbody, command=True))
|
||||
|
||||
loop.run_until_complete(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue