示例#1
0
 def test_dib_base(self):
     raw = ((0x0c, 0x02, 0x02, 0x01, 0x03, 0x02, 0x04, 0x01, 0x05, 0x01,
             0x07, 0x01))
     dib = DIBGeneric()
     self.assertEqual(dib.from_knx(raw), 12)
     self.assertEqual(dib.dtc, DIBTypeCode.SUPP_SVC_FAMILIES)
     self.assertEqual(dib.to_knx(), list(raw))
     self.assertEqual(dib.calculated_length(), 12)
示例#2
0
文件: str_test.py 项目: phbaer/xknx
 def test_dib_generic(self):
     """Test string representation of DIBGeneric."""
     dib = DIBGeneric()
     dib.dtc = 0x01
     dib.data = [0x02, 0x03, 0x04]
     self.assertEqual(
         str(dib),
         '<DIB dtc="1" data="0x02, 0x03, 0x04" />')
示例#3
0
 def test_dib_generic(self):
     """Test string representation of DIBGeneric."""
     dib = DIBGeneric()
     dib.dtc = 0x01
     dib.data = [0x02, 0x03, 0x04]
     self.assertEqual(
         str(dib),
         '<DIB dtc="1" data="0x02, 0x03, 0x04" />')
示例#4
0
 def test_dib_base(self):
     """Test parsing and streaming KNX/IP DIB packet."""
     raw = (0x0C, 0x02, 0x02, 0x01, 0x03, 0x02, 0x04, 0x01, 0x05, 0x01, 0x07, 0x01)
     dib = DIBGeneric()
     self.assertEqual(dib.from_knx(raw), 12)
     self.assertEqual(dib.dtc, DIBTypeCode.SUPP_SVC_FAMILIES)
     self.assertEqual(dib.to_knx(), list(raw))
     self.assertEqual(dib.calculated_length(), 12)
示例#5
0
 def test_dib_base(self):
     """Test parsing and streaming KNX/IP DIB packet."""
     raw = (0x0C, 0x02, 0x02, 0x01, 0x03, 0x02, 0x04, 0x01, 0x05, 0x01, 0x07, 0x01)
     dib = DIBGeneric()
     assert dib.from_knx(raw) == 12
     assert dib.dtc == DIBTypeCode.SUPP_SVC_FAMILIES
     assert dib.to_knx() == list(raw)
     assert dib.calculated_length() == 12
示例#6
0
文件: dib_test.py 项目: phbaer/xknx
 def test_dib_base(self):
     """Test parsing and streaming KNX/IP DIB packet."""
     raw = ((0x0c, 0x02, 0x02, 0x01, 0x03, 0x02, 0x04, 0x01,
             0x05, 0x01, 0x07, 0x01))
     dib = DIBGeneric()
     self.assertEqual(dib.from_knx(raw), 12)
     self.assertEqual(dib.dtc, DIBTypeCode.SUPP_SVC_FAMILIES)
     self.assertEqual(dib.to_knx(), list(raw))
     self.assertEqual(dib.calculated_length(), 12)
示例#7
0
文件: str_test.py 项目: onkelbeh/xknx
 def test_search_response_extended(self):
     """Test string representation of KNX/IP SearchResponseExtended."""
     search_response = SearchResponseExtended()
     search_response.control_endpoint = HPAI(ip_addr="192.168.42.1",
                                             port=33941)
     search_response.dibs.append(DIBGeneric())
     search_response.dibs.append(DIBGeneric())
     assert (
         str(search_response) ==
         '<SearchResponseExtended control_endpoint="192.168.42.1:33941/udp" dibs="[\n'
         '<DIB dtc="0" data="" />,\n'
         '<DIB dtc="0" data="" />\n'
         ']" />')
示例#8
0
 def test_search_response(self):
     """Test string representation of KNX/IP SearchResponse."""
     xknx = XKNX(loop=self.loop)
     search_response = SearchResponse(xknx)
     search_response.control_endpoint = HPAI(ip_addr='192.168.42.1', port=33941)
     search_response.dibs.append(DIBGeneric())
     search_response.dibs.append(DIBGeneric())
     self.assertEqual(
         str(search_response),
         '<SearchResponse control_endpoint="<HPAI 192.168.42.1:33941 />" dibs="[\n'
         '<DIB dtc="None" data="" />,\n'
         '<DIB dtc="None" data="" />\n'
         ']" />')
示例#9
0
 def test_dib_wrong_input(self):
     """Test parsing of wrong KNX/IP DIB packet."""
     raw = (0x08, 0x01, 0xC0, 0xA8, 0x2A)
     with pytest.raises(CouldNotParseKNXIP):
         DIBGeneric().from_knx(raw)
示例#10
0
 def test_dib_wrong_input(self):
     raw = ((0x08, 0x01, 0xc0, 0xa8, 0x2a))
     with self.assertRaises(CouldNotParseKNXIP):
         DIBGeneric().from_knx(raw)
示例#11
0
 def test_dib_wrong_input(self):
     """Test parsing of wrong KNX/IP DIB packet."""
     raw = ((0x08, 0x01, 0xc0, 0xa8, 0x2a))
     with self.assertRaises(CouldNotParseKNXIP):
         DIBGeneric().from_knx(raw)