Beispiel #1
0
    def test_serializers_have_get_absolute_url_method(self):
        serializers = JSONAPISerializer.__subclasses__()
        base_get_absolute_url = JSONAPISerializer.get_absolute_url

        for serializer in serializers:
            if not re.match('^(api_test|test).*', serializer.__module__):
                assert hasattr(serializer, 'get_absolute_url'), 'No get_absolute_url method'
                assert_not_equal(serializer.get_absolute_url, base_get_absolute_url)
Beispiel #2
0
    def test_serializers_have_get_absolute_url_method(self):
        serializers = JSONAPISerializer.__subclasses__()
        base_get_absolute_url = JSONAPISerializer.get_absolute_url

        for serializer in serializers:
            if not re.match('^(api_test|test).*', serializer.__module__):
                assert hasattr(serializer, 'get_absolute_url'), 'No get_absolute_url method'
                assert_not_equal(serializer.get_absolute_url, base_get_absolute_url)
    def test_serializers_have_get_absolute_url_method(self):
        serializers = JSONAPISerializer.__subclasses__()
        base_get_absolute_url = JSONAPISerializer.get_absolute_url

        for serializer in serializers:
            # Waffle endpoints are nonstandard
            if serializer == WaffleSerializer or serializer == BaseWaffleSerializer:
                continue
            if not re.match('^(api_test|test).*', serializer.__module__):
                assert hasattr(
                    serializer,
                    'get_absolute_url'), 'No get_absolute_url method'

                assert_not_equal(serializer.get_absolute_url,
                                 base_get_absolute_url)
Beispiel #4
0
    def test_serializers_have_get_absolute_url_method(self):
        serializers = JSONAPISerializer.__subclasses__()
        base_get_absolute_url = JSONAPISerializer.get_absolute_url

        for serializer in serializers:
            # Waffle endpoints are nonstandard
            if serializer == WaffleSerializer or serializer == BaseWaffleSerializer:
                continue
            if not re.match('^(api_test|test).*', serializer.__module__):
                assert hasattr(
                    serializer, 'get_absolute_url'
                ), 'No get_absolute_url method'

                assert_not_equal(
                    serializer.get_absolute_url,
                    base_get_absolute_url
                )
Beispiel #5
0
 def test_serializers_types_are_kebab_case(self):
     serializers = JSONAPISerializer.__subclasses__()
     request = make_drf_request_with_version(version=KEBAB_CASE_VERSION)
     for serializer in serializers:
         if serializer == WaffleSerializer or serializer == BaseWaffleSerializer:
             continue
         if serializer == SchemaSerializer:
             for schema_serializer in serializer.__subclasses__():
                 if 'Deprecated' not in str(schema_serializer):
                     if hasattr(serializer.Meta, 'get_type'):
                         json_type = serializer.Meta.get_type(request)
                     else:
                         json_type = serializer.Meta.type_
                     assert '_' not in json_type
                     assert json_type == json_type.lower()
         if not re.match('^(api_test|test).*', serializer.__module__):
             if hasattr(serializer.Meta, 'get_type'):
                 json_type = serializer.Meta.get_type(request)
             else:
                 json_type = serializer.Meta.type_
             assert '_' not in json_type
             assert json_type == json_type.lower()