Example #1
0
 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)
Example #2
0
 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)
Example #3
0
 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)
Example #4
0
 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)
Example #5
0
 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)
Example #6
0
 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)
Example #7
0
 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)
Example #8
0
 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)
Example #9
0
 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")
Example #10
0
 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')
Example #11
0
 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")
Example #12
0
 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')