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)
 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)
 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']>")
 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))
 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))
 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)
 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)