def create_cinema_db(): cinema = Cinema(10, 10) movies = [ {"name": 'The Hunger Games: Catching Fire', "rating": 7.9}, {'name': 'Wreck-It Ralph', 'rating': 7.8}, {'name': 'Her', 'rating': 8.3} ] projections = [ {'movie_id': 1, 'type': '3D', 'date': '2014-04-01', 'time': '19:10'}, {'movie_id': 1, 'type': '2D', 'date': '2014-04-01', 'time': '19:00'}, {'movie_id': 1, 'type': '4DX', 'date': '2014-04-02', 'time': '21:00'}, {'movie_id': 3, 'type': '2D', 'date': '2014-04-05', 'time': '20:20'}, {'movie_id': 2, 'type': '3D', 'date': '2014-04-02', 'time': '22:00'}, {'movie_id': 2, 'type': '2D', 'date': '2014-04-02', 'time': '19:30'} ] reservations = [ {'username': '******', 'projection_id': 1, 'row': 2, 'col': 1}, {'username': '******', 'projection_id': 1, 'row': 3, 'col': 5}, {'username': '******', 'projection_id': 1, 'row': 7, 'col': 8}, {'username': '******', 'projection_id': 3, 'row': 1, 'col': 1}, {'username': '******', 'projection_id': 3, 'row': 1, 'col': 2}, {'username': '******', 'projection_id': 5, 'row': 2, 'col': 3}, {'username': '******', 'projection_id': 5, 'row': 2, 'col': 4}, ] for movie in movies: cinema.add_movie(**movie) for projection in projections: cinema.add_projection(**projection) for reservation in reservations: cinema.add_reservation(**reservation)
def main(): Base.metadata.create_all(engine) arena = Cinema() while True: command = input(">>>") if command == 'add_movie': arena.add_movie() elif command == 'add_projection': arena.add_projection() elif command == 'add_reservation': arena.add_reservation() elif command == 'show_movies': arena.show_movies() elif command == 'show_movie_projections': arena.show_movie_projections(1, '2014-03-22')
def main(): engine = create_engine("sqlite:///cinema.db") base.Base.metadata.create_all(engine) session = Session(bind=engine) cinema = Cinema(session) print_menu() command = input("Enter your choice: ") put = command.split(" ") while put[0] != "end": if put[0] == "add_movie" or put[0] == '1': cinema.add_movie() if put[0] == "show_movies" or put[0] == '2': cinema.show_movies() if put[0] == "add_projection" or put[0] == '3': cinema.add_projections() if put[0] == "show_movie_projections": cinema.show_movie_projections(put[1]) if put[0] == "make_reservation" or put[0] == '5': #ENTER INFORMATION FOR USER try: #USER INFORMATION user_info = step_one(cinema) #CHOOSING MOVIE movie_choice = step_two(cinema) # CHOOSING PROJECTIONS projection_choice = step_three(cinema) # CHOOSING SEATS step_four(cinema, user_info, projection_choice, movie_choice) # FINALIZE step_five(cinema, user_info, projection_choice) except GiveUpError: print("You just give up the reservation!") print_menu() if put[0] == "cancel_reservation": cinema.cancel_reservation(put[1]) if put[0] == "exit": break if put[0] == "help": cinema.print_menu() command = input("Enter your choice: ") put = command.split(" ")
def main(): engine = create_engine("sqlite:///cinema.db") base.Base.metadata.create_all(engine) session = Session(bind=engine) cinema = Cinema(session) print_menu() command = input("Enter your choice: ") put = command.split(" ") while put[0] != "end": if put[0] == "add_movie" or put[0] == '1': cinema.add_movie() if put[0] == "show_movies" or put[0] == '2': cinema.show_movies() if put[0] == "add_projection" or put[0] == '3': cinema.add_projections() if put[0] == "show_movie_projections": cinema.show_movie_projections(put[1]) if put[0] == "make_reservation" or put[0] == '5': #ENTER INFORMATION FOR USER try: #USER INFORMATION user_info = step_one(cinema) #CHOOSING MOVIE movie_choice = step_two(cinema) # CHOOSING PROJECTIONS projection_choice = step_three(cinema) # CHOOSING SEATS step_four(cinema, user_info, projection_choice, movie_choice) # FINALIZE step_five(cinema, user_info, projection_choice) except GiveUpError: print("You just give up the reservation!") print_menu() if put[0] == "cancel_reservation": cinema.cancel_reservation(put[1]) if put[0] == "exit": break if put[0] == "help": cinema.print_menu() command = input("Enter your choice: ") put = command.split(" ")
class MyTests(unittest.TestCase): def setUp(self): self.cinema = Cinema("test1.db") def tearDown(self): self.cinema.exit() os.remove("test1.db") def test_add_movie(self): self.cinema.add_movie('The Hunger Games: Catching Fire', 7.9) self.cinema.cursor.execute('SELECT * FROM Movies') movie = self.cinema.cursor.fetchall()[0] self.assertTrue(movie[0] == 1) self.assertEqual(movie[1], "The Hunger Games: Catching Fire") self.assertEqual(movie[2], 7.9) def test_add_proj(self): proj = (1, 1, '3D', '2014-04-01', '19:10') self.cinema.add_projection(1, '3D', '2014-04-01', '19:10') self.cinema.cursor.execute('SELECT * FROM Projections') projection_from_db = self.cinema.cursor.fetchall()[0] self.assertEqual(proj, projection_from_db) def test_add_reservation(self): reservation = (1, 'RadoRado', 1, 2, 1) self.cinema.add_reservation('RadoRado', 1, 2, 1) self.cinema.cursor.execute('SELECT * FROM Reservations') reservation_from_db = self.cinema.cursor.fetchall()[0] self.assertEqual(reservation, reservation_from_db) def test_cancel_reservation(self): self.cinema.add_reservation('RadoRado', 1, 2, 1) self.cinema.add_reservation('RadoRado', 1, 3, 5) self.cinema.add_reservation('RadoRado', 1, 7, 8) self.cinema.add_reservation('Ivo', 3, 1, 1) self.cinema.add_reservation('Ivo', 3, 1, 2) self.cinema.add_reservation('Mysterious', 5, 2, 3) self.cinema.add_reservation('Mysterious', 5, 2, 4) self.cinema.cancel_reservation("a") self.cinema.cancel_reservation("RadoRado") testing_value = self.cinema.free_place_for_projection(1) self.assertEqual(testing_value, 100)
def main(): engine = create_engine("sqlite:///EmilCinema.db") Base.metadata.create_all(engine) session = Session(bind=engine) EmilCinema = Cinema(session) print_main_menu() print("asda") command = input("Enter your choice: ") parsed_command = command.split() while parsed_command[0] != "end": if parsed_command[0] == "add_movie" or parsed_command[0] == '1': EmilCinema.add_movie() if parsed_command[0] == "show_movies" or parsed_command[0] == '2': EmilCinema.show_movies() if parsed_command[0] == "add_projection" or parsed_command[0] == '3': EmilCinema.add_projection() if parsed_command[0] == "show_movie_projections" or parsed_command[0] == '4': EmilCinema.show_projections_available_spots(parsed_command[1]) if parsed_command[0] == "make_reservation" or parsed_command[0] == '5': try: user_info = personal_info(EmilCinema) movie_id = choosing_movie(EmilCinema) projection_id = choosing_projection(EmilCinema) choosing_seats(EmilCinema, user_info, projection_id, movie_id) finalize_reservation(EmilCinema, user_info, projection_id) except GiveUpError: print("You just give up the reservation!") print_main_menu() if parsed_command[0] == "cancel_reservation": EmilCinema.cancel_reservation(parsed_command[1]) if parsed_command[0] == "exit": break if parsed_command[0] == "help": EmilCinema.print_main_menu() command = input("Enter your choice: ") parsed_command = command.split()
class MyTests(unittest.TestCase): def setUp(self): self.cinema = Cinema("test1.db") def test_a(self): self.cinema = Cinema("test1.db") self.cinema.add_movie('The Hunger Games: Catching Fire', 7.9) self.cinema.add_movie('Wreck-It Ralph', 7.8) self.cinema.add_movie('Her', 8.3) self.cinema.add_projection(1, '3D', '2014-04-01', '19:10') self.cinema.add_projection(1, '2D', '2014-04-01', '19:00') self.cinema.add_projection(1, '4DX', '2014-04-02', '21:00') self.cinema.add_projection(3, '2D', '2014-04-05', '20:20') self.cinema.add_projection(2, '3D', '2014-04-02', '22:00') self.cinema.add_projection(2, '2D', '2014-04-02', '19:30') self.cinema.add_reservation('RadoRado', 1, 2, 1) self.cinema.add_reservation('RadoRado', 1, 3, 5) self.cinema.add_reservation('RadoRado', 1, 7, 8) self.cinema.add_reservation('Ivo', 3, 1, 1) self.cinema.add_reservation('Ivo', 3, 1, 2) self.cinema.add_reservation('Mysterious', 5, 2, 3) self.cinema.add_reservation('Mysterious', 5, 2, 4) def test_fetch_movie(self): movie = self.cinema.fetch_movie(3) self.assertEqual(movie[0], "Her") self.assertEqual(movie[1], 8.3) def test_fetch_fetch_movies(self): movies = self.cinema.fetch_movies() self.assertTrue((1, 'The Hunger Games: Catching Fire', 7.9) in movies) self.assertTrue((2, 'Wreck-It Ralph', 7.8) in movies) self.assertTrue((3, 'Her', 8.3) in movies) def test_fetch_projections_by_id(self): proj = self.cinema.fetch_projections_by_id(2) self.assertTrue((6, '2014-04-02', '19:30', '2D') in proj) self.assertTrue((5, '2014-04-02', '22:00', '3D') in proj) def test_fetch_projections_by_id_and_date(self): proj = self.cinema.fetch_projections_by_id_and_date(1, '2014-04-01') self.assertTrue((2, '19:00', '2D') in proj) self.assertTrue((1, '19:10', '3D') in proj) def test_fetch_taken_seats(self): taken = self.cinema.fetch_taken_seats(4) self.assertEqual(taken, []) taken = self.cinema.fetch_taken_seats(5) self.assertTrue((2, 3) in taken) self.assertTrue((2, 4) in taken) def test_free_place_for_projection(self): testing_value = self.cinema.free_place_for_projection(1) self.assertEqual(testing_value, 97) testing_value = self.cinema.free_place_for_projection(2) self.assertEqual(testing_value, 100) def test_fetch_projection(self): proj = self.cinema.fetch_projection(2) self.assertEqual(proj[0], ('2014-04-01', '19:00', '2D')) def test_z(self): os.remove("test1.db")