示例#1
0
 def test_send_construct_response(self):
     handler = GeckoWatercareProtocolHandler.response(3, parms=PARMS)
     self.assertEqual(
         handler.send_bytes,
         b"<PACKT><SRCCN>DESTID</SRCCN><DESCN>SRCID</DESCN>"
         b"<DATAS>WCGET\x03</DATAS></PACKT>",
     )
示例#2
0
 def test_send_construct_set(self):
     handler = GeckoWatercareProtocolHandler.set(1, 2, parms=PARMS)
     self.assertEqual(
         handler.send_bytes,
         b"<PACKT><SRCCN>DESTID</SRCCN><DESCN>SRCID</DESCN>"
         b"<DATAS>SETWC\x01\x02</DATAS></PACKT>",
     )
     self.assertEqual(handler._timeout_in_seconds, 4)
示例#3
0
 def test_send_construct_schedule(self):
     handler = GeckoWatercareProtocolHandler.schedule(parms=PARMS)
     self.assertEqual(
         handler.send_bytes,
         b"<PACKT><SRCCN>DESTID</SRCCN><DESCN>SRCID</DESCN>"
         b"<DATAS>WCREQ\x00\x00\x00\x01\x00\x00\x06\x00\x00\x00\x00\x02\x01\x00"
         b"\x01\x05"
         b"\x06\x00\x12\x00\x03\x01\x00\x00\x06\x06\x00\x12\x00\x04\x01\x00"
         b"\x01\x05\x00\x00\x00\x00</DATAS></PACKT>",
     )
示例#4
0
 def test_recv_handle_request_schedule(self):
     handler = GeckoWatercareProtocolHandler()
     handler.handle(None, b"REQWC\x01", PARMS)
     self.assertFalse(handler.should_remove_handler)
     self.assertTrue(handler.schedule)
示例#5
0
 def test_recv_handle_response(self):
     handler = GeckoWatercareProtocolHandler()
     handler.handle(None, b"WCGET\x03", PARMS)
     self.assertTrue(handler.should_remove_handler)
     self.assertFalse(handler.schedule)
     self.assertEqual(handler.mode, 3)
示例#6
0
 def test_recv_handle_request(self):
     handler = GeckoWatercareProtocolHandler()
     handler.handle(None, b"GETWC\x01", PARMS)
     self.assertFalse(handler.should_remove_handler)
     self.assertEqual(handler._sequence, 1)
     self.assertFalse(handler.schedule)
示例#7
0
 def test_recv_can_handle(self):
     handler = GeckoWatercareProtocolHandler()
     self.assertTrue(handler.can_handle(b"GETWC", PARMS))
     self.assertTrue(handler.can_handle(b"WCGET", PARMS))
     self.assertTrue(handler.can_handle(b"REQWC", PARMS))
     self.assertFalse(handler.can_handle(b"OTHER", PARMS))