Beispiel #1
0
def test_help(capsys):
    """Capture and verify expected help info"""
    # --help does SystemExit so we need to catch it
    try:
        photos.main(arg_list('-h'))
    except SystemExit:
        pass
    verify(capsys, 'help')
Beispiel #2
0
def test_interactive(capsys, monkeypatch):
    """Verify series of interactive album ids"""

    monkeypatch.setattr(photos, 'get_photos', get_photos_mock)

    patch_input(monkeypatch, response=['2', '4', '0'])
    photos.main([])
    verify(capsys, 'interactive_test')
Beispiel #3
0
def test_bad_albumid_interactive(capsys, monkeypatch):
    """Verify handling of invalid Album id in interactive mode"""
    patch_input(monkeypatch, response=['1', 'bad', '0'])
    photos.main([])
    verify(capsys, 'bad_album_id_interactive')
Beispiel #4
0
def test_bad_albumid(capsys):
    """Verify handling of invalid Album id"""
    photos.main(arg_list('x'))
    verify(capsys, 'bad_album_id')
Beispiel #5
0
def test_101(capsys):
    """Verify non-existing Album number with debug enabled"""
    photos.main(arg_list('101 -d'))
    verify(capsys, 'album_101')
Beispiel #6
0
def test_35_100_max20(capsys, monkeypatch):
    """Verify multiple Album ids with max row number for each"""
    monkeypatch.setattr(photos, 'get_photos', get_photos_mock)
    photos.main(arg_list('35 100 -n 20'))
    verify(capsys, 'album_35+100_max20')
Beispiel #7
0
def test_3_bad_grep(capsys, monkeypatch):
    """Verify handling of invalid grep pattern"""
    monkeypatch.setattr(photos, 'get_photos', get_photos_mock)
    photos.main(arg_list('3 --grep "][" --rows --pretty'))
    verify(capsys, 'album_3_bad_grep')
Beispiel #8
0
def test_3_grep_nomatch(capsys, monkeypatch):
    """Verify row filtering with no matches"""
    monkeypatch.setattr(photos, 'get_photos', get_photos_mock)
    photos.main(arg_list('3 --grep NOMATCH --rows --pretty'))
    verify(capsys, 'album_3_grep_nomatch')
Beispiel #9
0
def test_3_max5(capsys, monkeypatch):
    """Verify first 5 rows of Album 3 with relative row numbers output"""
    monkeypatch.setattr(photos, 'get_photos', get_photos_mock)
    photos.main(arg_list('3 -n 5 --rows'))
    verify(capsys, 'album_3_max5_rows')
Beispiel #10
0
def test_2_max5(capsys, monkeypatch):
    """Verify first 5 rows of Album 2 in prettyTable format"""
    monkeypatch.setattr(photos, 'get_photos', get_photos_mock)

    photos.main(arg_list('2 -n 5 --pretty'))
    verify(capsys, 'album_2_max5_pretty')
Beispiel #11
0
def test_1(capsys, monkeypatch):
    """Verify Album 1"""
    monkeypatch.setattr(photos, 'get_photos', get_photos_mock)

    photos.main(arg_list('1'))
    verify(capsys, 'album_1')
Beispiel #12
0
def test_0(capsys):
    """Verify expected response from album id of zero"""
    photos.main(arg_list('0'))
    verify(capsys, 'album_0')
Beispiel #13
0
def test_exit_with_two_empty_returns(capsys, monkeypatch):
    """Verify exit via two empty returns"""
    patch_input(monkeypatch, response=['', ''])
    photos.main([])
    verify(capsys, 'exit_with_two_empty_returns')
Beispiel #14
0
def test_no_args(capsys, monkeypatch):
    """Verify no argument behavior"""
    patch_input(monkeypatch, response='q')
    photos.main([])
    verify(capsys, 'no_args')
Beispiel #15
0
def test_timeout(capsys):
    """Verify handling of timeout accessing URL"""
    photos.main(arg_list('99 -t .01'))
    verify(capsys, 'timeout_test')
Beispiel #16
0
def test_3_grep_qui(capsys, monkeypatch):
    """Verify row filtering with expected matches"""
    monkeypatch.setattr(photos, 'get_photos', get_photos_mock)
    photos.main(arg_list('3 --grep iste --rows --pretty'))
    verify(capsys, 'album_3_grep_qui')
Beispiel #17
0
def test_bad_url(capsys, monkeypatch):
    """Verify handling of bad or unrecognized URL"""
    patch_url(monkeypatch, 'x')
    photos.main(['1'])
    verify(capsys, 'bad_url')
Beispiel #18
0
import sys
import os
import b_w
import photos


if len(sys.argv) > 2:
    print('You have specified too many arguments')
    sys.exit()
    
elif len(sys.argv) < 2:
    print('Enter path to an image.\nExample: python main.py imgs_0/img_0.jpg')
    sys.exit()
    
elif not os.path.isfile(sys.argv[1]):
    print('Enter valid path to an image')
    sys.exit()
    
elif sys.argv[1].endswith('jpg'):
    b_w.main(sys.argv[1])
    
else:
    photos.main(sys.argv[1])