@@ -57,7 +57,26 @@ def test_read_file_content_with_non_notebook(tmp_path: Path):
5757 mock_process .assert_not_called ()
5858
5959
60- # TODO: test with include patterns: ['*.txt']
60+ # Test that when using a ['*.txt'] as include pattern, only .txt files are processed & .py files are excluded
61+ def test_include_txt_pattern (temp_directory : Path , sample_query : dict [str , Any ]) -> None :
62+ sample_query ["local_path" ] = temp_directory
63+ sample_query ["include_patterns" ] = ["*.txt" ]
64+
65+ result = _scan_directory (temp_directory , query = sample_query )
66+ assert result is not None , "Result should not be None"
67+
68+ files = _extract_files_content (query = sample_query , node = result , max_file_size = 1_000_000 )
69+ file_paths = [f ["path" ] for f in files ]
70+ assert len (files ) == 5 , "Should have found exactly 5 .txt files"
71+ assert all (path .endswith (".txt" ) for path in file_paths ), "Should only include .txt files"
72+
73+ expected_files = ["file1.txt" , "subfile1.txt" , "file_subdir.txt" , "file_dir1.txt" , "file_dir2.txt" ]
74+ for expected_file in expected_files :
75+ assert any (expected_file in path for path in file_paths ), f"Missing expected file: { expected_file } "
76+
77+ assert not any (path .endswith (".py" ) for path in file_paths ), "Should not include .py files"
78+
79+
6180# TODO: test with wrong include patterns: ['*.qwerty']
6281
6382
0 commit comments