示例#1
0
    def test_no_address(self, _, __):
        """
        Test when no address could be retrieved.
        Additionally check the `output` method behavior.
        """
        wan_ip = WanIp()

        output_mock = MagicMock()
        wan_ip.output(output_mock)

        self.assertListEmpty(wan_ip.value)
        self.assertEqual(output_mock.append.call_args[0][1],
                         DEFAULT_CONFIG['default_strings']['no_address'])
示例#2
0
    def test_ipv6_timeout(self, urlopen_mock, _):
        """
        Test when `dig` call timeout for the IPv6 detection.
        Additionally check the `output` method behavior.
        """
        urlopen_mock.return_value.read.return_value = b'0123::4567:89a:dead:beef\n'

        wan_ip = WanIp()

        output_mock = MagicMock()
        wan_ip.output(output_mock)

        self.assertListEqual(wan_ip.value,
                             ['XXX.YY.ZZ.TTT', '0123::4567:89a:dead:beef'])
        self.assertEqual(output_mock.append.call_args[0][1],
                         'XXX.YY.ZZ.TTT, 0123::4567:89a:dead:beef')