fix(parsers): close stale source jobs
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import timedelta
|
||||
from types import SimpleNamespace
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
@@ -10,6 +11,7 @@ from apps.parsers.source_cards import (
|
||||
)
|
||||
from django.http import Http404
|
||||
from django.test import SimpleTestCase
|
||||
from django.utils import timezone
|
||||
from rest_framework.exceptions import ValidationError
|
||||
|
||||
|
||||
@@ -249,6 +251,19 @@ class SourceCardServiceUnitTest(SimpleTestCase):
|
||||
),
|
||||
"in_progress",
|
||||
)
|
||||
stale_in_progress_load = SimpleNamespace(
|
||||
status="in_progress",
|
||||
updated_at=timezone.now() - timedelta(hours=3),
|
||||
)
|
||||
self.assertEqual(
|
||||
SourceCardService._get_status(
|
||||
definition=SourceCardService.get_definition("financial-indicators"),
|
||||
active_tasks=[],
|
||||
latest_load=stale_in_progress_load,
|
||||
last_updated_at=None,
|
||||
),
|
||||
"error",
|
||||
)
|
||||
self.assertEqual(
|
||||
SourceCardService._get_status(
|
||||
definition=SourceCardService.get_definition("financial-indicators"),
|
||||
|
||||
Reference in New Issue
Block a user