Пример #1
0
    def test_find_nearby_empty(self):
        resolver = 'unused'
        ips = []

        result = fierce.find_nearby(resolver, ips)
        expected = {}

        self.assertEqual(expected, result)
Пример #2
0
    def test_find_nearby_empty(self):
        resolver = 'unused'
        ips = []

        result = fierce.find_nearby(resolver, ips)
        expected = {}

        assert expected == result
Пример #3
0
    def test_find_nearby_basic(self):
        resolver = 'unused'
        ips = [
            ipaddress.IPv4Address('192.168.1.0'),
            ipaddress.IPv4Address('192.168.1.1'),
        ]
        side_effect = [
            [MockAnswer('sd1.example.com.')],
            [MockAnswer('sd2.example.com.')],
        ]

        with unittest.mock.patch.object(fierce, 'reverse_query', side_effect=side_effect):
            result = fierce.find_nearby(resolver, ips)

        expected = {
            '192.168.1.0': 'sd1.example.com.',
            '192.168.1.1': 'sd2.example.com.',
        }

        self.assertEqual(expected, result)
Пример #4
0
    def test_find_nearby_filter_func(self):
        resolver = 'unused'
        ips = [
            ipaddress.IPv4Address('192.168.1.0'),
            ipaddress.IPv4Address('192.168.1.1'),
        ]
        side_effect = [
            [MockAnswer('sd1.example.com.')],
            [MockAnswer('sd2.example.com.')],
        ]

        def filter_func(reverse_result):
            return reverse_result == 'sd1.example.com.'

        with unittest.mock.patch.object(fierce,
                                        'reverse_query',
                                        side_effect=side_effect):
            result = fierce.find_nearby(resolver, ips, filter_func=filter_func)

        expected = {
            '192.168.1.0': 'sd1.example.com.',
        }

        assert expected == result