Add spotarea command tests
Add spotarea command tests
This commit is contained in:
+9
-19
@@ -792,26 +792,16 @@ class Stop(Clean):
|
|||||||
super().__init__('stop', 'normal')
|
super().__init__('stop', 'normal')
|
||||||
|
|
||||||
class SpotArea(Clean):
|
class SpotArea(Clean):
|
||||||
def __init__(self, **kwargs):
|
def __init__(self, action='start', namedarea='', customarea='', cleanings='1'):
|
||||||
self.action='start'
|
|
||||||
self.mid=''
|
|
||||||
self.p=''
|
|
||||||
self.deep=''
|
|
||||||
if kwargs is not None:
|
|
||||||
for kkey, kvalue in kwargs.items():
|
|
||||||
if kkey == 'action':
|
|
||||||
self.action = kvalue
|
|
||||||
elif kkey == 'mid':
|
|
||||||
self.mid = kvalue
|
|
||||||
elif kkey == 'p':
|
|
||||||
self.p = kvalue
|
|
||||||
elif kkey == 'deep':
|
|
||||||
self.deep = kvalue
|
|
||||||
|
|
||||||
if self.mid != '': #For cleaning specified map area
|
|
||||||
super().__init__('spotarea', 'normal', act=CLEAN_ACTION_TO_ECOVACS[self.action], mid=self.mid)
|
if namedarea != '': #For cleaning specified map area
|
||||||
elif self.p != '': #For cleaning custom map area, and specify deep amount 1x/2x
|
super().__init__('spotarea', 'normal', act=CLEAN_ACTION_TO_ECOVACS[action], mid=namedarea)
|
||||||
super().__init__('spotarea' ,'normal',act=CLEAN_ACTION_TO_ECOVACS[self.action], p=self.p, deep=self.deep)
|
elif customarea != '': #For cleaning custom map area, and specify deep amount 1x/2x
|
||||||
|
super().__init__('spotarea' ,'normal',act=CLEAN_ACTION_TO_ECOVACS[action], p=customarea, deep=cleanings)
|
||||||
|
else:
|
||||||
|
#no valid entries
|
||||||
|
raise ValueError("must provide namedarea or customarea for spotarea clean")
|
||||||
|
|
||||||
class Charge(VacBotCommand):
|
class Charge(VacBotCommand):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|||||||
+1
-1
@@ -216,7 +216,7 @@ def run(actions, debug):
|
|||||||
#vacbot.connect_and_wait_until_ready()(
|
#vacbot.connect_and_wait_until_ready()(
|
||||||
|
|
||||||
|
|
||||||
vacbot.run(SpotArea(action='start', mid='0'))
|
vacbot.run(SpotArea('start'))
|
||||||
|
|
||||||
|
|
||||||
#vacbot.request_all_statuses()
|
#vacbot.request_all_statuses()
|
||||||
|
|||||||
@@ -35,6 +35,42 @@ def test_clean_command():
|
|||||||
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
|
||||||
|
|
||||||
|
|
||||||
|
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'<ctl td="Clean"><clean act="s" mid="0" speed="standard" type="SpotArea" /></ctl>') #Test namedarea clean
|
||||||
|
|
||||||
|
c = SpotArea('start', namedarea='0')
|
||||||
|
assert_equals(ElementTree.tostring(c.to_xml()),
|
||||||
|
b'<ctl td="Clean"><clean act="s" mid="0" speed="standard" type="SpotArea" /></ctl>') #Test namedarea keyword clean
|
||||||
|
|
||||||
|
c = SpotArea('start', '', '01234,56789')
|
||||||
|
assert_equals(ElementTree.tostring(c.to_xml()),
|
||||||
|
b'<ctl td="Clean"><clean act="s" deep="1" p="01234,56789" speed="standard" type="SpotArea" /></ctl>') #Test customarea clean
|
||||||
|
|
||||||
|
c = SpotArea('start', '', '01234,56789', '2')
|
||||||
|
assert_equals(ElementTree.tostring(c.to_xml()),
|
||||||
|
b'<ctl td="Clean"><clean act="s" deep="2" p="01234,56789" speed="standard" type="SpotArea" /></ctl>') #Test customarea clean with deep 2
|
||||||
|
|
||||||
|
c = SpotArea('start', '', customarea='01234,56789')
|
||||||
|
assert_equals(ElementTree.tostring(c.to_xml()),
|
||||||
|
b'<ctl td="Clean"><clean act="s" deep="1" p="01234,56789" speed="standard" type="SpotArea" /></ctl>') #Test customarea keyword clean with deep default
|
||||||
|
|
||||||
|
c = SpotArea('start', customarea='01234,56789', cleanings='2')
|
||||||
|
assert_equals(ElementTree.tostring(c.to_xml()),
|
||||||
|
b'<ctl td="Clean"><clean act="s" deep="2" p="01234,56789" speed="standard" type="SpotArea" /></ctl>') #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'<ctl td="Clean"><clean act="s" mid="0" speed="standard" type="SpotArea" /></ctl>') #Test all keywords specified, should default to only mid
|
||||||
|
|
||||||
|
c = SpotArea('start', '0', '01234,56789','2')
|
||||||
|
assert_equals(ElementTree.tostring(c.to_xml()),
|
||||||
|
b'<ctl td="Clean"><clean act="s" mid="0" speed="standard" type="SpotArea" /></ctl>') #Test all keywords specified, should default to only mid
|
||||||
|
|
||||||
|
|
||||||
def test_edge_command():
|
def test_edge_command():
|
||||||
c = Edge()
|
c = Edge()
|
||||||
assert_equals(ElementTree.tostring(c.to_xml()),
|
assert_equals(ElementTree.tostring(c.to_xml()),
|
||||||
|
|||||||
Reference in New Issue
Block a user