test: verify switchbot cast speed selection and document probe interference

This commit is contained in:
shen
2026-10-17 17:01:05 -07:00
parent dc24e0e8e1
commit a4e96a1559
2 changed files with 23 additions and 0 deletions
+14
View File
@@ -18,6 +18,7 @@ class Widget(object):
def __getattr__(self,name):
if name.startswith('__'):raise AttributeError(name)
return lambda *a,**k:0
def __del__(self):pass
def Show(self):self.shown=True
def Hide(self):self.shown=False
def IsShow(self):return self.shown
@@ -104,6 +105,19 @@ class SwitchbotTests(unittest.TestCase):
self.assertEqual(self.mods['constInfo'].USERDATA_DIRECTORY,'')
self.assertEqual(self.ns['ITEM_TAB_WIDTH'],(400-16)/5+1-2) # 5 tabs: cell 5 is hidden, as in AVA2
def test_cast_speed_selection_preserves_attribute_id(self):
sent=[]
sb=self.mods['switchbot']
sb.GetAttributeMaxValue=lambda slot,kind:20
sb.SetAttribute=lambda *args:sent.append(args)
window=self.ns['SwitchbotWindow'].__new__(self.ns['SwitchbotWindow'])
window.selectedSlot=0;window.alternative=0;window.attrSearchIdx=0
row=Widget();row.SetAttribute=lambda label,value:None
window.attrDict={0:row}
window._SwitchbotWindow__RefreshButtons=lambda:None
window._SwitchbotWindow__OnAcceptSearch(9,'cast speed')
self.assertEqual(sent,[(0,0,0,9,20)])
def test_server_messages(self):
game=self.mods['game'].GameWindow()
for line in ('switchbot_end 2','switchbot_stop noattr 1','switchbot_stop nochanger 0','switchbot_error active',