fix parser schedule run issues
All checks were successful
CI/CD Pipeline / Manual Action Help (push) Has been skipped
CI/CD Pipeline / Start Dev Containers in Dokploy (push) Has been skipped
CI/CD Pipeline / Drop and Recreate Dev Database (push) Has been skipped
CI/CD Pipeline / Quality Gate (push) Successful in 1m53s
CI/CD Pipeline / Build and Push Images (push) Successful in 2m42s
CI/CD Pipeline / Internal Notify (push) Successful in 1s
CI/CD Pipeline / Deploy Dev in Dokploy (push) Successful in 1s
All checks were successful
CI/CD Pipeline / Manual Action Help (push) Has been skipped
CI/CD Pipeline / Start Dev Containers in Dokploy (push) Has been skipped
CI/CD Pipeline / Drop and Recreate Dev Database (push) Has been skipped
CI/CD Pipeline / Quality Gate (push) Successful in 1m53s
CI/CD Pipeline / Build and Push Images (push) Successful in 2m42s
CI/CD Pipeline / Internal Notify (push) Successful in 1s
CI/CD Pipeline / Deploy Dev in Dokploy (push) Successful in 1s
This commit is contained in:
@@ -5,6 +5,7 @@ from __future__ import annotations
|
||||
import io
|
||||
import os
|
||||
import tempfile
|
||||
from unittest.mock import Mock, patch
|
||||
|
||||
from apps.parsers.models import FinancialReport, FinancialReportLine, ProcurementRecord
|
||||
from django.core.files.uploadedfile import SimpleUploadedFile
|
||||
@@ -341,3 +342,28 @@ class ParsersViewSetTest(APITestCase):
|
||||
|
||||
self.assertEqual(updated.status_code, status.HTTP_200_OK)
|
||||
self.assertEqual(updated.data["planned_inspections"], "weekly")
|
||||
|
||||
def test_run_sync_inspections_accepts_limited_sync_params(self):
|
||||
self.client.force_authenticate(self.user)
|
||||
url = reverse("api_v1:parsers:run-parser", args=["sync_inspections"])
|
||||
payload = {
|
||||
"max_months_per_law": 1,
|
||||
"start_year": 2026,
|
||||
"start_month": 4,
|
||||
"include_fz294": True,
|
||||
"include_fz248": False,
|
||||
"current_year": 2026,
|
||||
"current_month": 4,
|
||||
}
|
||||
|
||||
with patch(
|
||||
"apps.parsers.views.tasks.sync_inspections.apply_async",
|
||||
return_value=Mock(id="task-123"),
|
||||
) as apply_async_mock:
|
||||
response = self.client.post(url, payload, format="json")
|
||||
|
||||
self.assertEqual(response.status_code, status.HTTP_202_ACCEPTED)
|
||||
task_kwargs = apply_async_mock.call_args.kwargs["kwargs"]
|
||||
for key, value in payload.items():
|
||||
self.assertEqual(task_kwargs[key], value)
|
||||
self.assertEqual(task_kwargs["requested_by_id"], self.user.id)
|
||||
|
||||
Reference in New Issue
Block a user