def test_parse_ip_cache(self): """ testing parsing ip cache info """ _output = io.open('tests/test_netshowlib/ip_addr_show.txt').read() output = io.StringIO(_output) result = ip_address_mod.parse_ip_cache(output) assert_equals( result, { 'vnet-v0': {'ipv6': [], 'ipv4': ['192.168.1.1/23']}, 'lo': { 'ipv4': ['127.0.0.1/8'], 'ipv6': ['::1/128'] }, 'net2compute': { 'ipv4': ['192.168.50.1/24'], 'ipv6': [] }, 'virbr0': { 'ipv4': ['192.168.122.1/24'], 'ipv6': [] }, 'vnet0': { 'ipv4': [], 'ipv6': [] }, 'eth0': { 'ipv4': ['192.168.0.33/24'], 'ipv6': [] } })
def test_parse_ip_cache(self): """ testing parsing ip cache info """ _output = io.open('tests/test_netshowlib/ip_addr_show.txt').read() output = io.StringIO(_output) result = ip_address_mod.parse_ip_cache(output) assert_equals( result, { 'vnet-v0': { 'ipv6': [], 'ipv4': ['192.168.1.1/23'] }, 'lo': { 'ipv4': ['127.0.0.1/8'], 'ipv6': ['::1/128'] }, 'net2compute': { 'ipv4': ['192.168.50.1/24'], 'ipv6': [] }, 'virbr0': { 'ipv4': ['192.168.122.1/24'], 'ipv6': [] }, 'vnet0': { 'ipv4': [], 'ipv6': [] }, 'eth0': { 'ipv4': ['192.168.0.33/24'], 'ipv6': [] } })
def test_run_ip_address(self, mock_ip_cache): """ get ipv6 and ipv4 info """ # using feature cache _output = io.open('tests/test_netshowlib/ip_addr_show.txt').read() output = io.StringIO(_output) mock_ip_cache.return_value = ip_address_mod.parse_ip_cache(output) _feature_cache = feature_cache.Cache() _feature_cache.run() ip_address = ip_address_mod.IpAddress('eth0', _feature_cache) ip_address.run() assert_equals(ip_address.ipv4, ['192.168.0.33/24']) assert_equals(ip_address.ipv6, []) # without feature cache ip_address = ip_address_mod.IpAddress('eth0') ip_address.run() assert_equals(ip_address.ipv4, ['192.168.0.33/24']) assert_equals(ip_address.ipv6, [])