Esempio n. 1
0
    def test_dib_sup_svc_families_router(self):
        """Test parsing of svc families."""
        raw = bytes(
            (0x0C, 0x02, 0x02, 0x01, 0x03, 0x02, 0x04, 0x01, 0x05, 0x01, 0x07, 0x01)
        )

        dib = DIB.determine_dib(raw)
        assert isinstance(dib, DIBSuppSVCFamilies)
        assert dib.from_knx(raw) == 12

        assert dib.families == [
            DIBSuppSVCFamilies.Family(DIBServiceFamily.CORE, 1),
            DIBSuppSVCFamilies.Family(DIBServiceFamily.DEVICE_MANAGEMENT, 2),
            DIBSuppSVCFamilies.Family(DIBServiceFamily.TUNNELING, 1),
            DIBSuppSVCFamilies.Family(DIBServiceFamily.ROUTING, 1),
            DIBSuppSVCFamilies.Family(
                DIBServiceFamily.REMOTE_CONFIGURATION_DIAGNOSIS, 1
            ),
        ]

        assert dib.to_knx() == raw

        assert dib.supports(DIBServiceFamily.CORE)
        assert dib.supports(DIBServiceFamily.DEVICE_MANAGEMENT)
        assert dib.supports(DIBServiceFamily.DEVICE_MANAGEMENT, version=2)
        assert dib.supports(DIBServiceFamily.TUNNELING)
        assert not dib.supports(DIBServiceFamily.TUNNELING, version=2)
        assert dib.supports(DIBServiceFamily.ROUTING, version=1)
Esempio n. 2
0
 def test_dib_supp_svc_families(self):
     """Test string representation of DIBSuppSVCFamilies."""
     dib = DIBSuppSVCFamilies()
     dib.families.append(DIBSuppSVCFamilies.Family(DIBServiceFamily.CORE, "1"))
     dib.families.append(DIBSuppSVCFamilies.Family(DIBServiceFamily.DEVICE_MANAGEMENT, "2"))
     self.assertEqual(
         str(dib),
         '<DIBSuppSVCFamilies families="[DIBServiceFamily.CORE version: 1, DIBServiceFamily.DEVICE_MANAGEMENT version: 2]" />')
Esempio n. 3
0
    def test_dib_sup_svc_families(self):
        raw = ((0x0c, 0x02, 0x02, 0x01, 0x03, 0x02, 0x04, 0x01, 0x05, 0x01,
                0x07, 0x01))

        dib = DIB.determine_dib(raw)
        self.assertTrue(isinstance(dib, DIBSuppSVCFamilies))
        self.assertEqual(dib.from_knx(raw), 12)

        self.assertEqual(dib.families, [
            DIBSuppSVCFamilies.Family(DIBServiceFamily.CORE, 1),
            DIBSuppSVCFamilies.Family(DIBServiceFamily.DEVICE_MANAGEMENT, 2),
            DIBSuppSVCFamilies.Family(DIBServiceFamily.TUNNELING, 1),
            DIBSuppSVCFamilies.Family(DIBServiceFamily.ROUTING, 1),
            DIBSuppSVCFamilies.Family(
                DIBServiceFamily.REMOTE_CONFIGURATION_DIAGNOSIS, 1)
        ])

        self.assertEqual(dib.to_knx(), list(raw))
Esempio n. 4
0
    def test_dib_secured_service_families(self):
        """Test parsing of secured service families."""
        raw = bytes((0x08, 0x06, 0x03, 0x01, 0x04, 0x01, 0x05, 0x01))

        dib = DIB.determine_dib(raw)
        assert isinstance(dib, DIBSecuredServiceFamilies)
        assert dib.from_knx(raw) == 8

        assert dib.families == [
            DIBSuppSVCFamilies.Family(DIBServiceFamily.DEVICE_MANAGEMENT, 1),
            DIBSuppSVCFamilies.Family(DIBServiceFamily.TUNNELING, 1),
            DIBSuppSVCFamilies.Family(DIBServiceFamily.ROUTING, 1),
        ]

        assert dib.to_knx() == raw

        assert dib.supports(DIBServiceFamily.TUNNELING)
        assert dib.supports(DIBServiceFamily.TUNNELING, version=1)
        assert dib.supports(DIBServiceFamily.ROUTING)
        assert not dib.supports(DIBServiceFamily.ROUTING, version=2)
        assert dib.supports(DIBServiceFamily.DEVICE_MANAGEMENT)
