from xml.etree import ElementTree from nose.tools import * from sucks import * def test_custom_command(): # Ensure a custom-built command generates the expected XML payload c = VacBotCommand('CustomCommand', {'type': 'customtype'}) assert_equals(ElementTree.tostring(c.to_xml()), b'') def test_custom_command_inner_tag(): # Ensure a custom-built command generates the expected XML payload c = VacBotCommand('CustomCommand', {'customtag': {'customvar': 'customvalue'}}) assert_equals(ElementTree.tostring(c.to_xml()), b'') def test_custom_command_multiple_inner_tag(): # Ensure a custom-built command with multiple inner tags generates the expected XML payload c = VacBotCommand('CustomCommand', {"customtag":[{"customvar":"customvalue1"},{"customvar":"customvalue2"}]}) logging.info(ElementTree.tostring(c.to_xml())) assert_equals(ElementTree.tostring(c.to_xml()), b'') def test_custom_command_args_multiple_inner_tag(): # Ensure a custom-built command with args and multiple inner tags generates the expected XML payload c = VacBotCommand('CustomCommand', {"arg1":"value1","customtag":[{"customvar":"customvalue1"},{"customvar":"customvalue2"}]}) assert_equals(ElementTree.tostring(c.to_xml()), b'') def test_custom_command_noargs(): # Ensure a custom-built command with no args generates XML without an args element c = VacBotCommand('CustomCommand') assert_equals(ElementTree.tostring(c.to_xml()), b'') def test_clean_command(): c = Clean() assert_equals(ElementTree.tostring(c.to_xml()), b'') # protocol has attribs in other order c = Clean('edge', 'high') assert_equals(ElementTree.tostring(c.to_xml()), b'') # protocol has attribs in other order def test_spotarea_command(): assert_raises(ValueError, SpotArea, 'start') #Value error if SpotArea doesn't include a mid or p c = SpotArea('start', '0') assert_equals(ElementTree.tostring(c.to_xml()), b'') #Test namedarea clean c = SpotArea('start', namedarea='0') assert_equals(ElementTree.tostring(c.to_xml()), b'') #Test namedarea keyword clean c = SpotArea('start', '', '01234,56789') assert_equals(ElementTree.tostring(c.to_xml()), b'') #Test customarea clean c = SpotArea('start', '', '01234,56789', '2') assert_equals(ElementTree.tostring(c.to_xml()), b'') #Test customarea clean with deep 2 c = SpotArea('start', '', customarea='01234,56789') assert_equals(ElementTree.tostring(c.to_xml()), b'') #Test customarea keyword clean with deep default c = SpotArea('start', customarea='01234,56789', cleanings='2') assert_equals(ElementTree.tostring(c.to_xml()), b'') #Test customarea keyword and cleanings keyword clean with deep default c = SpotArea('start', namedarea='0', customarea='01234,56789', cleanings='2') assert_equals(ElementTree.tostring(c.to_xml()), b'') #Test all keywords specified, should default to only mid c = SpotArea('start', '0', '01234,56789','2') assert_equals(ElementTree.tostring(c.to_xml()), b'') #Test all keywords specified, should default to only mid def test_edge_command(): c = Edge() assert_equals(ElementTree.tostring(c.to_xml()), b'') # protocol has attribs in other order def test_spot_command(): c = Spot() assert_equals(ElementTree.tostring(c.to_xml()), b'') # protocol has attribs in other order def test_charge_command(): c = Charge() assert_equals(ElementTree.tostring(c.to_xml()), b'') def test_stop_command(): c = Stop() assert_equals(ElementTree.tostring(c.to_xml()), b'') def test_play_sound_command(): c = PlaySound() assert_equals(ElementTree.tostring(c.to_xml()), b'') def test_play_sound_command_with_sid(): c = PlaySound(sid="1") assert_equals(ElementTree.tostring(c.to_xml()), b'') def test_get_clean_state_command(): c = GetCleanState() assert_equals(ElementTree.tostring(c.to_xml()), b'') def test_get_charge_state_command(): c = GetChargeState() assert_equals(ElementTree.tostring(c.to_xml()), b'') def test_get_battery_state_command(): c = GetBatteryState() assert_equals(ElementTree.tostring(c.to_xml()), b'') def test_move_command(): c = Move(action='left') assert_equals(ElementTree.tostring(c.to_xml()), b'') c = Move(action='right') assert_equals(ElementTree.tostring(c.to_xml()), b'') c = Move(action='turn_around') assert_equals(ElementTree.tostring(c.to_xml()), b'') c = Move(action='forward') assert_equals(ElementTree.tostring(c.to_xml()), b'') c = Move(action='backward') assert_equals(ElementTree.tostring(c.to_xml()), b'') c = Move(action='stop') assert_equals(ElementTree.tostring(c.to_xml()), b'') def test_get_lifepsan_command(): c = GetLifeSpan('main_brush') assert_equals(ElementTree.tostring(c.to_xml()), b'') c = GetLifeSpan('side_brush') assert_equals(ElementTree.tostring(c.to_xml()), b'') c = GetLifeSpan('filter') assert_equals(ElementTree.tostring(c.to_xml()), b'')