Skip to content

Commit

Permalink
Update format choice select for import admin pages
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyGreenwell94 committed Oct 19, 2023
1 parent 45978fa commit db6c6ff
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion import_export_extensions/admin/mixins/import_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def celery_import_job_results_view(
if job.import_status != models.ImportJob.ImportStatus.PARSED:
# display import form
context["import_form"] = base_forms.ImportForm(
import_formats=job.resource.SUPPORTED_FORMATS,
import_formats=self.get_import_formats(),
)
else:
context["confirm_form"] = Form()
Expand Down
32 changes: 32 additions & 0 deletions tests/test_admin/test_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,35 @@ def test_import_using_admin_model(

import_job.refresh_from_db()
assert import_job.import_status == ImportJob.ImportStatus.IMPORTED


@pytest.mark.usefixtures("existing_artist")
def test_import_admin_has_same_formats(
client: Client,
superuser: User,
artist_import_job: ImportJob,
):
"""Ensure input formats on import forms are the same.
Ensure Import forms on import and on import result pages
fetch format choices from the same source.
"""
client.force_login(superuser)
artist_import_job.import_status = ImportJob.ImportStatus.IMPORTED
artist_import_job.save()
import_response = client.get(
path=reverse("admin:fake_app_artist_import"),
)
import_response_result = client.get(
path=reverse(
"admin:fake_app_artist_import_job_results",
kwargs={"job_id": artist_import_job.id},
),
)
import_response_form = import_response.context_data["form"]
import_response_result_form = import_response_result.context_data["import_form"]
assert (
import_response_form.fields["input_format"].choices ==
import_response_result_form.fields["input_format"].choices
)

0 comments on commit db6c6ff

Please sign in to comment.