def test_get_files_d(): fti = FileTagIndex(root_dir="./tests/test_data", file_types=["txt", "md"]) fti.get_files(file_types=["md"]) assert set(str(path) for path in fti.file_list) == { "tests/test_data/file2.md", "tests/test_data/more/file4.md", }
def test_get_files_a(): fti = FileTagIndex(root_dir="./tests/test_data") fti.get_files() assert set(str(path) for path in fti.file_list) == { "tests/test_data/file1.txt", "tests/test_data/file2.md", "tests/test_data/more/file3.txt", "tests/test_data/more/file4.md", }
def simple_fti(): ti = FileTagIndex(root_dir="~/") ti.doc_to_tags["doc_1"] = {"tag_a", "tag_b"} ti.doc_to_tags["doc_2"] = {"tag_a", "tag_b", "tag_c"} ti.doc_to_tags["doc_3"] = {"tag_d"} ti.tag_to_docs["tag_a"] = {"doc_1", "doc_2"} ti.tag_to_docs["tag_b"] = {"doc_1", "doc_2"} ti.tag_to_docs["tag_c"] = {"doc_2"} ti.tag_to_docs["tag_d"] = {"doc_3"} return ti
def test_init(): with pytest.raises(NotADirectoryError): fti = FileTagIndex(root_dir="~/asdfghjkl")