Esempio n. 1
0
    def test_should_get_a_nodes_ip_from_the_root_node_of_its_first_parent(
            self):
        root_node = DeliveryNodeFactory()
        self.assertEqual(
            root_node.get_ip(), {
                'id': root_node.id,
                'consignee': root_node.consignee,
                'location': root_node.location
            })

        second_parent = DeliveryNodeFactory()
        self.assertEqual(
            second_parent.get_ip(), {
                'id': second_parent.id,
                'consignee': second_parent.consignee,
                'location': second_parent.location
            })

        first_level_child_node = DeliveryNodeFactory(
            parents=[(root_node, 2), (second_parent, 3)])
        self.assertEqual(
            first_level_child_node.get_ip(), {
                'id': root_node.id,
                'consignee': root_node.consignee,
                'location': root_node.location
            })

        second_level_child_node = DeliveryNodeFactory(
            parents=[(first_level_child_node, 2)])
        self.assertEqual(
            second_level_child_node.get_ip(), {
                'id': root_node.id,
                'consignee': root_node.consignee,
                'location': root_node.location
            })
Esempio n. 2
0
    def test_should_get_a_nodes_ip_from_the_root_node_of_the_node_delivery(
            self):
        delivery = DeliveryFactory()

        root_node = DeliveryNodeFactory(distribution_plan=delivery)
        self.assertEqual(
            root_node.get_ip(), {
                'id': root_node.id,
                'consignee': root_node.consignee,
                'location': root_node.location
            })

        intermediary_node = DeliveryNodeFactory(distribution_plan=delivery,
                                                parents=[(root_node, 5)])
        self.assertEqual(
            intermediary_node.get_ip(), {
                'id': root_node.id,
                'consignee': root_node.consignee,
                'location': root_node.location
            })

        leaf_node = DeliveryNodeFactory(parents=[(intermediary_node, 3)],
                                        distribution_plan=delivery)
        self.assertEqual(
            leaf_node.get_ip(), {
                'id': root_node.id,
                'consignee': root_node.consignee,
                'location': root_node.location
            })
Esempio n. 3
0
    def test_should_get_a_nodes_ip_from_the_root_node_of_the_node_delivery(self):
        delivery = DeliveryFactory()

        root_node = DeliveryNodeFactory(distribution_plan=delivery)
        self.assertEqual(root_node.get_ip(),
                         {'id': root_node.id, 'consignee': root_node.consignee, 'location': root_node.location})

        intermediary_node = DeliveryNodeFactory(distribution_plan=delivery, parents=[(root_node, 5)])
        self.assertEqual(intermediary_node.get_ip(),
                         {'id': root_node.id, 'consignee': root_node.consignee, 'location': root_node.location})

        leaf_node = DeliveryNodeFactory(parents=[(intermediary_node, 3)], distribution_plan=delivery)
        self.assertEqual(leaf_node.get_ip(),
                         {'id': root_node.id, 'consignee': root_node.consignee, 'location': root_node.location})
Esempio n. 4
0
    def test_should_get_a_nodes_ip_from_the_root_node_of_its_first_parent(self):
        root_node = DeliveryNodeFactory()
        self.assertEqual(root_node.get_ip(),
                         {'id': root_node.id, 'consignee': root_node.consignee, 'location': root_node.location})

        second_parent = DeliveryNodeFactory()
        self.assertEqual(second_parent.get_ip(),
                         {'id': second_parent.id, 'consignee': second_parent.consignee,
                          'location': second_parent.location})

        first_level_child_node = DeliveryNodeFactory(parents=[(root_node, 2), (second_parent, 3)])
        self.assertEqual(first_level_child_node.get_ip(),
                         {'id': root_node.id, 'consignee': root_node.consignee, 'location': root_node.location})

        second_level_child_node = DeliveryNodeFactory(parents=[(first_level_child_node, 2)])
        self.assertEqual(second_level_child_node.get_ip(),
                         {'id': root_node.id, 'consignee': root_node.consignee, 'location': root_node.location})