mirror of
https://github.com/coleam00/Archon.git
synced 2025-12-30 21:49:30 -05:00
fix: Update tests for single-file discovery and discovery stage integration
- Fix discovery service tests to match new single-file return format - Remove obsolete tests for removed discovery methods - Update progress mapper tests for new discovery stage ranges - Fix stage range expectations after adding discovery stage (2,3) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -21,12 +21,12 @@ class TestProgressMapper:
|
||||
def test_stage_ranges_are_valid(self, progress_mapper):
|
||||
"""Test that all stage ranges are valid and sequential."""
|
||||
ranges = progress_mapper.STAGE_RANGES
|
||||
|
||||
|
||||
# Test that ranges don't overlap (except for aliases)
|
||||
crawl_stages = ["starting", "analyzing", "crawling", "processing",
|
||||
"source_creation", "document_storage", "code_extraction",
|
||||
crawl_stages = ["starting", "analyzing", "crawling", "processing",
|
||||
"source_creation", "document_storage", "code_extraction",
|
||||
"finalization", "completed"]
|
||||
|
||||
|
||||
last_end = 0
|
||||
for stage in crawl_stages[:-1]: # Exclude completed which is (100, 100)
|
||||
start, end = ranges[stage]
|
||||
@@ -37,17 +37,17 @@ class TestProgressMapper:
|
||||
# Test that code extraction gets the largest range (it's the longest)
|
||||
code_start, code_end = ranges["code_extraction"]
|
||||
code_range = code_end - code_start
|
||||
|
||||
doc_start, doc_end = ranges["document_storage"]
|
||||
|
||||
doc_start, doc_end = ranges["document_storage"]
|
||||
doc_range = doc_end - doc_start
|
||||
|
||||
|
||||
assert code_range > doc_range, "Code extraction should have larger range than document storage"
|
||||
|
||||
def test_map_progress_basic_functionality(self, progress_mapper):
|
||||
"""Test basic progress mapping functionality."""
|
||||
# Test crawling stage at 50%
|
||||
result = progress_mapper.map_progress("crawling", 50.0)
|
||||
|
||||
|
||||
# Should be halfway between crawling range (2-5%)
|
||||
expected = 2 + (50 / 100) * (5 - 2) # 3.5%, rounded to 4
|
||||
assert result == 4
|
||||
@@ -56,16 +56,16 @@ class TestProgressMapper:
|
||||
"""Test progress mapping for document storage stage."""
|
||||
# Test document storage at 25%
|
||||
result = progress_mapper.map_progress("document_storage", 25.0)
|
||||
|
||||
|
||||
# Should be 25% through document_storage range (10-30%)
|
||||
expected = 10 + (25 / 100) * (30 - 10) # 10 + 5 = 15
|
||||
assert result == 15
|
||||
|
||||
def test_map_progress_code_extraction(self, progress_mapper):
|
||||
"""Test progress mapping for code extraction stage."""
|
||||
# Test code extraction at 50%
|
||||
# Test code extraction at 50%
|
||||
result = progress_mapper.map_progress("code_extraction", 50.0)
|
||||
|
||||
|
||||
# Should be 50% through code_extraction range (30-95%)
|
||||
expected = 30 + (50 / 100) * (95 - 30) # 30 + 32.5 = 62.5, rounded to 62
|
||||
assert result == 62
|
||||
@@ -75,10 +75,10 @@ class TestProgressMapper:
|
||||
# Set initial progress to 50%
|
||||
result1 = progress_mapper.map_progress("document_storage", 100.0) # Should be 30%
|
||||
assert result1 == 30
|
||||
|
||||
|
||||
# Try to map a lower stage with lower progress
|
||||
result2 = progress_mapper.map_progress("crawling", 50.0) # Would normally be ~3.5%
|
||||
|
||||
|
||||
# Should maintain higher progress
|
||||
assert result2 == 30 # Stays at previous high value
|
||||
|
||||
@@ -86,11 +86,11 @@ class TestProgressMapper:
|
||||
"""Test that stage progress is clamped to 0-100 range."""
|
||||
# Test negative progress
|
||||
result = progress_mapper.map_progress("crawling", -10.0)
|
||||
expected = 2 # Start of crawling range
|
||||
expected = 3 # Start of crawling range (updated after discovery stage)
|
||||
assert result == expected
|
||||
|
||||
|
||||
# Test progress over 100
|
||||
result = progress_mapper.map_progress("crawling", 150.0)
|
||||
result = progress_mapper.map_progress("crawling", 150.0)
|
||||
expected = 5 # End of crawling range
|
||||
assert result == expected
|
||||
|
||||
@@ -109,16 +109,17 @@ class TestProgressMapper:
|
||||
# Set some initial progress
|
||||
progress_mapper.map_progress("crawling", 50)
|
||||
current = progress_mapper.last_overall_progress
|
||||
|
||||
|
||||
# Try unknown stage
|
||||
result = progress_mapper.map_progress("unknown_stage", 75)
|
||||
|
||||
|
||||
# Should maintain current progress
|
||||
assert result == current
|
||||
|
||||
def test_get_stage_range(self, progress_mapper):
|
||||
"""Test getting stage ranges."""
|
||||
assert progress_mapper.get_stage_range("crawling") == (2, 5)
|
||||
assert progress_mapper.get_stage_range("discovery") == (2, 3) # New discovery stage
|
||||
assert progress_mapper.get_stage_range("crawling") == (3, 5) # Updated after discovery
|
||||
assert progress_mapper.get_stage_range("document_storage") == (10, 30)
|
||||
assert progress_mapper.get_stage_range("code_extraction") == (30, 95)
|
||||
assert progress_mapper.get_stage_range("unknown") == (0, 100) # Default
|
||||
@@ -128,11 +129,11 @@ class TestProgressMapper:
|
||||
# Test normal case
|
||||
result = progress_mapper.calculate_stage_progress(25, 100)
|
||||
assert result == 25.0
|
||||
|
||||
|
||||
# Test division by zero protection
|
||||
result = progress_mapper.calculate_stage_progress(10, 0)
|
||||
assert result == 0.0
|
||||
|
||||
|
||||
# Test negative max protection
|
||||
result = progress_mapper.calculate_stage_progress(10, -5)
|
||||
assert result == 0.0
|
||||
@@ -141,7 +142,7 @@ class TestProgressMapper:
|
||||
"""Test batch progress mapping."""
|
||||
# Test batch 3 of 6 in document_storage stage
|
||||
result = progress_mapper.map_batch_progress("document_storage", 3, 6)
|
||||
|
||||
|
||||
# Should be (3-1)/6 = 33.3% through document_storage stage
|
||||
# document_storage is 10-30%, so 33.3% of 20% = 6.67%, so 10 + 6.67 = 16.67 ≈ 17
|
||||
assert result == 17
|
||||
@@ -159,10 +160,10 @@ class TestProgressMapper:
|
||||
progress_mapper.map_progress("crawling", 50)
|
||||
assert progress_mapper.last_overall_progress > 0
|
||||
assert progress_mapper.current_stage != "starting"
|
||||
|
||||
|
||||
# Reset
|
||||
progress_mapper.reset()
|
||||
|
||||
|
||||
# Should be back to initial state
|
||||
assert progress_mapper.last_overall_progress == 0
|
||||
assert progress_mapper.current_stage == "starting"
|
||||
@@ -172,7 +173,7 @@ class TestProgressMapper:
|
||||
# Initial state
|
||||
assert progress_mapper.get_current_stage() == "starting"
|
||||
assert progress_mapper.get_current_progress() == 0
|
||||
|
||||
|
||||
# After mapping some progress
|
||||
progress_mapper.map_progress("document_storage", 50)
|
||||
assert progress_mapper.get_current_stage() == "document_storage"
|
||||
@@ -196,9 +197,9 @@ class TestProgressMapper:
|
||||
("finalization", 100, 100), # Finalization
|
||||
("completed", 0, 100), # Completion
|
||||
]
|
||||
|
||||
|
||||
progress_mapper.reset()
|
||||
|
||||
|
||||
for stage, stage_progress, expected_overall in stages:
|
||||
result = progress_mapper.map_progress(stage, stage_progress)
|
||||
assert result == expected_overall, f"Stage {stage} at {stage_progress}% should map to {expected_overall}%, got {result}%"
|
||||
@@ -206,7 +207,7 @@ class TestProgressMapper:
|
||||
def test_upload_stage_ranges(self, progress_mapper):
|
||||
"""Test upload-specific stage ranges."""
|
||||
upload_stages = ["reading", "extracting", "chunking", "creating_source", "summarizing", "storing"]
|
||||
|
||||
|
||||
# Test that upload stages have valid ranges
|
||||
last_end = 0
|
||||
for stage in upload_stages:
|
||||
@@ -214,6 +215,6 @@ class TestProgressMapper:
|
||||
assert start >= last_end, f"Upload stage {stage} overlaps with previous"
|
||||
assert end > start, f"Upload stage {stage} has invalid range"
|
||||
last_end = end
|
||||
|
||||
|
||||
# Test that final upload stage reaches 100%
|
||||
assert progress_mapper.get_stage_range("storing")[1] == 100
|
||||
assert progress_mapper.get_stage_range("storing")[1] == 100
|
||||
|
||||
Reference in New Issue
Block a user