Add governed Files integrity operations UI
This commit is contained in:
@@ -6,6 +6,7 @@ import unittest
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
from fastapi import HTTPException
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
|
||||
@@ -16,6 +17,7 @@ from govoplan_files.backend.db.models import (
|
||||
FileIntegrityFinding,
|
||||
FileIntegrityScan,
|
||||
)
|
||||
from govoplan_files.backend.routes.integrity import _assert_expected_revision
|
||||
from govoplan_files.backend.storage.backends import LocalFilesystemStorageBackend
|
||||
from govoplan_files.backend.storage.common import FileStorageError
|
||||
from govoplan_files.backend.storage.integrity import (
|
||||
@@ -82,6 +84,7 @@ class IntegrityReconciliationTests(unittest.TestCase):
|
||||
backend=self.backend,
|
||||
)
|
||||
self.session.commit()
|
||||
self.assertEqual(1, scan.revision)
|
||||
|
||||
invocations = 0
|
||||
while scan.status != "completed":
|
||||
@@ -99,6 +102,7 @@ class IntegrityReconciliationTests(unittest.TestCase):
|
||||
self.fail("Integrity scan did not complete")
|
||||
|
||||
self.assertGreater(invocations, 3)
|
||||
self.assertEqual(1 + invocations, scan.revision)
|
||||
self.assertEqual(3, scan.scanned_blob_count)
|
||||
self.assertEqual(1, scan.verified_blob_count)
|
||||
self.assertEqual(2, scan.quarantined_blob_count)
|
||||
@@ -183,6 +187,13 @@ class IntegrityReconciliationTests(unittest.TestCase):
|
||||
self.assertEqual("already_deleted", repeated.action)
|
||||
self.assertFalse(repeated.changed)
|
||||
|
||||
def test_stale_integrity_action_revision_is_rejected(self) -> None:
|
||||
with self.assertRaises(HTTPException) as captured:
|
||||
_assert_expected_revision(3, 2)
|
||||
|
||||
self.assertEqual(409, captured.exception.status_code)
|
||||
self.assertIn("reload", str(captured.exception.detail).lower())
|
||||
|
||||
|
||||
def _blob(blob_id: str, filename: str, expected_data: bytes) -> FileBlob:
|
||||
return FileBlob(
|
||||
|
||||
Reference in New Issue
Block a user