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'])
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')
def test_ipv6_timeout(self, _, __, ___): """Test when `dig` call timeout for the IPv6 detection""" self.assertEqual( WanIp().value, 'XXX.YY.ZZ.TTT, 0123::4567:89a:dead:beef' )
def test_ipv4_only(self, _, __): """Test only public IPv4 detection""" self.assertEqual( WanIp().value, 'XXX.YY.ZZ.TTT' )
def test_ipv6_and_ipv4(self, _, __): """Test the regular case : Both IPv4 and IPv6 are retrieved""" self.assertEqual( WanIp().value, 'XXX.YY.ZZ.TTT, 0123::4567:89a:dead:beef' )
def test_no_address(self, _, __, ___): """Test when no address could be retrieved""" self.assertEqual(WanIp().value, 'No Address')
def test_ipv4_timeout_twice(self, _, __, ___): """Test when both `dig` and `wget` trigger timeouts...""" self.assertEqual(WanIp().value, 'No Address')
def test_ipv4_timeout_twice_socket_error(self, _, __, ___): """Test when both `dig` timeouts and `URLOpen` raises `socket.timeout`...""" self.assertEqual(WanIp().value, 'No Address')
def test_ipv4_timeout_twice_socket_error(self, _, __): """Test when both `dig` timeouts and `URLOpen` raises `socket.timeout`...""" self.assertListEmpty(WanIp().value)
def test_ipv4_timeout_twice(self, _, __): """Test when both `dig` and `URLOpen` trigger timeouts...""" self.assertListEmpty(WanIp().value)