Skip to content

Commit 5072f64

Browse files
committed
Test: Add test for specific-common-specific content and refactor fixtures
This commit adds a new test, `test__exclude_common_contents__specific_common_specific`, to verify that the `exclude_common_contents` function correctly handles the case where specific content is present both before and after a common content block. To support this test, the following changes were made: - Added `readme_content_specific_common_specific` fixture: This fixture generates README content with specific content before and after a common content block. - Refactored `readme_content_double` fixture: This fixture now reuses the `readme_content_specific_common_specific` fixture to generate its content, improving code reuse and reducing duplication. The new test asserts that the specific lines from both sections are preserved in the output, while the common lines are removed. This ensures that the function correctly handles the specific-common-specific scenario.
1 parent caadab5 commit 5072f64

1 file changed

Lines changed: 43 additions & 4 deletions

File tree

tests/test_ai_tutor.py

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,47 @@ def specific_lines_2() -> Tuple[str]:
377377
)
378378

379379

380+
@pytest.fixture
381+
def readme_content_specific_common_specific(
382+
readme_content_single:str,
383+
specific_lines_2:Tuple[str],
384+
) -> str:
385+
return (
386+
readme_content_single
387+
+ '\n'.join(specific_lines_2) + '\n'
388+
)
389+
390+
391+
def test__exclude_common_contents__specific_common_specific(
392+
readme_content_specific_common_specific:str,
393+
start_marker:str,
394+
end_marker:str,
395+
specific_lines:Tuple[str],
396+
common_lines:Tuple[str],
397+
specific_lines_2:Tuple[str],
398+
):
399+
result = ai_tutor.exclude_common_contents(
400+
readme_content=readme_content_specific_common_specific,
401+
common_content_start_marker=start_marker,
402+
common_content_end_marker=end_marker,
403+
)
404+
405+
for line in (specific_lines + specific_lines_2):
406+
assert line.strip() in result, ("\n"
407+
f"Could not find line: {line}\n"
408+
f"in result: {result}."
409+
)
410+
411+
for line in common_lines:
412+
assert line.strip() not in result, ("\n"
413+
f"Found line: {line}\n"
414+
f"in result: {result}."
415+
)
416+
417+
assert start_marker.strip() not in result
418+
assert end_marker.strip() not in result
419+
420+
380421
@pytest.fixture
381422
def common_lines_2() -> Tuple[str]:
382423
return (
@@ -387,15 +428,13 @@ def common_lines_2() -> Tuple[str]:
387428

388429
@pytest.fixture
389430
def readme_content_double(
390-
readme_content_single:str,
391-
specific_lines_2:Tuple[str],
431+
readme_content_specific_common_specific:str,
392432
start_marker:str,
393433
common_lines_2:Tuple[str],
394434
end_marker:str
395435
) -> str:
396436
return (
397-
readme_content_single
398-
+ '\n'.join(specific_lines_2) + '\n'
437+
readme_content_specific_common_specific
399438
+ create_common_block(start_marker, common_lines_2, end_marker)
400439
)
401440

0 commit comments

Comments
 (0)