Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update format choice select for import admin pages #20

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
)