Files
django-lasuite/tests/malware_detection/test_check_analysis_pending_command.py
Manuel Raynaud 519f58ea8a (malware) allow a malware detection backend to reschedule a task
For multiple reasons a task can be blocked in processing task. We wanto
to allow a backend to reschedule a blocked task.
2025-12-02 09:31:29 +01:00

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()