# Path: tests/support/decorators.py

# 
# Path: tests/support/views.py
# class ArtistViewSet(BaseViewSet):
#     """A simple ViewSet for listing or retrieving artists."""
# 
#     serializer_class = ArtistSerializer
#     # This is not testing pagination
#     pagination_class: Optional[Type[BasePagination]] = None
# 
#     def get_queryset(self) -> QuerySet[Artist]:
#         """Return the list of artists."""
#         return get_artists()
# 
# class AlbumViewSet(BaseViewSet):
#     """A simple ViewSet for listing or retrieving albums."""
# 
#     pagination_class = None
# 
#     def get_queryset(self) -> QuerySet[Album]:
#         """Return the list of albums."""
#         return get_albums()
# 
#     def get_serializer(self, *args: Any, **kwargs: Any) -> BaseSerializer:
#         """Test the use of dynamic serializers with the parser."""
#         return AlbumSerializer(*args, **kwargs)
# 
#     @action_route
#     def relationship_artist(self) -> Response:
#         """Do nothing."""
#         # Not currently called, just reversed.
#         return Response()
# 
#     @action_route
#     def related_artist(self) -> Response:
#         """Do nothing."""
#         # Not currently called, just reversed.
#         return Response()
# 
# class TrackViewSet(BaseViewSet):
#     """A simple ViewSet for listing or retrieving tracks."""
# 
#     serializer_class = TrackSerializer
#     pagination_class = None
# 
#     def get_queryset(self) -> QuerySet[Track]:
#         """Return the list of tracks."""
#         return get_tracks()


import json
from django.urls import reverse
from rest_framework.test import APIRequestFactory
from tests.support.decorators import mark_urls
from tests.support.views import ArtistViewSet, AlbumViewSet, TrackViewSet




@mark_urls
def test_detail_attributes(factory: APIRequestFactory) -> None:
    """You can render primary data object attributes."""
    request = factory.get(reverse("artist-detail", kwargs={"pk": 1}))
    view_detail = ArtistViewSet.as_view({"get": "retrieve"})
    response = view_detail(request, pk=1)
    response.render()
    assert response["Content-Type"] == "application/vnd.api+json"
    assert json.loads(response.content) == {
        "data": {
            "id": "1",
            "type": "artist",
            "attributes": {"firstName": "John", "lastName": "Coltrane"},
        }
    }



# Path: tests/support/decorators.py

# 
# Path: tests/support/views.py
# class ArtistViewSet(BaseViewSet):
#     """A simple ViewSet for listing or retrieving artists."""
# 
#     serializer_class = ArtistSerializer
#     # This is not testing pagination
#     pagination_class: Optional[Type[BasePagination]] = None
# 
#     def get_queryset(self) -> QuerySet[Artist]:
#         """Return the list of artists."""
#         return get_artists()
# 
# class AlbumViewSet(BaseViewSet):
#     """A simple ViewSet for listing or retrieving albums."""
# 
#     pagination_class = None
# 
#     def get_queryset(self) -> QuerySet[Album]:
#         """Return the list of albums."""
#         return get_albums()
# 
#     def get_serializer(self, *args: Any, **kwargs: Any) -> BaseSerializer:
#         """Test the use of dynamic serializers with the parser."""
#         return AlbumSerializer(*args, **kwargs)
# 
#     @action_route
#     def relationship_artist(self) -> Response:
#         """Do nothing."""
#         # Not currently called, just reversed.
#         return Response()
# 
#     @action_route
#     def related_artist(self) -> Response:
#         """Do nothing."""
#         # Not currently called, just reversed.
#         return Response()
# 
# class TrackViewSet(BaseViewSet):
#     """A simple ViewSet for listing or retrieving tracks."""
# 
#     serializer_class = TrackSerializer
#     pagination_class = None
# 
#     def get_queryset(self) -> QuerySet[Track]:
#         """Return the list of tracks."""
#         return get_tracks()


# Path: tests/test_renderers.py
import json
from django.urls import reverse
from rest_framework.test import APIRequestFactory
from tests.support.decorators import mark_urls
from tests.support.views import ArtistViewSet, AlbumViewSet, TrackViewSet





@mark_urls
def test_detail_attributes(factory: APIRequestFactory) -> None:
    """You can render primary data object attributes."""
    request = factory.get(reverse("artist-detail", kwargs={"pk": 1}))
    view_detail = ArtistViewSet.as_view({"get": "retrieve"})
    response = view_detail(request, pk=1)
    response.render()
    assert response["Content-Type"] == "application/vnd.api+json"
    assert json.loads(response.content) == {
        "data": {
            "id": "1",
            "type": "artist",
            "attributes": {"firstName": "John", "lastName": "Coltrane"},
        }
    }



@mark_urls