예제 #1
0
 def test_length(self):
     hosts = HostnameList()
     hosts.add("test1")
     hosts.add("test2")
     assert_equals(len(hosts), 2)
     hosts.add("test1")
     assert_equals(len(hosts), 2)
예제 #2
0
 def test_indexing(self):
     hosts = HostnameList()
     hosts.add("test1")
     assert_equals(hosts[0].name, "test1")
     hosts.add("test2")
     assert_equals(hosts[1].name, "test2")
     assert_equals(hosts[-1].name, "test2")
예제 #3
0
 def test_str(self):
     hosts = HostnameList()
     hosts.add('1.2.3.4')
     assert_equals(hosts.__str__(), 'HostList (1)')
     hosts.add('2.3.4.5')
     hosts.add('3.4.5.6')
     hosts.add('4.5.6.7')
     assert_equals(hosts.__str__(), 'HostList (4)')
예제 #4
0
 def test_deletion(self):
     hosts = HostnameList()
     hosts.add("test1")
     assert_equals(len(hosts), 1)
     hosts.add("test2")
     assert_equals(len(hosts), 2)
     del hosts[-1]
     assert_equals(len(hosts), 1)
예제 #5
0
 def test_repr(self):
     hosts = HostnameList()
     hosts.add('1.2.3.4')
     assert_equals(hosts.__repr__(), '<HostList \'1.2.3.4\'>')
     hosts.add('2.3.4.5')
     hosts.add('3.4.5.6')
     hosts.add('4.5.6.7')
     assert_equals(hosts.__repr__(), '<HostList \'1.2.3.4, 2.3.4.5, 3.4.5.6\'>')
예제 #6
0
 def test_str(self):
     hosts = HostnameList()
     hosts.add("1.2.3.4")
     assert_equals(hosts.__str__(), "HostList (1)")
     hosts.add("2.3.4.5")
     hosts.add("3.4.5.6")
     hosts.add("4.5.6.7")
     assert_equals(hosts.__str__(), "HostList (4)")
예제 #7
0
 def test_repr(self):
     hosts = HostnameList()
     hosts.add("1.2.3.4")
     assert_equals(hosts.__repr__(), "<HostList '1.2.3.4'>")
     hosts.add("2.3.4.5")
     hosts.add("3.4.5.6")
     hosts.add("4.5.6.7")
     assert_equals(hosts.__repr__(), "<HostList '1.2.3.4, 2.3.4.5, 3.4.5.6'>")
예제 #8
0
    def test_contains_host(self):
        host = HostnameList()
        host.add(Hostname("test", "1.2.3.4"))
        assert_true("test" in host)
        assert_true(Hostname("test") in host)
        assert_true(Hostname("test", "1.2.3.4") in host)
        assert_true(Hostname("test.example.com") in host)
        assert_true(Hostname("test.example.com", "1.2.3.4") in host)

        assert_false("test1" in host)
        assert_false(Hostname("test1") in host)
        assert_false(Hostname("test1", "2.3.4.5") in host)
        assert_false(Hostname("test1.example.com") in host)
        assert_false(Hostname("test1.example.com", "2.3.4.5") in host)
예제 #9
0
    def test_contains_host(self):
        host = HostnameList()
        host.add(Hostname('test', '1.2.3.4'))
        assert_true('test' in host)
        assert_true(Hostname('test') in host)
        assert_true(Hostname('test', '1.2.3.4') in host)
        assert_true(Hostname('test.example.com') in host)
        assert_true(Hostname('test.example.com', '1.2.3.4') in host)

        assert_false('test1' in host)
        assert_false(Hostname('test1') in host)
        assert_false(Hostname('test1', '2.3.4.5') in host)
        assert_false(Hostname('test1.example.com') in host)
        assert_false(Hostname('test1.example.com', '2.3.4.5') in host)
예제 #10
0
 def test_add_fail(self):
     hosts = HostnameList()
     hosts.add('test1', '1.1.1.1')
     assert_equals(len(hosts), 1)
     assert_raises(TypeError, hosts.add)
     assert_equals(len(hosts), 1)
     hosts.add(ip='1.1.1.1')
     assert_equals(len(hosts), 1)
     hosts.add('1.1.1.1')
     assert_equals(len(hosts), 1)
