Beispiel #1
0
def ls(tag, exclude_tag, mime, exclude_mime):
    """Outputs all the files tagged with given tag(s). If no tags are specified, outputs all the files in the database. If multiple tags are specified, outputs files matching ANY of the tags."""
    output_file_list(
        search_files(
            tags=tag if len(tag) > 0 else None,
            exclude_tags=exclude_tag if len(exclude_tag) > 0 else None,
            mime_types=mime if len(mime) > 0 else None,
            exclude_mime_types=exclude_mime if len(exclude_mime) > 0 else None,
        ))
Beispiel #2
0
def test_search_with_no_criteria_should_return_all_filetags(sample_filetag):
    files = list(tag.search_files())
    assert len(files) == 1
Beispiel #3
0
def test_search_should_match_files_with_no_tags(sample_file):
    files = list(tag.search_files())
    assert len(files) == 1
Beispiel #4
0
def test_search_should_exclude_filetags_with_exclude_mime_types(
        sample_filetag):
    files = list(tag.search_files(exclude_mime_types=["text/plain"]))
    assert len(files) == 0
Beispiel #5
0
def test_search_should_return_filetags_matching_any_mime_types(sample_filetag):
    files = list(tag.search_files(mime_types=["text/plain", "foo/bar"]))
    assert len(files) == 1
Beispiel #6
0
def test_search_should_exclude_tags_based_on_exclude_tags(sample_filetag):
    files = list(tag.search_files(exclude_tags=["testtag"]))
    assert len(files) == 0
Beispiel #7
0
def test_search_should_not_return_files_without_matching_tags(sample_filetag):
    files = list(tag.search_files(tags=["badtag"]))
    assert len(files) == 0
Beispiel #8
0
def test_search_should_not_return_files_with_partial_tag_matches(
        sample_filetag):
    files = list(tag.search_files(tags=["testtag", "othertag"]))
    assert len(files) == 0
Beispiel #9
0
def test_search_should_return_files_matching_tags(sample_filetag):
    files = list(tag.search_files(tags=["testtag"]))
    assert len(files) == 1