diff --git a/tests/test_api/test_export.py b/tests/test_api/test_export.py index a3a508c..8e15bc8 100644 --- a/tests/test_api/test_export.py +++ b/tests/test_api/test_export.py @@ -1,41 +1,38 @@ -from django.contrib.auth.models import User -from django.test.client import Client from django.urls import reverse +from rest_framework import status +from rest_framework.test import APIClient + import pytest from import_export_extensions.models import ExportJob @pytest.mark.django_db(transaction=True) -def test_export_api_creates_export_job(client: Client, superuser: User): +def test_export_api_creates_export_job(admin_api_client: APIClient): """Ensure export start API creates new export job.""" - client.force_login(superuser) - - response = client.post( + response = admin_api_client.post( path=reverse("export-artist-start"), data={ "file_format": "csv", }, ) + assert response.status_code == status.HTTP_201_CREATED assert response.data["export_status"] == "CREATED" assert ExportJob.objects.first() @pytest.mark.django_db(transaction=True) def test_export_api_detail( - client: Client, + admin_api_client: APIClient, artist_export_job: ExportJob, - superuser: User, ): """Ensure export detail API shows current export job status.""" - client.force_login(superuser) - - response = client.get( + response = admin_api_client.get( path=reverse( "export-artist-detail", kwargs={"pk": artist_export_job.id}, ), ) - + assert response.status_code == status.HTTP_200_OK assert response.data["export_finished"]