def test_get_host_info(self): host_info = DataSourceVMware.get_host_info() self.assertTrue(host_info) self.assertTrue(host_info["hostname"]) self.assertTrue(host_info["local-hostname"]) self.assertTrue(host_info["local_hostname"]) self.assertTrue(host_info[DataSourceVMware.LOCAL_IPV4])
def test_get_host_info_ipv4(self, m_fn_ipaddr): m_fn_ipaddr.return_value = ("10.10.10.1", None) host_info = DataSourceVMware.get_host_info() self.assertTrue(host_info) self.assertTrue(host_info["hostname"]) self.assertTrue(host_info["hostname"] == "host.cloudinit.test") self.assertTrue(host_info["local-hostname"]) self.assertTrue(host_info["local_hostname"]) self.assertTrue(host_info[DataSourceVMware.LOCAL_IPV4]) self.assertTrue(host_info[DataSourceVMware.LOCAL_IPV4] == "10.10.10.1") self.assertFalse(host_info.get(DataSourceVMware.LOCAL_IPV6))
def test_get_host_info_ipv6(self, m_fn_ipaddr): m_fn_ipaddr.return_value = (None, "2001:db8::::::8888") host_info = DataSourceVMware.get_host_info() self.assertTrue(host_info) self.assertTrue(host_info["hostname"]) self.assertTrue(host_info["hostname"] == "host.cloudinit.test") self.assertTrue(host_info["local-hostname"]) self.assertTrue(host_info["local_hostname"]) self.assertTrue(host_info[DataSourceVMware.LOCAL_IPV6]) self.assertTrue( host_info[DataSourceVMware.LOCAL_IPV6] == "2001:db8::::::8888") self.assertFalse(host_info.get(DataSourceVMware.LOCAL_IPV4))
def test_get_host_info_dual(self, m_fn_ipaddr): m_fn_ipaddr.return_value = ("10.10.10.1", "2001:db8::::::8888") host_info = DataSourceVMware.get_host_info() self.assertTrue(host_info) self.assertTrue(host_info["hostname"]) self.assertTrue(host_info["hostname"] == "host.cloudinit.test") self.assertTrue(host_info["local-hostname"]) self.assertTrue(host_info["local_hostname"]) self.assertTrue(host_info[DataSourceVMware.LOCAL_IPV4]) self.assertTrue(host_info[DataSourceVMware.LOCAL_IPV4] == "10.10.10.1") self.assertTrue(host_info[DataSourceVMware.LOCAL_IPV6]) self.assertTrue( host_info[DataSourceVMware.LOCAL_IPV6] == "2001:db8::::::8888")