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')
|
||||
|
||||
class SpotArea(Clean):
|
||||
def __init__(self, **kwargs):
|
||||
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
|
||||
def __init__(self, action='start', namedarea='', customarea='', cleanings='1'):
|
||||
|
||||
|
||||
if self.mid != '': #For cleaning specified map area
|
||||
super().__init__('spotarea', 'normal', act=CLEAN_ACTION_TO_ECOVACS[self.action], mid=self.mid)
|
||||
elif self.p != '': #For cleaning custom map area, and specify deep amount 1x/2x
|
||||
super().__init__('spotarea' ,'normal',act=CLEAN_ACTION_TO_ECOVACS[self.action], p=self.p, deep=self.deep)
|
||||
if namedarea != '': #For cleaning specified map area
|
||||
super().__init__('spotarea', 'normal', act=CLEAN_ACTION_TO_ECOVACS[action], mid=namedarea)
|
||||
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):
|
||||
def __init__(self):
|
||||
|
||||
+1
-1
@@ -216,7 +216,7 @@ def run(actions, debug):
|
||||
#vacbot.connect_and_wait_until_ready()(
|
||||
|
||||
|
||||
vacbot.run(SpotArea(action='start', mid='0'))
|
||||
vacbot.run(SpotArea('start'))
|
||||
|
||||
|
||||
#vacbot.request_all_statuses()
|
||||
|
||||
@@ -33,6 +33,42 @@ def test_clean_command():
|
||||
c = Clean('edge', 'high')
|
||||
assert_equals(ElementTree.tostring(c.to_xml()),
|
||||
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():
|
||||
|
||||
Reference in New Issue
Block a user