-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
9 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"] |