def test_sub_routes_with_duplicated_sub_route_names(self):
        generalized_sub_route_1 = Route(None, 'sub_route_1')
        generalized_sub_route_2 = Route(None, 'sub_route_2')
        generalized_route = Route(
            FAKE_VIEW,
            None,
            [generalized_sub_route_1, generalized_sub_route_2],
            )

        duplicated_sub_route_name = 'duplicated_sub_route_name'
        specialized_sub_route_1 = generalized_sub_route_1.create_specialization(
            additional_sub_routes=[Route(None, duplicated_sub_route_name)],
            )
        specialized_sub_route_2 = generalized_sub_route_2.create_specialization(
            additional_sub_routes=[Route(None, duplicated_sub_route_name)],
            )

        with assert_raises_substring(
            DuplicatedRouteError,
            duplicated_sub_route_name,
            ):
            generalized_route.create_specialization(
                specialized_sub_routes=[
                    specialized_sub_route_1,
                    specialized_sub_route_2,
                    ],
                )
 def test_sub_route_duplicating_direct_ancestor_name(self):
     duplicated_route_name = 'route_name'
     sub_route = Route(FAKE_VIEW, duplicated_route_name)
     with assert_raises_substring(
         DuplicatedRouteError,
         duplicated_route_name,
         ):
         Route(FAKE_VIEW, duplicated_route_name, [sub_route])
 def test_sibling_sub_routes_with_duplicated_names(self):
     duplicated_route_name = 'sub_route_1'
     sub_route_1 = Route(FAKE_VIEW, duplicated_route_name)
     sub_route_2 = Route(FAKE_VIEW, duplicated_route_name)
     with assert_raises_substring(
         DuplicatedRouteError,
         duplicated_route_name,
         ):
         Route(FAKE_VIEW, FAKE_ROUTE_NAME, (sub_route_1, sub_route_2))
    def test_sub_route_specializing_current_route(self):
        generalized_route = Route(None, FAKE_ROUTE_NAME)

        sub_route = generalized_route.create_specialization()

        with assert_raises_substring(DuplicatedRouteError, FAKE_ROUTE_NAME):
            generalized_route.create_specialization(
                specialized_sub_routes=[sub_route],
                )
    def test_non_existing_sub_route(self):
        sub_route = Route(FAKE_VIEW, 'sub_route_1')
        route = Route(FAKE_VIEW, FAKE_ROUTE_NAME, [sub_route])

        non_existing_route_name = 'non_existing'
        with assert_raises_substring(
            NonExistingRouteError,
            non_existing_route_name,
            ):
            route.get_route_by_name(non_existing_route_name)
    def test_additional_duplicated_sub_route(self):
        sub_route_1 = Route(None, FAKE_ROUTE_NAME)
        generalized_route = Route(FAKE_VIEW, None, [sub_route_1])

        intermediate_route = generalized_route.create_specialization()

        sub_route_2 = Route(None, FAKE_ROUTE_NAME)
        with assert_raises_substring(DuplicatedRouteError, FAKE_ROUTE_NAME):
            intermediate_route.create_specialization(
                additional_sub_routes=[sub_route_2],
                )
 def test_sub_route_duplicating_route_name(self):
     duplicated_route_name = 'route_name'
     generalized_route = Route(FAKE_VIEW, duplicated_route_name)
     sub_route = Route(None, duplicated_route_name)
     with assert_raises_substring(
         DuplicatedRouteError,
         duplicated_route_name,
         ):
         generalized_route.create_specialization(
             additional_sub_routes=[sub_route],
             )
    def test_non_existing_named_sub_route(self):
        generalized_route = Route(None, None)

        non_existing_sub_route_name = 'non_existing_route'
        generalized_sub_route = Route(None, non_existing_sub_route_name)
        specialized_sub_route = generalized_sub_route.create_specialization()

        with assert_raises_substring(
            InvalidSpecializationError,
            non_existing_sub_route_name,
            ):
            generalized_route.create_specialization(
                specialized_sub_routes=[specialized_sub_route],
                )
    def test_non_existing_unnamed_sub_route(self):
        unnamed_sub_route = Route(None, None)
        generalized_route = Route(None, None, [unnamed_sub_route])

        unnamed_generalized_sub_route = Route(FAKE_VIEW, None)
        unnamed_specialized_sub_route = \
            unnamed_generalized_sub_route.create_specialization()

        with assert_raises_substring(
            InvalidSpecializationError,
            repr(unnamed_generalized_sub_route),
            ):
            generalized_route.create_specialization(
                specialized_sub_routes=[unnamed_specialized_sub_route],
                )
