Skip to content

Commit 4c84f95

Browse files
committed
fix: correct test patches and QualityDecision enum values
1 parent 6393a54 commit 4c84f95

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

tests/unit/test_document_action_tools.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ async def test_initialize_success(self):
7171
mock_nim_client = AsyncMock()
7272
mock_db_service = AsyncMock()
7373

74+
# Patch the module import - need to patch where it's imported from
7475
with patch("src.api.agents.document.action_tools.get_nim_client", return_value=mock_nim_client), \
7576
patch("src.api.services.document.get_document_db_service", return_value=mock_db_service), \
7677
patch.object(tools, "_load_status_data"):
@@ -88,8 +89,9 @@ async def test_initialize_without_database_fallback(self):
8889

8990
mock_nim_client = AsyncMock()
9091

92+
# Patch the module import - need to patch where it's imported from
9193
with patch("src.api.agents.document.action_tools.get_nim_client", return_value=mock_nim_client), \
92-
patch("src.api.services.document.get_document_db_service", side_effect=Exception("DB unavailable")), \
94+
patch("src.api.services.document.get_document_db_service", side_effect=ImportError("DB unavailable")), \
9395
patch.object(tools, "_load_status_data"):
9496

9597
await tools.initialize()
@@ -492,6 +494,7 @@ def test_load_status_data_file_not_exists(self):
492494

493495
def test_save_and_load_status_data(self):
494496
"""Test saving and loading status data from file."""
497+
pytest.importorskip("PIL", reason="PIL/Pillow not available")
495498
tools = DocumentActionTools()
496499

497500
# Use temporary file for testing
@@ -512,6 +515,12 @@ def test_save_and_load_status_data(self):
512515
# Verify file was created
513516
assert tmp_path.exists()
514517

518+
# Verify file has content
519+
with open(tmp_path, 'r') as f:
520+
saved_data = json.load(f)
521+
assert "doc-1" in saved_data
522+
assert "doc-2" in saved_data
523+
515524
# Clear and reload
516525
tools.document_statuses = {}
517526
tools._load_status_data()
@@ -714,7 +723,7 @@ def test_create_quality_score_from_validation_dict(self):
714723
"accuracy_score": 0.80,
715724
"compliance_score": 0.75,
716725
"quality_score": 0.85,
717-
"decision": "APPROVED",
726+
"decision": "APPROVE", # Use valid enum value
718727
"reasoning": "Good quality document",
719728
"issues_found": [],
720729
"confidence": 0.95,
@@ -727,7 +736,7 @@ def test_create_quality_score_from_validation_dict(self):
727736
assert result.accuracy_score == 0.80
728737
assert result.compliance_score == 0.75
729738
assert result.quality_score == 0.85
730-
assert result.decision.value == "APPROVED"
739+
assert result.decision.value == "APPROVE"
731740
assert isinstance(result.reasoning, dict)
732741
assert result.confidence == 0.95
733742
assert result.judge_model == tools.MODEL_LARGE_JUDGE
@@ -758,7 +767,7 @@ def __init__(self):
758767
self.accuracy_score = 0.80
759768
self.compliance_score = 0.75
760769
self.quality_score = 0.85
761-
self.decision = "APPROVED"
770+
self.decision = "APPROVE" # Use valid enum value
762771
self.reasoning = "Object reasoning"
763772
self.issues_found = []
764773
self.confidence = 0.95
@@ -767,7 +776,7 @@ def __init__(self):
767776
result = tools._create_quality_score_from_validation(obj)
768777

769778
assert result.overall_score == 0.85
770-
assert result.decision.value == "APPROVED"
779+
assert result.decision.value == "APPROVE"
771780
assert isinstance(result.reasoning, dict)
772781
assert result.reasoning["summary"] == "Object reasoning"
773782

0 commit comments

Comments
 (0)