more tests
This commit is contained in:
+1
-1
@@ -1018,7 +1018,7 @@ class VacBotCommand:
|
|||||||
|
|
||||||
class Clean(VacBotCommand):
|
class Clean(VacBotCommand):
|
||||||
def __init__(self, mode='auto', speed='normal', iot=False, action='start',terminal=False, **kwargs):
|
def __init__(self, mode='auto', speed='normal', iot=False, action='start',terminal=False, **kwargs):
|
||||||
if kwargs is None:
|
if kwargs == {}:
|
||||||
if not iot:
|
if not iot:
|
||||||
super().__init__('Clean', {'clean': {'type': CLEAN_MODE_TO_ECOVACS[mode], 'speed': FAN_SPEED_TO_ECOVACS[speed]}})
|
super().__init__('Clean', {'clean': {'type': CLEAN_MODE_TO_ECOVACS[mode], 'speed': FAN_SPEED_TO_ECOVACS[speed]}})
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -44,9 +44,14 @@ def test_clean_command():
|
|||||||
c = Clean()
|
c = Clean()
|
||||||
assert_equals(ElementTree.tostring(c.to_xml()),
|
assert_equals(ElementTree.tostring(c.to_xml()),
|
||||||
b'<ctl td="Clean"><clean speed="standard" type="auto" /></ctl>') # protocol has attribs in other order
|
b'<ctl td="Clean"><clean speed="standard" type="auto" /></ctl>') # protocol has attribs in other order
|
||||||
|
|
||||||
c = Clean('edge', 'high')
|
c = Clean('edge', 'high')
|
||||||
assert_equals(ElementTree.tostring(c.to_xml()),
|
assert_equals(ElementTree.tostring(c.to_xml()),
|
||||||
b'<ctl td="Clean"><clean speed="strong" type="border" /></ctl>') # protocol has attribs in other order
|
b'<ctl td="Clean"><clean speed="strong" type="border" /></ctl>') # protocol has attribs in other order
|
||||||
|
|
||||||
|
c = Clean(iot=True)
|
||||||
|
assert_equals(ElementTree.tostring(c.to_xml()),
|
||||||
|
b'<ctl td="Clean"><clean act="s" speed="standard" type="auto" /></ctl>') # test for iot act is added
|
||||||
|
|
||||||
|
|
||||||
def test_spotarea_command():
|
def test_spotarea_command():
|
||||||
|
|||||||
@@ -71,15 +71,24 @@ def test_xml_to_dict():
|
|||||||
x._ctl_to_dict(test_topic, "<ctl ts='1547823592934' td='MapSt' st='relocGoChgStart' method='' info=''/>"),
|
x._ctl_to_dict(test_topic, "<ctl ts='1547823592934' td='MapSt' st='relocGoChgStart' method='' info=''/>"),
|
||||||
{'event': 'map_st', 'ts':'1547823592934', 'st':'reloc_go_chg_start', 'method':'', 'info':''})
|
{'event': 'map_st', 'ts':'1547823592934', 'st':'reloc_go_chg_start', 'method':'', 'info':''})
|
||||||
|
|
||||||
|
|
||||||
# #TODO: Find a way to check if string is b64 encoded
|
# #TODO: Find a way to check if string is b64 encoded
|
||||||
# test_topic = 'iot/atr/trace/%s/%s/%s/x'.format(x.vacuum['did'], x.vacuum['class'], x.vacuum['resource'])
|
# test_topic = 'iot/atr/trace/%s/%s/%s/x'.format(x.vacuum['did'], x.vacuum['class'], x.vacuum['resource'])
|
||||||
# assert_dict_equal(
|
# assert_dict_equal(
|
||||||
# x._ctl_to_dict(test_topic, "<ctl td='trace' trid='227975' tf='3' tt='4' tr='XQAABAAKAAAAAB4AMGAQCdAAAAA='/>"),
|
# x._ctl_to_dict(test_topic, "<ctl td='trace' trid='227975' tf='3' tt='4' tr='XQAABAAKAAAAAB4AMGAQCdAAAAA='/>"),
|
||||||
# {'event': 'trace', 'trid':'227975', 'tf':'4', 'tr':'XQAABAAKAAAAAB4AMGAQCdAAAAA='})
|
# {'event': 'trace', 'trid':'227975', 'tf':'4', 'tr':'XQAABAAKAAAAAB4AMGAQCdAAAAA='})
|
||||||
|
|
||||||
|
def test_bad_port():
|
||||||
|
bot = {"did": "E0000000001234567890", "class": "126","resource":"test_resource", "nick": "bob", "iot": True}
|
||||||
|
mqtt = EcoVacsMQTT('20170101abcdefabcdefa', 'ecouser.net', 'abcdef12', 'A1b2C3d4efghijklmNOPQrstuvwxyz12', 'na', bot, server_address='test.com:f123')
|
||||||
|
assert_equal(8883, mqtt.port)
|
||||||
|
|
||||||
|
def test_good_port():
|
||||||
|
bot = {"did": "E0000000001234567890", "class": "126","resource":"test_resource", "nick": "bob", "iot": True}
|
||||||
|
mqtt = EcoVacsMQTT('20170101abcdefabcdefa', 'ecouser.net', 'abcdef12', 'A1b2C3d4efghijklmNOPQrstuvwxyz12', 'na', bot, server_address='test.com:8000')
|
||||||
|
assert_equal(8000, mqtt.port)
|
||||||
|
|
||||||
def make_ecovacs_mqtt(bot=None):
|
def make_ecovacs_mqtt(bot=None):
|
||||||
if bot is None:
|
if bot is None:
|
||||||
bot = bot = {"did": "E0000000001234567890", "class": "126","resource":"test_resource", "nick": "bob", "iot": True}
|
bot = {"did": "E0000000001234567890", "class": "126","resource":"test_resource", "nick": "bob", "iot": True}
|
||||||
return EcoVacsMQTT('20170101abcdefabcdefa', 'ecouser.net', 'abcdef12', 'A1b2C3d4efghijklmNOPQrstuvwxyz12', 'na', bot)
|
return EcoVacsMQTT('20170101abcdefabcdefa', 'ecouser.net', 'abcdef12', 'A1b2C3d4efghijklmNOPQrstuvwxyz12', 'na', bot)
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ def test_wrap_command():
|
|||||||
assert_true(search(r'from="20170101abcdefabcdefa@ecouser.net/abcdef12"', c))
|
assert_true(search(r'from="20170101abcdefabcdefa@ecouser.net/abcdef12"', c))
|
||||||
assert_true(search(r'to="E0000000001234567890@126.ecorobot.net/atom"', c))
|
assert_true(search(r'to="E0000000001234567890@126.ecorobot.net/atom"', c))
|
||||||
|
|
||||||
|
|
||||||
def test_subscribe_to_ctls():
|
def test_subscribe_to_ctls():
|
||||||
response = None
|
response = None
|
||||||
|
|
||||||
@@ -58,7 +57,7 @@ def test_xml_to_dict():
|
|||||||
|
|
||||||
def make_ecovacs_xmpp(bot=None):
|
def make_ecovacs_xmpp(bot=None):
|
||||||
if bot is None:
|
if bot is None:
|
||||||
bot = bot = {"did": "E0000000001234567890", "class": "126", "nick": "bob", "iot": False}
|
bot = {"did": "E0000000001234567890", "class": "126", "nick": "bob", "iot": False}
|
||||||
return EcoVacsXMPP('20170101abcdefabcdefa', 'ecouser.net', 'abcdef12', 'A1b2C3d4efghijklmNOPQrstuvwxyz12', 'na', bot)
|
return EcoVacsXMPP('20170101abcdefabcdefa', 'ecouser.net', 'abcdef12', 'A1b2C3d4efghijklmNOPQrstuvwxyz12', 'na', bot)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user