Skip to content

Commit

Permalink
Refactor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yalef committed Dec 4, 2023
1 parent c21f46c commit 9100a07
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions tests/test_api/test_export.py
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"]

0 comments on commit 9100a07

Please sign in to comment.