def test_unroutable_demand(self):
        node_a = Node(name="nodeA", lat=0, lon=0)
        node_b = Node(name="nodeB", lat=0, lon=0)
        node_d = Node(name="nodeD")
        interface_a = Interface(
            name="inerfaceA-to-B",
            cost=4,
            capacity=100,
            node_object=node_a,
            remote_node_object=node_b,
            circuit_id=1,
        )
        interface_b = Interface(
            name="inerfaceB-to-A",
            cost=4,
            capacity=100,
            node_object=node_b,
            remote_node_object=node_a,
            circuit_id=1,
        )
        dmd_a_d = Demand(node_a, node_d, traffic=10)
        model = FlexModel(
            interface_objects=set([interface_a, interface_b]),
            node_objects=set([node_a, node_b, node_d]),
            demand_objects=set([dmd_a_d]),
            rsvp_lsp_objects=set([]),
        )
        model.update_simulation()

        self.assertEqual(dmd_a_d.path, "Unrouted")
    def test_demand_on_lsp(self):
        """
        Ensure the demand takes an available LSP
        :return:
        """
        node_a = Node(name="nodeA", lat=0, lon=0)
        node_b = Node(name="nodeB", lat=0, lon=0)
        node_d = Node(name="nodeD")
        interface_a = Interface(
            name="inerfaceA-to-B",
            cost=4,
            capacity=100,
            node_object=node_a,
            remote_node_object=node_b,
            circuit_id=1,
        )
        interface_b = Interface(
            name="inerfaceB-to-A",
            cost=4,
            capacity=100,
            node_object=node_b,
            remote_node_object=node_a,
            circuit_id=1,
        )
        dmd_a_b = Demand(node_a, node_b, traffic=10)

        lsp_a_b = RSVP_LSP(source_node_object=node_a,
                           dest_node_object=node_b,
                           lsp_name="lsp_a_b")

        model = FlexModel(
            interface_objects=set([interface_a, interface_b]),
            node_objects=set([node_a, node_b, node_d]),
            demand_objects=set([dmd_a_b]),
            rsvp_lsp_objects=set([lsp_a_b]),
        )

        model.update_simulation()

        self.assertEqual(
            str(dmd_a_b.path),
            "[[RSVP_LSP(source = nodeA, dest = nodeB, lsp_name = 'lsp_a_b')]]",
        )