示例#10
0
    def test_unnamed_sub_routes_specializing_common_generalization(self):
        generalized_sub_route = Route(None, None)
        generalized_route = Route(None, None, [generalized_sub_route])

        specialized_sub_route_1 = \
            generalized_sub_route.create_specialization(FAKE_VIEW)
        specialized_sub_route_2 = generalized_sub_route.create_specialization()

        with assert_raises_substring(
            InvalidSpecializationError,
            'cannot be specialized twice',
            ):
            generalized_route.create_specialization(specialized_sub_routes=[
                specialized_sub_route_1,
                specialized_sub_route_2,
                ])
示例#11
0
 def test_sub_route_duplicating_indirect_ancestor_name(self):
     duplicated_route_name = 'route_name'
     intermediate_sub_route = Route(
         None,
         None,
         [Route(FAKE_VIEW, duplicated_route_name)],
         )
     with assert_raises_substring(
         DuplicatedRouteError,
         duplicated_route_name,
         ):
         Route(
             FAKE_VIEW,
             duplicated_route_name,
             [intermediate_sub_route],
             )
示例#12
0
    def test_sub_route_with_non_specialized_route(self):
        sub_route_name = 'sub_route_name'
        generalized_sub_route = Route(None, sub_route_name)
        generalized_route = Route(
            FAKE_VIEW,
            FAKE_ROUTE_NAME,
            [generalized_sub_route],
            )
        unspecialized_route = Route(None, sub_route_name)

        with assert_raises_substring(
            InvalidSpecializationError,
            sub_route_name,
            ):
            generalized_route.create_specialization(
                specialized_sub_routes=[unspecialized_route],
                )
示例#13
0
    def test_sub_route_duplicating_cousin_name(self):
        duplicated_route_name = 'duplicated_route_name'

        leaf_sub_route_1 = Route(FAKE_VIEW, duplicated_route_name)
        intermediate_sub_route_1 = Route(object(), None, [leaf_sub_route_1])

        leaf_sub_route_2 = Route(None, duplicated_route_name)
        intermediate_sub_route_2 = Route(object(), None, [leaf_sub_route_2])

        with assert_raises_substring(
            DuplicatedRouteError,
            duplicated_route_name,
            ):
            Route(
                FAKE_VIEW,
                FAKE_ROUTE_NAME,
                (intermediate_sub_route_1, intermediate_sub_route_2),
                )
示例#14
0
    def test_adding_duplicate_sub_route_name(self):
        generalized_sub_route = Route(None, FAKE_ROUTE_NAME)
        generalized_route = Route(FAKE_VIEW, None, [generalized_sub_route])

        duplicated_sub_route_name = 'duplicated_sub_route_name'
        specialized_sub_route = generalized_sub_route.create_specialization(
            additional_sub_routes=[Route(None, duplicated_sub_route_name)],
            )

        additional_sub_route = Route(None, duplicated_sub_route_name)

        with assert_raises_substring(
            DuplicatedRouteError,
            duplicated_sub_route_name,
            ):
            generalized_route.create_specialization(
                additional_sub_routes=[additional_sub_route],
                specialized_sub_routes=[specialized_sub_route],
                )
示例#15
0
    def test_specializing_with_invalid_sub_route(self):
        """
        The same validation routines as in the single inheritance case should be
        used.

        """
        sub_route_1 = Route(None, FAKE_ROUTE_NAME)
        generalized_route = Route(None, None, [sub_route_1])

        intermediate_route = generalized_route.create_specialization()

        sub_route_2 = Route(FAKE_VIEW, FAKE_ROUTE_NAME)
        with assert_raises_substring(
            InvalidSpecializationError,
            FAKE_ROUTE_NAME
            ):
            intermediate_route.create_specialization(
                specialized_sub_routes=[sub_route_2.create_specialization()],
                )
示例#16
0
    def test_additional_route_on_sub_route_duplicating_name(self):
        duplicated_name = 'duplicated_name'
        generalized_sub_route_1 = Route(None, duplicated_name)
        generalized_sub_route_2 = Route(None, 'sub_route')
        generalized_route = Route(
            FAKE_VIEW,
            FAKE_ROUTE_NAME,
            [generalized_sub_route_1, generalized_sub_route_2],
            )

        specialized_sub_route_1 = \
            generalized_sub_route_1.create_specialization()

        specialized_sub_route_2 = generalized_sub_route_2.create_specialization(
            additional_sub_routes=[Route(None, duplicated_name)]
            )

        with assert_raises_substring(DuplicatedRouteError, duplicated_name):
            generalized_route.create_specialization(
                specialized_sub_routes=[
                    specialized_sub_route_1,
                    specialized_sub_route_2,
                    ],
                )
示例#17
0
 def test_equivalent_sibling_sub_routes_without_names(self):
     sub_route_1 = Route(FAKE_VIEW, None)
     sub_route_2 = Route(FAKE_VIEW, None)
     with assert_raises_substring(DuplicatedRouteError, repr(sub_route_1)):
         Route(FAKE_VIEW, FAKE_ROUTE_NAME, (sub_route_1, sub_route_2))