def test_add(self): host = Host("test1") assert_equals(len(host), 1) host = Host(Hostname("test1")) host_entry_1 = Hostname("test1") assert_equals(len(host), 1) host.add(host_entry_1) assert_equals(len(host), 1)
def test_add_fqdn_to_shortname(self): # New fqdn updates the domain if exisiting domain is empty host = Host(Hostname("test1")) assert_equals(host[0].fqdn, "test1") host_entry_2 = Hostname("test1.example.com") host.add(host_entry_2) assert_equals(len(host), 1) assert_equals(host[0].fqdn, host_entry_2.fqdn)
def test_add_fqdn_to_shortname(self): # New fqdn updates the domain if exisiting domain is empty host = Host(Hostname('test1')) assert_equals(host[0].fqdn, 'test1') host_entry_2 = Hostname('test1.example.com') host.add(host_entry_2) assert_equals(len(host), 1) assert_equals(host[0].fqdn, host_entry_2.fqdn)
def test_add(self): host = Host('test1') assert_equals(len(host), 1) host = Host(Hostname('test1')) host_entry_1 = Hostname('test1') assert_equals(len(host), 1) host.add(host_entry_1) assert_equals(len(host), 1)
def test_add_new_host_existing_ip(self): # New Hostname with duplicate ip adds new host entry host = Host(Hostname("test1", "1.2.3.4")) host_entry_3 = Hostname("test2", "1.2.3.4") host.add(host_entry_3) assert_equals(len(host), 2) assert_equals(host[-1].fqdn, host_entry_3.fqdn) del host[-1] assert_equals(len(host), 1) host_entry_4 = Hostname("test2.example.com", "1.2.3.4") host.add(host_entry_4) assert_equals(len(host), 2) assert_equals(host[-1].fqdn, host_entry_4.fqdn)
def test_add_new_host_existing_ip(self): # New Hostname with duplicate ip adds new host entry host = Host(Hostname('test1', '1.2.3.4')) host_entry_3 = Hostname('test2', '1.2.3.4') host.add(host_entry_3) assert_equals(len(host), 2) assert_equals(host[-1].fqdn, host_entry_3.fqdn) del host[-1] assert_equals(len(host), 1) host_entry_4 = Hostname('test2.example.com', '1.2.3.4') host.add(host_entry_4) assert_equals(len(host), 2) assert_equals(host[-1].fqdn, host_entry_4.fqdn)
def test_add_ip_to_no_ip_host(self): # New IP with matching hostnames updates existing hostname's ip host_entry_1 = Hostname("test1.example.com") host = Host(host_entry_1) host_entry_2 = Hostname("test1", "1.2.3.4") host.add(host_entry_2) assert_equals(host[0].ip, host_entry_2.ip) assert_equals(len(host), 1) assert_equals(host[0].fqdn, host_entry_1.fqdn) host[0].ip = None host_entry_3 = Hostname("test1.example.com", "1.2.3.4") host.add(host_entry_3) assert_equals(len(host), 1) assert_equals(host[0].fqdn, host_entry_3.fqdn) assert_equals(host[0].ip, host_entry_3.ip)
def test_add_ip_to_no_ip_host(self): # New IP with matching hostnames updates existing hostname's ip host_entry_1 = Hostname('test1.example.com') host = Host(host_entry_1) host_entry_2 = Hostname('test1', '1.2.3.4') host.add(host_entry_2) assert_equals(host[0].ip, host_entry_2.ip) assert_equals(len(host), 1) assert_equals(host[0].fqdn, host_entry_1.fqdn) host[0].ip = None host_entry_3 = Hostname('test1.example.com', '1.2.3.4') host.add(host_entry_3) assert_equals(len(host), 1) assert_equals(host[0].fqdn, host_entry_3.fqdn) assert_equals(host[0].ip, host_entry_3.ip)
def test_add_new_ip_existing_name(self): # New Hostname with duplicate ip adds new host entry host = Host(Hostname("test1", "1.2.3.4")) host.add(Hostname("test1", "2.3.4.5")) assert_equals(len(host), 2) assert_equals(host[0].fqdn, "test1") assert_equals(host[1].fqdn, "test1") assert_equals(host[0].ip, "1.2.3.4") assert_equals(host[1].ip, "2.3.4.5") del host[-1] host.add(Hostname("test1.example.com", "2.3.4.5")) assert_equals(len(host), 2) assert_equals(host[0].fqdn, "test1.example.com") assert_equals(host[1].fqdn, "test1.example.com") assert_equals(host[0].ip, "1.2.3.4") assert_equals(host[1].ip, "2.3.4.5")
def test_add_new_ip_existing_name(self): # New Hostname with duplicate ip adds new host entry host = Host(Hostname('test1', '1.2.3.4')) host.add(Hostname('test1', '2.3.4.5')) assert_equals(len(host), 2) assert_equals(host[0].fqdn, 'test1') assert_equals(host[1].fqdn, 'test1') assert_equals(host[0].ip, '1.2.3.4') assert_equals(host[1].ip, '2.3.4.5') del host[-1] host.add(Hostname('test1.example.com', '2.3.4.5')) assert_equals(len(host), 2) assert_equals(host[0].fqdn, 'test1.example.com') assert_equals(host[1].fqdn, 'test1.example.com') assert_equals(host[0].ip, '1.2.3.4') assert_equals(host[1].ip, '2.3.4.5')
def test_display_hostname_update(self): host = Host("test1") assert_equals(host.display_hostname, "test1") host.add("test1.example.com") assert_equals(host.display_hostname, "test1.example.com")
def test_display_hostname_update(self): host = Host('test1') assert_equals(host.display_hostname, 'test1') host.add('test1.example.com') assert_equals(host.display_hostname, 'test1.example.com')