mirror of
https://github.com/suitenumerique/django-lasuite
synced 2026-04-25 17:15:14 +02:00
For multiple reasons a task can be blocked in processing task. We wanto to allow a backend to reschedule a blocked task.
39 lines
1.2 KiB
Python
39 lines
1.2 KiB
Python
"""Test the check_analysis_pending command."""
|
|
|
|
from unittest import mock
|
|
|
|
from django.core.management import call_command
|
|
|
|
from lasuite.malware_detection.backends.base import BaseBackend
|
|
from lasuite.malware_detection.models import MalwareDetection
|
|
|
|
mock_launch_next_analysis = mock.MagicMock()
|
|
|
|
|
|
class TestBackend(BaseBackend):
|
|
"""Test backend."""
|
|
|
|
def launch_next_analysis(self) -> None:
|
|
"""Launch the next analysis."""
|
|
mock_launch_next_analysis()
|
|
|
|
def analyse_file(self, file_path: str, **kwargs) -> None:
|
|
"""Analyse a file."""
|
|
|
|
def reschedule_processing_task(self, malware_detection_record: MalwareDetection) -> None:
|
|
"""Reschedule the processing task for a malware detection record."""
|
|
|
|
|
|
def test_check_analysis_pending_command(settings):
|
|
"""Test the check_analysis_pending command."""
|
|
settings.MALWARE_DETECTION = {
|
|
"BACKEND": "tests.malware_detection.test_check_analysis_pending_command.TestBackend",
|
|
"PARAMETERS": {
|
|
"callback_path": "tests.malware_detection.test_check_analysis_pending_command.dummy_callback",
|
|
},
|
|
}
|
|
|
|
call_command("check_analysis_pending")
|
|
|
|
mock_launch_next_analysis.assert_called_once()
|