#2299: Add tests to check for 'not implemented' warning message.

This commit is contained in:
Nick Todd
2024-04-25 17:56:55 +01:00
parent 0c375ebe4d
commit ec8b46f3bc
2 changed files with 24 additions and 0 deletions

View File

@@ -1,3 +1,5 @@
import warnings
import pytest
from primaite.simulator.file_system.file import File
@@ -84,3 +86,14 @@ def test_file_corrupt_repair_restore(file_system):
file.restore()
assert file.health_status == FileSystemItemHealthStatus.GOOD
def test_file_warning_triggered(file_system):
file: File = file_system.create_file(file_name="test_file.txt", folder_name="test_folder")
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
file.check_hash()
# Check warning issued
assert len(w) == 1
assert "not implemented" in str(w[-1].message)

View File

@@ -1,3 +1,4 @@
import warnings
from typing import Tuple
import pytest
@@ -63,6 +64,16 @@ def test_folder_checkhash_request(populated_file_system):
assert folder.health_status == FileSystemItemHealthStatus.CORRUPT
def test_folder_warning_triggered(populated_file_system):
fs, folder, _ = populated_file_system
with warnings.catch_warnings(record=True) as w:
warnings.simplefilter("always")
fs.apply_request(request=["folder", folder.name, "checkhash"])
# Check warning issued
assert len(w) == 1
assert "not implemented" in str(w[-1].message)
def test_folder_repair_request(populated_file_system):
"""Test that an agent can request a folder repair."""
fs, folder, file = populated_file_system