def test_count_movie_14(): assert len( index.search_film( index_dir, "Pirates of the Caribbean: Dead Men Tell No Tales")) == 6
def test_count_movie_15(): assert len(index.search_film(index_dir, "Zoolander")) == 137
def test_count_movie_1(): assert len(index.search_film(index_dir, "New York Stories")) == 87
def test_count_movie_13(): assert len( index.search_film(index_dir, "Pirates of the Caribbean: On Stranger Tides")) == 73
def test_count_movie_20(): assert len(index.search_film(index_dir, "Vykoupení z věznice Shawshank")) == 62
def test_film_correction_and_exit(): original_input = mock.builtins.input mock.builtins.input = lambda _: "e" output = index.search_film(index_dir, "new york storieZ") assert output == -2 mock.builtins.input = original_input
def test_count_movie_8(): assert len(index.search_film(index_dir, "Pearl Harbor")) == 167
def test_count_movie_18(): assert len( index.search_film(index_dir, "Harry Potter and the Prisoner of Azkaban")) == 60
def test_count_movie_6(): assert len(index.search_film(index_dir, "Step Up Revolution")) == 160
def test_count_movie_7(): assert len(index.search_film(index_dir, "Eagle Eye")) == 202
def test_count_movie_5(): assert len(index.search_film(index_dir, "The Dark Knight")) == 197
def test_count_movie_4(): original_input = mock.builtins.input mock.builtins.input = lambda _: "2" assert len(index.search_film(index_dir, "Lawless")) == 9 mock.builtins.input = original_input
def test_count_movie_2(): assert len(index.search_film(index_dir, "The Dark Knight Rises")) == 284
def test_count_movie_16(): assert len(index.search_film(index_dir, "Into the Wild")) == 55
def test_count_movie_9(): original_input = mock.builtins.input mock.builtins.input = lambda _: "2" assert len(index.search_film(index_dir, "Road Trip")) == 15 mock.builtins.input = original_input
def test_count_movie_17(): assert len(index.search_film(index_dir, "Abraham Lincoln, Vampire Hunter")) == 114
def test_count_movie_10(): assert len( index.search_film(index_dir, "Pirates of the Caribbean: at World's End")) == 130
def test_count_movie_19(): assert len(index.search_film(index_dir, "Bojová loď")) == 186
def test_count_movie_11(): assert len( index.search_film(index_dir, "Pirates of the Caribbean: Dead Man's Chest")) == 119
def test_new_york_stories(): test = sorted( ['Bill Moor', 'Carole Bouquet', 'Victor Argo']) assert sorted(index.search_film(index_dir, "New York Stories")) == test
def test_count_movie_12(): assert len( index.search_film( index_dir, "Pirates of the Caribbean: The Curse of the Black Pearl")) == 76
def test_input_not_find(): output = index.search_film(index_dir, "Name not found, I think, This is bad name of film") assert output == -1
def search(index_dir): not_end = "y" while not_end == "y": print("\nrun SEARCH...") print("\trun search...") cmd = input("\nYou want to search by actors or movie? [a|m]: ") if cmd == "m": name = input("\nEnter name of movie: ") actors = index.search_film(index_dir, name) if not actors or actors == -1: print("I didn't find the movie") not_end = input("\nDo you want to continue? [y|n]: ") continue if actors != -2: print("\nIn film " + name + " played:") for a in actors: print("\t" + a) else: break elif cmd == "a": actors = [] i = 0 pref_names = [] pref_name = "" while i < 2: if i == 0: prefix = 'first' else: prefix = 'second' name = input("\nEnter " + prefix + " name: ") if actors and name.upper() in pref_names: print("\nWARN: actor " + pref_name + " and actor " + name + " can be the same person!") actors.append(index.search_actor(index_dir, name)) if actors[i] == -1 or actors[i] == -2: break pref_names = actors[i]['names'].upper().split('\t') pref_name = name i += 1 if i != 2: if actors[i] == -2: not_end = input("\nDo you want to continue? [y|n]: ") continue name_1 = "" name_2 = "" actor_1 = [] actor_2 = [] films = [] for a in actors: a['data'][1] = datetime.now().strftime( "%Y-%m-%d") if a['data'][1] == "NOW" else a['data'][1] if i == 2: actor_1 = a name_1 = a['query'] else: actor_2 = a name_2 = a['query'] i -= 1 if datetime.strptime(actor_1['data'][0], '%Y-%m-%d') <= datetime.strptime(actor_2['data'][1], '%Y-%m-%d') \ and datetime.strptime(actor_2['data'][0], '%Y-%m-%d') <= datetime.strptime(actor_1['data'][1], '%Y-%m-%d'): for film_1 in actor_1['films'].split('@'): for film_2 in actor_2['films'].split('@'): if film_1.split('\t')[0] == film_2.split('\t')[0]: films.append(film_1[1:]) break if films: print("\nActors: \n\t" + name_1 + " -> " + ", ".join(actor_1['names'].split('\t')) + "\n\t" + name_2 + " -> " + ", ".join(actor_2['names'].split('\t')) + "\nplayed together in films:") for f in films: string_1 = "" string_2 = "" if len(f) > 1: string_1 = f.split('\t')[1] if len(f) > 2: string_2 = ", ".join(f.split('\t')[2:]) print("\t" + string_1 + " -> " + string_2) else: actor_1_films = [] actor_2_films = [] for f in actor_1['films'].split('@'): if len(f.split('\t')) > 2: actor_1_films.append(f.split('\t')[1]) for f in actor_2['films'].split('@'): if len(f.split('\t')) > 2: actor_2_films.append(f.split('\t')[1]) print("\nActors played in:\n\t" + name_1 + " -> " + ', '.join(actor_1_films) + "\n\t" + name_2 + " -> " + ', '.join(actor_2_films) + "\nActors did not play together") else: date_1 = "born: " + actor_1['data'][0] + " died: " + actor_1[ 'data'][1] date_2 = "born: " + actor_2['data'][0] + " died: " + actor_2[ 'data'][1] print( "\nActors:\n\t" + name_1 + " -> " + date_1 + "\n\t" + name_2 + " -> " + date_2 + "\nActors could not play together because they did not live at the same time" ) else: print("ERROR: Unknown input") not_end = input("\nDo you want to continue? [y|n]: ") return not_end