Example #1
0
def db(tmpdir):
    file = os.path.join(tmpdir.strpath, "test.db")
    conn = sqlite3.connect(file)
    conn.execute('''
                    CREATE TABLE movies(title, year, runtime, genre, director, cast, writer,
                                       language, country, awards, IMDb_rating, IMDb_votes,box_office)
                 ''')
    commands_manager = CommandsManager(conn)
    commands_manager.add_to_database("Memento")
    commands_manager.add_to_database("The Shawshank Redemption")
    commands_manager.add_to_database("Interstellar")
    commands_manager.add_to_database("Coco")
    commands_manager.add_to_database("Inception")
    yield conn
    conn.close()
Example #2
0
def main():
    conn = create_connection()
    if conn is None:
        exit(0)

    if not os.path.isfile('./databaseIsFilled.txt'):
        fill_database(conn)

    commands_manager = CommandsManager(conn)
    for arg in sys.argv:
        if "--sort_by" in arg:
            commands_manager.print_sorted_data()
        elif "--filter_by" in arg:
            commands_manager.print_filtered_data()
        elif "--compare" in arg:
            commands_manager.print_comparision()
        elif "--add" in arg:
            commands_manager.add_to_database()
        elif "--highscores" in arg:
            commands_manager.print_high_scores()
Example #3
0
def test_if_comparing_print_proper_values(db, capsys):
    commands_manager = CommandsManager(db)
    commands_manager.print_comparision("runtime", "Memento", "Interstellar")
    captured = capsys.readouterr()
    assert captured.out == """Interstellar 169 min\n"""
Example #4
0
def test_if_filtering_by_director_print_values_properly(db, capsys):
    commands_manager = CommandsManager(db)
    commands_manager.print_filtered_data("director", "Christopher Nolan")
    captured = capsys.readouterr()
    assert captured.out == """Memento - Christopher Nolan
Example #5
0
def test_if_sorting_prints_proper_values(db, capsys):
    commands_manager = CommandsManager(db)
    commands_manager.add_to_database("it")
    commands_manager.print_sorted_data(["year", "runtime"])
    captured = capsys.readouterr()
    assert captured.out == """It - 2017 - 135 min 
Example #6
0
def test_if_highscores_have_proper_values(db, capsys):
    commands_manager = CommandsManager(db)
    commands_manager.print_high_scores()
    captured = capsys.readouterr()
    assert captured.out == """Runtime: Interstellar - 169 min
Example #7
0
def test_if_all_adds_were_executed_properly(db, capsys):
    commands_manager = CommandsManager(db)
    commands_manager.print_all_data()
    captured = capsys.readouterr()
    assert captured.out == """('Memento', 2000, '113 min', 'Mystery, Thriller', 'Christopher Nolan', 'Guy Pearce, Carrie-Anne Moss, Joe Pantoliano, Mark Boone Junior', 'Christopher Nolan (screenplay), Jonathan Nolan (short story "Memento Mori")', 'English', 'USA', 'Nominated for 2 Oscars. Another 56 wins & 55 nominations.', 8.4, 1045443, 23844220)