예제 #11
0
 def test_add_fail(self):
     hosts = HostnameList()
     hosts.add("test1", "1.1.1.1")
     assert_equals(len(hosts), 1)
     assert_raises(TypeError, hosts.add)
     assert_equals(len(hosts), 1)
     hosts.add(ip="1.1.1.1")
     assert_equals(len(hosts), 1)
     hosts.add("1.1.1.1")
     assert_equals(len(hosts), 1)
예제 #12
0
 def test_indexing(self):
     hosts = HostnameList()
     hosts.add('test1')
     assert_equals(hosts[0].name, 'test1')
     hosts.add('test2')
     assert_equals(hosts[1].name, 'test2')
     assert_equals(hosts[-1].name, 'test2')
예제 #13
0
 def test_length(self):
     hosts = HostnameList()
     hosts.add('test1')
     hosts.add('test2')
     assert_equals(len(hosts), 2)
     hosts.add('test1')
     assert_equals(len(hosts), 2)
예제 #14
0
 def test_itr(self):
     hosts = HostnameList()
     hosts.add('test1')
     hosts.add('test2')
     host = hosts.next()
     assert_equals(host.name, 'test1')
     host = hosts.next()
     assert_equals(host.name, 'test2')
     assert_raises(StopIteration, hosts.next)
     host = hosts.next()
     assert_equals(host.name, 'test1')
     host = hosts.next()
     assert_equals(host.name, 'test2')
     assert_raises(StopIteration, hosts.next)
예제 #15
0
 def test_deletion(self):
     hosts = HostnameList()
     hosts.add('test1')
     assert_equals(len(hosts), 1)
     hosts.add('test2')
     assert_equals(len(hosts), 2)
     del hosts[-1]
     assert_equals(len(hosts), 1)
예제 #16
0
 def test_itr(self):
     hosts = HostnameList()
     hosts.add("test1")
     hosts.add("test2")
     host = hosts.next()
     assert_equals(host.name, "test1")
     host = hosts.next()
     assert_equals(host.name, "test2")
     assert_raises(StopIteration, hosts.next)
     host = hosts.next()
     assert_equals(host.name, "test1")
     host = hosts.next()
     assert_equals(host.name, "test2")
     assert_raises(StopIteration, hosts.next)
예제 #17
0
 def test_get(self):
     hosts = HostnameList()
     hosts.add("test")
     assert_equals(hosts.get("test"), Hostname("test"))
     assert_equals(hosts.get("test"), Hostname("test"))
     assert_equals(hosts.get("test"), Hostname("test"))
     assert_equals(hosts.get("test1"), None)
     hosts.add("test.example.com")
     assert_equals(hosts.get("test"), Hostname("test"))
     assert_equals(hosts.get("test.example.com"), Hostname("test"))
     assert_equals(hosts.get("test"), Hostname("test.example.com"))
     assert_equals(hosts.get("test.example.com"), Hostname("test.example.com"))
예제 #18
0
 def test_add(self):
     hosts = HostnameList()
     hosts.add("test1")
     assert_in("test1", hosts)
     assert_not_in("test2", hosts)
예제 #19
0
 def test_add(self):
     hosts = HostnameList()
     hosts.add('test1')
     assert_in('test1', hosts)
     assert_not_in('test2', hosts)
예제 #20
0
 def test_get(self):
     hosts = HostnameList()
     hosts.add('test')
     assert_equals(hosts.get('test'), Hostname('test'))
     assert_equals(hosts.get('test'), Hostname('test'))
     assert_equals(hosts.get('test'), Hostname('test'))
     assert_equals(hosts.get('test1'), None)
     hosts.add('test.example.com')
     assert_equals(hosts.get('test'), Hostname('test'))
     assert_equals(hosts.get('test.example.com'), Hostname('test'))
     assert_equals(hosts.get('test'), Hostname('test.example.com'))
     assert_equals(hosts.get('test.example.com'), Hostname('test.example.com'))