Exemplo n.º 1
0
 def test_frame2_from_raw(self):
     """Test parse EXAMPLE_FRAME2 from raw."""
     slip = bytearray.fromhex(self.EXAMPLE_FRAME2.replace(":", ""))
     raw, _ = get_next_slip(slip)
     frame = frame_from_raw(bytes(raw))
     self.assertTrue(isinstance(frame, FrameGetNodeInformationNotification))
     self.assertEqual(frame.node_id, 4)
     self.assertEqual(frame.order, 4)
     self.assertEqual(frame.placement, 4)
     self.assertEqual(frame.name, "Fenster Büro")
     self.assertEqual(frame.velocity, Velocity.DEFAULT)
     self.assertEqual(frame.node_type,
                      NodeTypeWithSubtype.WINDOW_OPENER_WITH_RAIN_SENSOR)
     self.assertEqual(frame.product_group, 213)
     self.assertEqual(frame.product_type, 7)
     self.assertEqual(frame.node_variation, NodeVariation.NOT_SET)
     self.assertEqual(frame.power_mode, 1)
     self.assertEqual(frame.build_number, 30)
     self.assertEqual(frame.serial_number, "53:36:27:26:10:2f:00:81")
     self.assertEqual(frame.state, 5)
     self.assertEqual(str(Position(frame.current_position)), "100 %")
     self.assertEqual(str(Position(frame.target)), "100 %")
     self.assertEqual(str(Position(frame.current_position_fp1)), "0 %")
     self.assertEqual(str(Position(frame.current_position_fp2)), "UNKNOWN")
     self.assertEqual(str(Position(frame.current_position_fp3)), "UNKNOWN")
     self.assertEqual(str(Position(frame.current_position_fp4)), "UNKNOWN")
     self.assertEqual(frame.remaining_time, 0)
     self.assertEqual(frame.timestamp, 1326315944)
     test_ts = datetime.fromtimestamp(1326315944).strftime(
         "%Y-%m-%d %H:%M:%S")
     self.assertEqual(frame.timestamp_formatted, test_ts)
     self.assertEqual(str(frame.alias_array), "d802=6400, d803=ba00")
     # Crosscheck, Serializing:
     self.assertEqual(bytes(frame), raw)
Exemplo n.º 2
0
 def test_get_next_slip(self):
     """Test get_next_slip function."""
     self.assertEqual(
         get_next_slip(
             b"\xc0\xdb\xdc\xdb\xdc\xdb\xdd\xdb\xdd\xdb\xdc\xdb\xdd\xdb\xdc\xc0fnord"
         ),
         (b"\xc0\xc0\xdb\xdb\xc0\xdb\xc0", b"fnord"),
     )
Exemplo n.º 3
0
 def test_get_next_slip_empty_queue(self):
     """Test get_next_slip function with empty queue."""
     self.assertEqual(get_next_slip(b""), (None, b""))
Exemplo n.º 4
0
 def test_get_next_slip_no_complete_slip(self):
     """Test get_next_slip function with no complete slip frame beeing in queue."""
     self.assertEqual(get_next_slip(b"zz\xc0abc\xc0"), (None, b"zz\xc0abc\xc0"))
Exemplo n.º 5
0
 def test_get_next_slip(self):
     """Test get_next_slip function."""
     self.assertEqual(
         get_next_slip(
             b'\xc0\xdb\xdc\xdb\xdc\xdb\xdd\xdb\xdd\xdb\xdc\xdb\xdd\xdb\xdc\xc0fnord'
         ), (b'\xc0\xc0\xdb\xdb\xc0\xdb\xc0', b'fnord'))