Skip to content

Commit 22224a7

Browse files
committed
Test: Add test for specific-common-specific2-common2-specific3 content
This commit adds a new test, `test__exclude_common_contents__double_specific`, to verify that the `exclude_common_contents` function correctly handles complex cases with multiple common content sections interspersed with specific content. The test covers the following scenario: - Specific content 1 - Common content 1 - Specific content 2 - Common content 2 - Specific content 3 The test uses the following fixtures: - `specific_lines_3`: Provides the specific lines for the third section. - `readme_content__double_specific`: Generates the README content with the specific-common-specific2-common2-specific3 structure. The test asserts that all the specific lines from all three sections are preserved in the output, while the common lines from both common content sections are removed. This ensures that the function correctly handles complex scenarios with multiple common and specific content sections.
1 parent 5072f64 commit 22224a7

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

tests/test_ai_tutor.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,5 +470,57 @@ def test__exclude_common_contents__double(
470470
assert end_marker.strip() not in result
471471

472472

473+
@pytest.fixture
474+
def specific_lines_3() -> Tuple[str]:
475+
"""Provides a tuple of specific lines to be inserted after two common content blocks."""
476+
return (
477+
"# This is also specific content, after two common blocks.",
478+
"# It should be preserved in the output, too."
479+
)
480+
481+
482+
@pytest.fixture
483+
def readme_content__double_specific(
484+
readme_content_double:str,
485+
specific_lines_3:Tuple[str],
486+
) -> str:
487+
return (
488+
readme_content_double
489+
+ '\n'.join(specific_lines_3) + '\n'
490+
)
491+
492+
493+
def test__exclude_common_contents__double_specific(
494+
readme_content__double_specific:str,
495+
start_marker:str,
496+
end_marker:str,
497+
specific_lines:Tuple[str],
498+
specific_lines_2:Tuple[str],
499+
specific_lines_3:Tuple[str],
500+
common_lines:Tuple[str],
501+
common_lines_2:Tuple[str],
502+
):
503+
result = ai_tutor.exclude_common_contents(
504+
readme_content=readme_content__double_specific,
505+
common_content_start_marker=start_marker,
506+
common_content_end_marker=end_marker,
507+
)
508+
509+
for line in (specific_lines + specific_lines_2 + specific_lines_3):
510+
assert line.strip() in result, ("\n"
511+
f"Could not find line: {line}\n"
512+
f"in result: {result}."
513+
)
514+
515+
for line in (common_lines + common_lines_2):
516+
assert line.strip() not in result, ("\n"
517+
f"Found line: {line}\n"
518+
f"in result: {result}."
519+
)
520+
521+
assert start_marker.strip() not in result
522+
assert end_marker.strip() not in result
523+
524+
473525
if '__main__' == __name__:
474526
pytest.main([__file__])

0 commit comments

Comments
 (0)