예제 #1
0
def test_args_wrong_directory(monkeypatch):
    name = 'test213213fake_dir'
    expecting = f'There is no "{name}" directory.'
    args = ['filesize_scanner.py', name]
    monkeypatch.setattr(sys, 'argv', args)
    with pytest.raises(SystemExit) as e:
        _get_args()
    assert expecting in e.exconly()
예제 #2
0
def test_args_wrong_library(monkeypatch, fake_dir):
    args = ['filesize_scanner.py', fake_dir, 'l=videos']
    expecting = 'Available libraries: ' +\
        ', '.join(list(LIBRARY.keys()))
    monkeypatch.setattr(sys, 'argv', args)
    with pytest.raises(SystemExit) as e:
        _get_args()
    assert expecting in e.exconly()
예제 #3
0
def test_args_library_with_extensions(monkeypatch, fake_dir):
    args = ['filesize_scanner.py', fake_dir, 'l=video', 'e=mp3']
    ext = set(LIBRARY['video'])
    ext.add('mp3')
    expecting = (fake_dir, ext, Params.get())
    monkeypatch.setattr(sys, 'argv', args)
    assert _get_args() == expecting
예제 #4
0
def test_args_several_libraries(monkeypatch, fake_dir):
    args = ['filesize_scanner.py', fake_dir, 'l=video,audio']
    ext = set(LIBRARY['video'])
    ext = ext.union(set(LIBRARY['audio']))
    expecting = (fake_dir, ext, Params.get())
    monkeypatch.setattr(sys, 'argv', args)
    assert _get_args() == expecting
예제 #5
0
def test_args_exclude_libraries(monkeypatch, fake_dir):
    args = ['filesize_scanner.py', fake_dir, 'l=-audio,video']
    ext = set(LIBRARY['audio'])
    ext = ext.union(LIBRARY['video'])
    expecting = (fake_dir, ext, Params(exclude=True).get())
    monkeypatch.setattr(sys, 'argv', args)
    assert _get_args() == expecting
예제 #6
0
def test_args_exclude_extensions(monkeypatch, fake_dir):
    args = ['filesize_scanner.py', fake_dir, 'e=-mp3,mp4']
    expecting = (fake_dir, {'mp3', 'mp4'}, Params(exclude=True).get())
    monkeypatch.setattr(sys, 'argv', args)
    assert _get_args() == expecting
예제 #7
0
def test_args_no_extension(monkeypatch, fake_dir):
    expecting = (fake_dir, {''}, Params.get())
    args = ['filesize_scanner.py', fake_dir, 'e=']
    monkeypatch.setattr(sys, 'argv', args)
    assert _get_args() == expecting
예제 #8
0
def test_args_subfolders(monkeypatch, fake_dir):
    expecting = (fake_dir, {''}, Params(search_subfolders=True).get())
    args = ['filesize_scanner.py', fake_dir, '-r']
    monkeypatch.setattr(sys, 'argv', args)
    assert _get_args() == expecting
예제 #9
0
def test_args_int_limit_number(monkeypatch):
    expecting = (os.getcwd(), {''}, Params(limit=1).get())
    args = ['filesize_scanner.py', '1']
    monkeypatch.setattr(sys, 'argv', args)
    assert _get_args() == expecting
예제 #10
0
def test_args_exclude_include(monkeypatch, fake_dir):
    args = ['filesize_scanner.py', fake_dir, 'l=-audio,video', 'e=mp3']
    expecting = (fake_dir, {'mp3'}, Params(exclude=True).get())
    monkeypatch.setattr(sys, 'argv', args)
    assert _get_args() == expecting