Beispiel #1
0
    def test_search_response_reception(self):
        """Test function of gateway scanner."""
        xknx = XKNX()
        gateway_scanner = GatewayScanner(xknx)
        test_search_response = fake_router_search_response(xknx)
        udp_client_mock = create_autospec(UDPClient)
        udp_client_mock.local_addr = ("192.168.42.50", 0)
        udp_client_mock.getsockname.return_value = ("192.168.42.50", 0)

        assert gateway_scanner.found_gateways == []
        gateway_scanner._response_rec_callback(
            test_search_response,
            udp_client_mock,
            interface="en1",
        )

        assert str(gateway_scanner.found_gateways[0]) == str(
            self.gateway_desc_both)
        assert len(gateway_scanner.found_gateways) == 1

        gateway_scanner._response_rec_callback(
            test_search_response,
            udp_client_mock,
            interface="eth1",
        )
        assert len(gateway_scanner.found_gateways) == 1
Beispiel #2
0
    def test_search_response_reception(self):
        """Test function of gateway scanner."""
        xknx = XKNX()
        gateway_scanner = GatewayScanner(xknx)
        test_search_response = fake_router_search_response()
        udp_transport_mock = create_autospec(UDPTransport)
        udp_transport_mock.local_addr = ("192.168.42.50", 0)
        udp_transport_mock.getsockname.return_value = ("192.168.42.50", 0)

        assert not gateway_scanner.found_gateways
        gateway_scanner._response_rec_callback(
            test_search_response,
            HPAI("192.168.42.50", 0),
            udp_transport_mock,
            interface="en1",
        )
        assert len(gateway_scanner.found_gateways) == 1

        gateway_scanner._response_rec_callback(
            test_search_response,
            HPAI("192.168.42.230", 0),
            udp_transport_mock,
            interface="eth1",
        )
        assert len(gateway_scanner.found_gateways) == 1

        assert str(gateway_scanner.found_gateways[
            test_search_response.body.control_endpoint]) == str(
                self.gateway_desc_both)
Beispiel #3
0
    def test_search_response_reception(self):
        """Test function of gateway scanner."""
        # pylint: disable=protected-access
        xknx = XKNX(loop=self.loop)
        gateway_scanner = GatewayScanner(xknx)
        test_search_response = fake_router_search_response(xknx)
        udp_client_mock = unittest.mock.create_autospec(UDPClient)
        udp_client_mock.local_addr = ("192.168.42.50", 0, "en1")
        udp_client_mock.getsockname.return_value = ("192.168.42.50", 0)

        self.assertEqual(gateway_scanner.found_gateways, [])
        gateway_scanner._response_rec_callback(test_search_response, udp_client_mock)
        self.assertEqual(str(gateway_scanner.found_gateways[0]),
                         str(self.gateway_desc_both))
Beispiel #4
0
    def test_search_response_reception(self):
        """Test function of gateway scanner."""
        # pylint: disable=protected-access
        xknx = XKNX(loop=self.loop)
        gateway_scanner = GatewayScanner(xknx)
        test_search_response = fake_router_search_response(xknx)
        udp_client_mock = unittest.mock.create_autospec(UDPClient)
        udp_client_mock.local_addr = ("192.168.42.50", 0, "en1")
        udp_client_mock.getsockname.return_value = ("192.168.42.50", 0)

        self.assertEqual(gateway_scanner.found_gateways, [])
        gateway_scanner._response_rec_callback(test_search_response,
                                               udp_client_mock)
        self.assertEqual(str(gateway_scanner.found_gateways[0]),
                         str(self.gateway_desc_both))
Beispiel #5
0
    def test_search_response_reception(self):
        """Test function of gateway scanner."""
        # pylint: disable=protected-access
        xknx = XKNX(loop=self.loop)
        gateway_scanner = GatewayScanner(xknx)
        search_response = fake_router_search_response(xknx)
        udp_client = unittest.mock.create_autospec(UDPClient)
        udp_client.local_addr = ("192.168.42.50", 0, "en1")
        udp_client.getsockname.return_value = ("192.168.42.50", 0)
        router_gw_descriptor = GatewayDescriptor(name="Gira KNX/IP-Router",
                                                 ip_addr="192.168.42.10",
                                                 port=3671,
                                                 local_interface="en1",
                                                 local_ip="192.168.42.50",
                                                 supports_tunnelling=True,
                                                 supports_routing=True)

        self.assertEqual(gateway_scanner.found_gateways, [])
        gateway_scanner._response_rec_callback(search_response, udp_client)
        self.assertEqual(str(gateway_scanner.found_gateways[0]),
                         str(router_gw_descriptor))