Ejemplo n.º 1
0
 def test_inequality(self):
     group01 = NetworkGroup()
     group02 = NetworkGroup()
     group01.add(self.address01)
     assert_not_equals(group01, group02)
     group02.add(self.address01)
     assert_not_equals(group01, group02)
Ejemplo n.º 2
0
 def test_print_group_network(self):
     source = NetworkGroup(name='source')
     destination = NetworkGroup(name='destination')
     network = NetworkLayer(source=source, destination=destination)
     ace = Ace(network=network)
     expected = 'permit ip source destination'
     assert_equals(ace.print_group(), expected)
Ejemplo n.º 3
0
 def test_contains(self):
     group = NetworkGroup()
     assert_in('10.0.0.0/8', group)
     group.add(self.address01)
     assert_in('10.0.0.0/8', group)
     assert_not_in('11.0.0.0/8', group)
     assert_not_in('0.0.0.0/0', group)
Ejemplo n.º 4
0
 def test_repr(self):
     group = NetworkGroup()
     assert_equals(group.__repr__(), "<NetworkGroup 0.0.0.0/0>")
     group.add(self.address01)
     assert_equals(group.__repr__(), "<NetworkGroup 10.0.0.0/8>")
     group.add(self.address02)
     assert_equals(group.__repr__(), "<NetworkGroup [u'10.0.0.0/8', u'192.168.0.0/16']>")
Ejemplo n.º 5
0
 def test_add(self):
     group = NetworkGroup()
     address04 = IPv4Network(u'10.0.0.0/8')
     assert_true(group.add(self.address01))
     assert_false(group.add(self.address01))
     assert_true(group.add(self.address02))
     assert_false(group.add(self.address02))
     assert_false(group.add(self.address01))
     assert_false(group.add(address04))
Ejemplo n.º 6
0
 def test_remove(self):
     group = NetworkGroup()
     group.add(self.address01)
     assert_false(group.remove(self.address02))
     group.add(self.address02)
     assert_true(group.remove(self.address01))
     assert_true(group.remove(self.address02))
     assert_false(group.remove(self.address01))
     assert_false(group.has(self.address01))
     assert_false(group.has(self.address02))
Ejemplo n.º 7
0
 def test_address_is_default(self):
     group = NetworkGroup()
     assert_true(group.address_is_default)
     group.add(self.address01)
     assert_false(group.address_is_default)
     group.add(self.address02)
     group.remove(self.address01)
     assert_false(group.address_is_default)
     group.remove(self.address02)
     assert_true(group.address_is_default)
Ejemplo n.º 8
0
 def test_has(self):
     group = NetworkGroup()
     addresses = list()
     addresses.append(self.address01)
     addresses.append(self.address02)
     addresses.append(self.address03)
     for index, address in enumerate(addresses):
         for added in addresses[:index]:
             assert_true(group.has(added))
         for not_added in addresses[index:]:
             assert_false(group.has(not_added))
         group.add(address)
Ejemplo n.º 9
0
 def test_addresses_getitem(self):
     group = NetworkGroup()
     assert_equals(group.addresses[0], IPv4Network(u'0.0.0.0/0'))
Ejemplo n.º 10
0
 def test_addresses_getter(self):
     group = NetworkGroup()
     assert_equals(group.addresses, [NetworkGroup._default_address])
Ejemplo n.º 11
0
 def test_contains_invalid(self):
     group = NetworkGroup()
     for value in self.invalid_types:
         assert_raises(TypeError, group.__contains__, value)