Пример #1
0
    def test_get_children(self):
        hive = Hive(self.host)
        self.assertEqual(hive.add_network(subnet), True)
        self.assertEqual(hive.add_network(supernet), True)

        # Add subnet to supernet as a child
        self.assertEqual(hive.add_child_to_net(supernet, subnet), True)

        # Check if a subnet is a child of a supernet
        self.assertEqual(subnet in hive.get_children(supernet), True)
Пример #2
0
    def test_add_child_to_net(self):
        hive = Hive(self.host, self.db)

        net = "10.0.0.0/24"

        subnet1 = "10.0.0.0/25"
        subnet2 = "10.0.0.128/25"

        # Must be failed because net is not added yet
        self.assertRaises(ValueError, hive.add_child_to_net, net, subnet1)
        self.assertRaises(ValueError, hive.add_child_to_net, net, subnet2)

        # Create set of NetworkEntry before addition a net child to it
        self.assertEqual(hive.add_network(net), True)
        self.assertEqual(hive.add_network(subnet1), True)
        self.assertEqual(hive.add_network(subnet2), True)

        # Must be true
        self.assertEqual(hive.add_child_to_net(net, subnet1), True)
        self.assertEqual(hive.add_child_to_net(net, subnet2), True)