fix: Update existing test to include timestamp in MockLog
Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
@@ -231,9 +231,7 @@ class TestSubtaskRetry:
|
|||||||
|
|
||||||
with patch("app.tasks.extract_metadata_with_gpt.extract_metadata_with_gpt") as mock_extract:
|
with patch("app.tasks.extract_metadata_with_gpt.extract_metadata_with_gpt") as mock_extract:
|
||||||
mock_extract.delay.return_value = mock_task
|
mock_extract.delay.return_value = mock_task
|
||||||
response = client.post(
|
response = client.post(f"/api/files/{file_record.id}/retry-subtask?subtask_name=embed_metadata_into_pdf")
|
||||||
f"/api/files/{file_record.id}/retry-subtask?subtask_name=embed_metadata_into_pdf"
|
|
||||||
)
|
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
data = response.json()
|
data = response.json()
|
||||||
assert data["status"] == "success"
|
assert data["status"] == "success"
|
||||||
@@ -503,21 +501,25 @@ class TestStepSummary:
|
|||||||
|
|
||||||
def test_summary_with_mixed_statuses(self):
|
def test_summary_with_mixed_statuses(self):
|
||||||
"""Test step summary with various statuses."""
|
"""Test step summary with various statuses."""
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
from app.views.files import _compute_step_summary
|
from app.views.files import _compute_step_summary
|
||||||
|
|
||||||
# Create mock logs
|
# Create mock logs
|
||||||
class MockLog:
|
class MockLog:
|
||||||
def __init__(self, step_name, status):
|
def __init__(self, step_name, status, timestamp):
|
||||||
self.step_name = step_name
|
self.step_name = step_name
|
||||||
self.status = status
|
self.status = status
|
||||||
|
self.timestamp = timestamp
|
||||||
|
|
||||||
|
now = datetime.now()
|
||||||
logs = [
|
logs = [
|
||||||
MockLog("hash_file", "success"),
|
MockLog("hash_file", "success", now - timedelta(minutes=5)),
|
||||||
MockLog("create_file_record", "success"),
|
MockLog("create_file_record", "success", now - timedelta(minutes=4)),
|
||||||
MockLog("extract_metadata_with_gpt", "failure"),
|
MockLog("extract_metadata_with_gpt", "failure", now - timedelta(minutes=3)),
|
||||||
MockLog("upload_to_dropbox", "success"),
|
MockLog("upload_to_dropbox", "success", now - timedelta(minutes=2)),
|
||||||
MockLog("upload_to_s3", "failure"),
|
MockLog("upload_to_s3", "failure", now - timedelta(minutes=1)),
|
||||||
MockLog("upload_to_nextcloud", "in_progress"),
|
MockLog("upload_to_nextcloud", "in_progress", now),
|
||||||
]
|
]
|
||||||
|
|
||||||
summary = _compute_step_summary(logs)
|
summary = _compute_step_summary(logs)
|
||||||
|
|||||||
Reference in New Issue
Block a user