def info(): """Outputs details about the tag database.""" output_info( tag_database=click.get_current_context().obj.get("db_filename"), file_count=count_files() or 0, tag_count=count_tags() or 0, filetag_count=count_filetags() or 0, )
def test_count_should_match_files_with_no_tags(sample_file): assert tag.count_files() == 1
def test_count_should_exclude_files_with_exclude_mime_types(sample_filetag): assert tag.count_files(exclude_mime_types=["text/plain"]) == 0
def test_count_should_include_files_matching_any_mime_types(sample_filetag): assert tag.count_files(mime_types=["text/plain", "foo/bar"]) == 1
def test_count_should_exclude_files_based_on_exclude_tags(sample_filetag): assert tag.count_files(exclude_tags=["testtag"]) == 0
def test_count_should_not_include_files_without_matching_tags(sample_filetag): assert tag.count_files(tags=["badtag"]) == 0
def test_delete_file_should_delete_file_from_db(tmpfile, sample_filetag): assert tag.count_files() == 1 tag.delete_file(tmpfile) assert tag.count_files() == 0
def test_add_file_should_not_update_existing_file_if_filename_different( tmpdb, tmpfiles): [tag.add_file(x) for x in tmpfiles] assert tag.count_files() == len(tmpfiles)
def test_delete_filetag_shouldnt_delete_files_from_db(tmpfile, sample_filetag): tag.delete_filetag(tmpfile, "testtag") assert tag.count_files() == 1
def test_add_filetags_should_create_new_file(tmpdb, tmpfile): tag.add_filetags(tmpfile, {"testtag": None}) assert tag.count_files() == 1
def test_add_filetags_should_allow_updating_multiple_tags(tmpdb, tmpfile): tag.add_filetags(tmpfile, {"testtag": "testval", "testtag2": "testval2"}) tag.add_filetags(tmpfile, {"testtag": None, "testtag3": "testval3"}) assert tag.count_files() == 1 assert tag.count_tags() == 3 assert tag.count_filetags() == 3
def test_add_filetags_shouldnt_recreate_existing_file_when_tags_change( tmpdb, tmpfile): tag.add_filetags(tmpfile, {"testtag": None}) tag.add_filetags(tmpfile, {"testtag2": "testval"}) assert tag.count_files() == 1
def test_add_filetags_shouldnt_recreate_existing_file(tmpdb, tmpfile): tag.add_filetags(tmpfile, {"testtag": None}) tag.add_filetags(tmpfile, {"testtag": None}) assert tag.count_files() == 1
def test_count_with_no_criteria_should_count_everything(sample_filetag): assert tag.count_files() == 1
def test_count_should_include_files_matching_tags(sample_filetag): assert tag.count_files(tags=["testtag"]) == 1
def test_add_file_should_update_existing_file(tmpdb, tmpfile): tag.add_file(tmpfile) tag.add_file(tmpfile) assert tag.count_files() == 1
def test_count_should_not_include_files_with_partial_tag_matches( sample_filetag): assert tag.count_files(tags=["testtag", "othertag"]) == 0
def test_add_file_should_create_new_file(tmpdb, tmpfile): tag.add_file(tmpfile) assert tag.count_files() == 1
def test_delete_file_should_do_nothing_if_file_doesnt_exist_in_db( tmpfile, sample_filetag): tag.delete_file("foo.txt") assert tag.count_files() == 1