Example #1
0
    def test_absent_route_wildcard_match(self, route_property):
        original_route0 = _create_route("198.51.100.0/24", "192.0.2.1", "eth1",
                                        50, 103)
        original_route1 = _create_route("2001:db8:a::/64", "2001:db8:1::a",
                                        "eth2", 51, 104)

        absent_route0_state = _create_route_dict("198.51.100.0/24",
                                                 "192.0.2.1", "eth1", 50, 103)
        absent_route0_state[Route.STATE] = Route.STATE_ABSENT
        del absent_route0_state[route_property]
        new_route0 = RouteEntry(absent_route0_state)

        assert new_route0.match(original_route0)
        assert not new_route0.match(original_route1)
Example #2
0
    def test_absent_route_with_exact_match(self):
        route0 = _create_route("198.51.100.0/24", "192.0.2.1", "eth1", 50, 103)

        absent_r0 = _create_route_dict("198.51.100.0/24", "192.0.2.1", "eth1",
                                       50, 103)
        absent_r0[Route.STATE] = Route.STATE_ABSENT
        absent_route0 = RouteEntry(absent_r0)

        route1 = _create_route("2001:db8:a::/64", "2001:db8:1::a", "eth2", 51,
                               104)

        assert absent_route0.match(route0)
        assert absent_route0 == route0
        assert not absent_route0.match(route1)
        assert absent_route0 != route1
Example #3
0
 def test_absent_route_is_ignored_for_matching_and_equality(self):
     route = _create_route_dict("198.51.100.0/24", "192.0.2.1", "eth1", 50,
                                103)
     route[Route.STATE] = Route.STATE_ABSENT
     obj1 = RouteEntry(route)
     obj2 = RouteEntry(route)
     assert obj1.match(obj2)
     assert obj1 == obj2