File tree Expand file tree Collapse file tree 2 files changed +31
-2
lines changed
lib/idp_common_pkg/tests/unit
src/lambda/test_set_file_copier Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,35 @@ def test_path_extraction_logic():
2525 assert dest_key == expected
2626
2727
28+ @pytest .mark .unit
29+ def test_baseline_path_extraction_logic ():
30+ """Test the path extraction logic for baseline files from testset bucket"""
31+ # Simulate the path extraction logic from _copy_baseline_from_testset
32+ file_key = "fcc_benchmark/input/fcc_benchmark/033f718b16cb597c065930410752c294.pdf"
33+ test_set_id = "demo_test_set"
34+
35+ # Extract test set name and file name from path (format: test_set_name/input/file_name)
36+ path_parts = file_key .split ("/" )
37+ if len (path_parts ) >= 3 and path_parts [1 ] == "input" :
38+ source_test_set_name = path_parts [0 ]
39+ file_name = "/" .join (path_parts [2 :]) # Get full path after 'input/'
40+
41+ # Source baseline path in testset bucket
42+ source_baseline_prefix = f"{ source_test_set_name } /baseline/{ file_name } /"
43+ # Destination baseline path
44+ dest_baseline_prefix = f"{ test_set_id } /baseline/{ file_name } /"
45+
46+ expected_source = (
47+ "fcc_benchmark/baseline/fcc_benchmark/033f718b16cb597c065930410752c294.pdf/"
48+ )
49+ expected_dest = (
50+ "demo_test_set/baseline/fcc_benchmark/033f718b16cb597c065930410752c294.pdf/"
51+ )
52+
53+ assert source_baseline_prefix == expected_source
54+ assert dest_baseline_prefix == expected_dest
55+
56+
2857@pytest .mark .unit
2958def test_path_extraction_edge_cases ():
3059 """Test edge cases for path extraction"""
Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ def handler(event, context):
6060 path_parts = file_key .split ('/' )
6161 if len (path_parts ) >= 3 and path_parts [1 ] == 'input' :
6262 test_set_name = path_parts [0 ]
63- file_name = path_parts [2 ]
63+ file_name = '/' . join ( path_parts [2 :]) # Get full path after 'input/'
6464 baseline_prefix = f"{ test_set_name } /baseline/{ file_name } /"
6565 baseline_check_bucket = source_bucket
6666 else :
@@ -185,7 +185,7 @@ def _copy_baseline_from_testset(test_set_id, files):
185185 path_parts = file_key .split ('/' )
186186 if len (path_parts ) >= 3 and path_parts [1 ] == 'input' :
187187 source_test_set_name = path_parts [0 ]
188- file_name = path_parts [2 ]
188+ file_name = '/' . join ( path_parts [2 :]) # Get full path after 'input/'
189189
190190 # Source baseline path in testset bucket
191191 source_baseline_prefix = f"{ source_test_set_name } /baseline/{ file_name } /"
You can’t perform that action at this time.
0 commit comments