Add better get_ip_address coverage
Change-Id: I93be8d34dc38eb6e63b4d32b180df01ad61d2385
This commit is contained in:
parent
8805a02bed
commit
ac8fc0a826
@ -39,6 +39,18 @@ class TestDNSUtils(oslotest.base.BaseTestCase):
|
||||
super().setUp()
|
||||
self.useFixture(cfg_fixture.Config(CONF))
|
||||
|
||||
@mock.patch('socket.getaddrinfo')
|
||||
def test_get_ip_address(self, mock_getaddrinfo):
|
||||
mock_getaddrinfo.return_value = [
|
||||
(socket.AF_INET, socket.SOCK_STREAM, 0, '', ('192.0.2.1', 0))
|
||||
]
|
||||
self.assertEqual('192.0.2.1', dnsutils.get_ip_address('test'))
|
||||
|
||||
@mock.patch('socket.getaddrinfo')
|
||||
def test_get_ip_address_none(self, mock_getaddrinfo):
|
||||
mock_getaddrinfo.return_value = []
|
||||
self.assertIsNone(dnsutils.get_ip_address('test'))
|
||||
|
||||
@mock.patch.object(dns.query, 'udp')
|
||||
def test_send_udp_dns_message(self, mock_udp):
|
||||
CONF.set_override('all_tcp', False, 'service:worker')
|
||||
|
Loading…
Reference in New Issue
Block a user