This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
from django.core.management import call_command
|
||||
|
||||
from finance.models import FormulaExport
|
||||
|
||||
pytestmark = pytest.mark.django_db
|
||||
|
||||
|
||||
def test_worker_processes_queued_import_and_reports_export_failure(workspace):
|
||||
ds, *_ = workspace
|
||||
ds.status = "queued"
|
||||
ds.save(update_fields=["status"])
|
||||
with patch(
|
||||
"finance.management.commands.import_worker.process_dataset", return_value=ds
|
||||
) as process_import:
|
||||
call_command("import_worker", once=True)
|
||||
process_import.assert_called_once_with(ds.pk)
|
||||
|
||||
export = FormulaExport.objects.create(dataset=ds, user=ds.created_by, context={})
|
||||
with patch(
|
||||
"finance.management.commands.import_worker.process_formula_export",
|
||||
side_effect=ValueError("invalid export"),
|
||||
):
|
||||
call_command("import_worker", once=True)
|
||||
export.refresh_from_db()
|
||||
assert export.status == "processing"
|
||||
Reference in New Issue
Block a user