Esempio n. 5
0
def fake_router_search_response(xknx: XKNX) -> KNXIPFrame:
    """Return the KNXIPFrame of a KNX/IP Router with a SearchResponse body."""
    frame_body = SearchResponse(xknx)
    frame_body.control_endpoint = HPAI(ip_addr="192.168.42.10", port=3671)

    device_information = DIBDeviceInformation()
    device_information.name = "Gira KNX/IP-Router"
    device_information.serial_number = "11:22:33:44:55:66"
    device_information.individual_address = IndividualAddress("1.1.0")
    device_information.mac_address = "01:02:03:04:05:06"

    svc_families = DIBSuppSVCFamilies()
    svc_families.families.append(
        DIBSuppSVCFamilies.Family(name=DIBServiceFamily.CORE, version=1))
    svc_families.families.append(
        DIBSuppSVCFamilies.Family(name=DIBServiceFamily.DEVICE_MANAGEMENT,
                                  version=2))
    svc_families.families.append(
        DIBSuppSVCFamilies.Family(name=DIBServiceFamily.TUNNELING, version=1))
    svc_families.families.append(
        DIBSuppSVCFamilies.Family(name=DIBServiceFamily.ROUTING, version=1))
    svc_families.families.append(
        DIBSuppSVCFamilies.Family(
            name=DIBServiceFamily.REMOTE_CONFIGURATION_DIAGNOSIS, version=1))

    frame_body.dibs.append(device_information)
    frame_body.dibs.append(svc_families)

    return KNXIPFrame.init_from_body(frame_body)
Esempio n. 6
0
def fake_router_search_response(xknx: XKNX) -> SearchResponse:
    """Return the SearchResponse of a KNX/IP Router."""
    _frame_header = KNXIPHeader(xknx)
    _frame_header.service_type_ident = KNXIPServiceType.SEARCH_RESPONSE
    _frame_body = SearchResponse(xknx)
    _frame_body.control_endpoint = HPAI(ip_addr="192.168.42.10", port=3671)

    _device_information = DIBDeviceInformation()
    _device_information.name = "Gira KNX/IP-Router"
    _device_information.serial_number = "11:22:33:44:55:66"
    _device_information.individual_address = PhysicalAddress("1.1.0")
    _device_information.mac_address = "01:02:03:04:05:06"

    _svc_families = DIBSuppSVCFamilies()
    _svc_families.families.append(
        DIBSuppSVCFamilies.Family(name=DIBServiceFamily.CORE, version=1))
    _svc_families.families.append(
        DIBSuppSVCFamilies.Family(name=DIBServiceFamily.DEVICE_MANAGEMENT,
                                  version=2))
    _svc_families.families.append(
        DIBSuppSVCFamilies.Family(name=DIBServiceFamily.TUNNELING, version=1))
    _svc_families.families.append(
        DIBSuppSVCFamilies.Family(name=DIBServiceFamily.ROUTING, version=1))
    _svc_families.families.append(
        DIBSuppSVCFamilies.Family(
            name=DIBServiceFamily.REMOTE_CONFIGURATION_DIAGNOSIS, version=1))

    _frame_body.dibs.append(_device_information)
    _frame_body.dibs.append(_svc_families)
    _frame_header.set_length(_frame_body)

    search_response = KNXIPFrame(xknx)
    search_response.init(KNXIPServiceType.SEARCH_RESPONSE)
    search_response.header = _frame_header
    search_response.body = _frame_body
    search_response.normalize()

    return search_response