def main():
    engine = create_engine("sqlite:///cinema.db")
    Base.metadata.create_all(engine)
    session = Session(bind=engine)
    cinema_city = Cinema(session)
    new_movies_and_projections_in_cinema(cinema_city)
    command_parser = CommandParser()
    command_parser.add_command("show_movies", cinema_city.show_movies)
    cinema_city.show_movies(session)
    command = input(">>>")
    command_parser.run_command(command)
def main():
    cinema = Cinema()
    command_parser = CommandParser(cinema)

    while True:
        command = input("> ")
        command_parser.handle_command(command)
    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)
示例#4
0
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)
示例#5
0
def main():
    options = [new_room, new_film, sell_ticket, reset_room, show_room]
    cinema = Cinema()
    while True:
        print("************")
        menu()
        n = utils.read_int("Selecciona una opción: ")
        if n is not None:
            if n == 0:
                break
            elif n > 0 and n < 6:
                options[n - 1](cinema)
            else:
                print("Opción incorrecta")

    print("Hasta pronto!")
示例#6
0
    def add_cinema(self):
        name = input('name: ')
        if not name:
            print('Invalid input!')
            return
        if self.cinemas.exists(name):
            print('cinema already exists!')
            return
        city = input('City: ')
        seats = input('Seats: ')

        cinema = Cinema(name, city, seats)

        if cinema:
            self.cinemas.insert(cinema)
            print('Added:', cinema)
示例#7
0
 def get_film(self):
     cinema = Cinema()
     driver = webdriver.Chrome()
     driver.get("https://generator-online.com/movies/")
     time.sleep(1)
     btn_element = driver.find_element_by_css_selector(
         "button[class^='btn-floating'] span").click()
     time.sleep(1)
     cinema.title = driver.find_element_by_id('title').text
     cinema.genre = driver.find_element_by_id('genres').text
     cinema.year = driver.find_element_by_id('release_date').text
     cinema.overview = driver.find_element_by_id('overview').text
     driver.close()
     return cinema
示例#8
0
from cinema import Cinema
from command_parser import CommandParser
from connections import *

cinema = Cinema(10, 10)


def create_command_parser():
    command_parser = CommandParser()
    command_parser.add_command('show_movies', show_movies)
    command_parser.add_command('show_movie_projections',
                               show_movie_projections)
    command_parser.add_command('make_reservation', make_reservation)
    command_parser.add_command('cancel_reservation', cancel_reservation)
    command_parser.add_command('exit', exit)
    command_parser.add_command('help', show_help)
    return command_parser


def show_movies():
    print('Current movies:')
    print(cinema.show_movies())


def show_movie_projections(movie_id, date=None):
    projections_info = cinema.show_movie_projections(movie_id, date)
    if date:
        print('Projections for movie {} on {}:'.format(
            projections_info['movie_name'], date))
    else:
        print('Projections for movie {}:'.format(
示例#9
0
	def setUp(self):
		self.cinema = Cinema("test1.db")
示例#10
0
import unittest
from sqlalchemy import create_engine
from sqlalchemy.orm import Session
from cinema import Cinema


engine = create_engine("sqlite:///cinema.db")
session = Session(bind=engine)

cinema = Cinema(session)


class Create_cinema_test(unittest.TestCase):

    def test_get_date_time(self):
        result = cinema._get_movie_date_time(1)
        self.assertEqual(result, ("2014-04-01", "19:10"))

    def test_get_movie_name(self):
        movie = cinema._get_movie_name(1)
        self.assertEqual(movie, "The Hunger Games: Catching Fire")
if __name__ == '__main__':
    unittest.main()
示例#11
0
文件: main.py 项目: mnurtay/python3
def buyTicket(user):
    db = DB()
    data = db.select('Cinemas', ['id', 'name'])
    # Choose cinema
    while True:
        print()
        for dt in data:
            print(dt[0], dt[1])
        request = input("\n<> Choose one of these cinemas:\n>> ")
        if request == 'back':
            return False, "Back"
        try:
            request = int(request)
        except:
            print('\n!!! Please, enter INTEGER number!')
            continue
        if request < 1 or request > len(data):
            print(
                "\n!!! Сhoose cinemas that do not exceed the number of cinemas"
            )
            continue
        cinema = Cinema(data[request - 1][0], data[request - 1][1])
        # Choose movie
        while True:
            print()
            for kino in cinema.listKino:
                print(kino["id"], kino["name"])
            request = input("\n<> Choose the movie you want to watch:\n>> ")
            if request == "back":
                break
            try:
                request = int(request)
            except:
                print('\n!!! Please, enter INTEGER number!')
                continue
            if request < 1 or request > len(cinema.listKino):
                print(
                    "\n!!! Choose films that do not exceed the amount of film")
                continue
            cinema.setChosenKino(request - 1)
            # Choose time
            while True:
                print("\n", "ID", "Time", "Price")
                time_id = 1
                for time in cinema.getTimes():
                    print(time_id, time['time'], time['price'])
                    time_id += 1
                request = input("\n<> Choose one of these times:\n>> ")
                if request == "back":
                    break
                try:
                    request = int(request)
                except:
                    print('\n!!! Please, enter INTEGER numbers!')
                    continue
                if request < 1 or request > time_id:
                    print(
                        "\n!!! Select a time that does not exceed the ID time")
                    continue
                cinema.setChosenTime(cinema.getTimes()[request - 1]['id'])
                # Choose place
                placeArr = []
                while True:
                    print()
                    for place in cinema.getPlaces():
                        if place['status'] == 0:
                            print(place['place'], end="  ")
                            placeArr.append(place['place'])
                    request = input(
                        "\n<> Select one or more places (with a space):\n>> ")
                    if request == "back":
                        break
                    try:
                        request = [int(i) for i in request.split()]
                    except:
                        print('\n!!! Please, enter INTEGER numbers!')
                        continue
                    ch = True
                    for req in request:
                        if not req in placeArr:
                            ch = False
                            break
                    if not ch:
                        print("<> Please select only free places!")
                        continue
                    else:
                        cinema.setChosenPlaces(request)
                        print("Perfect thank you!")
                        return True, cinema
示例#12
0
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()
示例#13
0
 def create_cinema_documents():
     for o in Cinema.query().iter():
         ModelSearch.add_document(ModelSearch.create_cinema_document(
             o.key.urlsafe(), o),
                                  index_name='cinemas')
示例#14
0
 def setUp(self):
     self.my_cinema = Cinema(session)
示例#15
0
class TestCinema(unittest.TestCase):
    def setUp(self):
        self.my_cinema = Cinema(session)

    def test_add_movie(self):
        #self.my_cinema.add_movie() add new movie
        movie = session.query(
            Movie.name, Movie.rating, Movie.id).filter(
            Movie.name == "Bad boys")
        self.assertEqual(movie[0][0], "Bad boys")
        self.assertEqual(movie[0][1], 7.1)
        self.assertEqual(movie[0][2], 3)

    def test_show_movies(self):
        #self.my_cinema.show_movies()
        movies = session.query(Movie.name).all()
        self.assertEqual(movies, [('The Hunger Games',), ('Die Hard',), ('Bad boys',)])

    #def test_what_movie(self): 
        #movie = self.my_cinema.what_movie()
        #self.assertEqual(movie, ['Wtf', '5.5'])

    def test_add_projections(self):
        #self.my_cinema.add_projections() #add one new projection
        projection = session.query(
            Projection.movie_type, Projection.date_time, Projection.movie_id).filter(
            Projection.movie_id == 3)
        self.assertEqual(projection[0][0], "3D")
        self.assertEqual(projection[0][1], datetime(2014, 11, 24, 21, 30))
        self.assertEqual(projection[0][2], 3)

    def test_select_title(self):
        self.assertEqual(self.my_cinema.select_title(2), "Projections for Die Hard")

    #def test_select_projections(self): # samo printva projekciite
    #    self.my_cinema.select_projections(2)

    #def test_show_projections(self): # samo printva projekciite
    #    self.my_cinema.show_movie_projections(2)

    def test_take_spots(self):
        self.assertEqual(self.my_cinema.take_spots(2), 97)

    def test_seats_for_out_if_index(self):
        self.assertFalse(self.my_cinema.check_seats_for_out_index('(2, 44)'))
        self.assertTrue(self.my_cinema.check_seats_for_out_index('(2, 3)'))

    def test_seats_if_are_available(self):
        self.my_cinema.take_spots(2)
        self.my_cinema.show_seats(2)
        self.assertTrue(self.my_cinema.check_seats_if_available("(1, 2)"))
        self.assertFalse(self.my_cinema.check_seats_if_available("(7, 7)"))

    def test_cancel_reservation(self): #works only once !
        #old_reservation = session.query(Reservation).all()
        #self.assertEqual(len(old_reservation), 6)
        self.my_cinema.cancel_reservation("Ivo")
        new_reservation = session.query(Reservation).all()
        self.assertEqual(len(new_reservation), 5)
示例#16
0
	def __init__(self, db_name):
		self.cinema = Cinema(db_name)
示例#17
0
class Spells():
	#db_name = "cinema.db"
	def __init__(self, db_name):
		self.cinema = Cinema(db_name)

	def show_movie(self, movie_id):
		movie = self.cinema.fetch_movie(movie_id)
		print("%s (%f)" % movie)
		return ("%s (%f)" % movie)

	def show_movies(self):
		output = []
		movies =self.cinema.fetch_movies()
		print("Current movies:")
		for movie in movies:
			print("[%d] - %s (%f)" % movie)
			output.append("[%d] - %s (%f)" % movie)
		return output

	def show_movie_projections(self, commands):
		if len(commands) == 2:
			return(self.show_pojections_by_id(commands[1]))
		elif len(commands) == 3:
			return(self.show_pojections_by_id_and_date(commands[1], commands[2]))

	def show_pojections_by_id(self, movie_id):
		output = []
		movie = self.cinema.fetch_movie_name(movie_id)
		print("Projections for movie '%s'" % movie[0])
		projections = self.cinema.fetch_projections_by_id(movie_id)
		for projection in projections:
			print("[%d] - %s %s (%s)" % projection)
			output.append("[%d] - %s %s (%s)" % projection)
		return output
		
	def show_pojections_by_id_and_date(self, movie_id, date):
		print("Projections for movie '%s' on %s:" % 
				(self.cinema.fetch_movie_name(movie_id)[0][0], date))
		output = []
		projections = self.cinema.fetch_projections_by_id_and_date(movie_id, date)
		for projection in projections:
			print("[%d] - %s (%s)" % projection)
			output.append("[%d] - %s (%s)" % projection)
		return output

	def show_places_map(self, taken_seats):
		map_seats = [
				[' ', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10'],
				['1', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'],
				['2', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'],
				['3', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'],
				['4', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'],
				['5', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'],
				['6', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'],
				['7', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'],
				['8', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'],
				['9', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'],
				['10', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.']
			]

		for seat in taken_seats:
			map_seats[seat[0]][seat[1]] = 'X'

		return map_seats

	def show_projection(self, projection_id):
		projection = self.cinema.fetch_projection(projection_id)
		projection = projection[0]
		print(len(projection))
		print("Date and Time: %s %s (%s)" % (projection[0], projection[1], projection[2]))

	def show_projection_reservertion(self, movie_id):
		output = ["Projections for movie '%s' :" % self.cinema.fetch_movie_name(movie_id)[0][0],]
		print("Projections for movie '%s' :" % self.cinema.fetch_movie_name(movie_id)[0][0])

		projections = self.cinema.fetch_projections_by_id(movie_id)

		for projection in projections:
			print("[%d] - %s %s (%s) - %d spots available" % 
						(projection[0], projection[1], projection[2], projection[3],
							self.cinema.free_place_for_projection(projection[0])))
			output.append("[%d] - %s %s (%s) - %d spots available" % 
						(projection[0], projection[1], projection[2], projection[3],
							self.cinema.free_place_for_projection(projection[0])))

		return output

	def show_reservation_info(self, movie_id, projection_id, seats):
		print("This is your reservation:")
		self.show_movie(movie_id)
		self.show_projection(projection_id)
		print(seats)
		fin = input("Step 5 (Confirm - type 'finalize')>")
		return fin

	def cancel_reservation(self, username):
		self.cinema.cancel_reservation(username)

	def get_user_info_prompt(self):
		name = input("Step 1 (User): Choose name>")
		if name == "give_up":
			return "give_up"
			
		while True:
			tickets_number = input("Step 1 (User): Choose number of tickets>")
			if tickets_number == "give_up":
				return "give_up"
			elif tickets_number.isdigit():
				break
			else:
				print("wrong input")

		return (name, tickets_number)		

	def choose_movie_prompt(self):
		while True:
			movie_id = input("Step 2 (Movie): Choose a movie>")
			if movie_id == "give_up":
				return "give_up"
			elif movie_id.isdigit(): 
				return movie_id

	def choose_projection_prompt(self, movie_id):

		projections = self.cinema.fetch_projections_id(movie_id)

		while True:
			projection = input("Step 3 (Projection): Choose a projection>")
			if projection == "give_up":
				return "give_up"
			elif projection.isdigit():#projection in projections:
				return projection 

	def str_to_tupul(self, string):
		string = string[1:].replace(")", "")
		result_list = string.split(",")
		return (int(result_list[0]), int(result_list[1]))


	def chose_seats(self, tickets_number, projection):
		not_free_seats = self.cinema.fetch_taken_seats(projection)
		choosen_seats = []
		print("Available seats (marked with a dot):")
		#print(self.show_places_map(not_free_seats))
		seat_map = []
		for line in self.show_places_map(not_free_seats):
			#print(line)
			seat_map.append(" ".join(line))

		print("\n".join(seat_map))

		while len(choosen_seats) < tickets_number:
			
			seat = input("Step 4 (Seats): Choose seat %s>" % str(len(choosen_seats)+1))
			if seat == "give_up":
				return "give_up"
			seat = self.str_to_tupul(seat)
			if seat in not_free_seats or seat in choosen_seats:
				print("This seat is already taken!")
			elif seat[0] > 10 or seat[1] > 10:
				print("Lol...NO!")
			else:
				choosen_seats.append(seat)
			#print(choosen_seats)

		return choosen_seats


	def reservation_prompt(self):
		user_info = self.get_user_info_prompt()
		if user_info == "give_up":
			return "give_up"

		(name, tickets_number) = user_info
		tickets_number = int(tickets_number)
		self.show_movies()

		movie_id = self.choose_movie_prompt()
		if movie_id == "give_up":
			return "give_up"

		self.show_pojections_by_id(movie_id)

		while True:
			projection = self.choose_projection_prompt(movie_id)
			if projection == "give_up":
				return "give_up"
			elif tickets_number <= self.cinema.free_place_for_projection(projection):
				break

		seats = self.chose_seats(tickets_number, projection)

		if seats == "give_up":
			return "give_up"

		fin = self.show_reservation_info(movie_id, projection, seats)

		if fin == "finalize":
			for seat in seats:
				self.make_reservation(name, projection_id, seat[0], seat[1])
			print("Thanks.")

		elif fin == "give_up":
			return "give_up"

	def exit(self):
		self.cinema.exit()
示例#18
0
from datetime import datetime
from flask import Flask, request
from flask_restful import Resource, Api, reqparse
from cinema import Cinema
from urllib.parse import quote

app = Flask(__name__)
api = Api(app)

basePath = '/api/v1'

cinema = Cinema()


def validDate(date):
    try:
        datetime.strptime(date, '%d%m%Y')
        return True
    except ValueError:
        return False


def validTime(time):
    if time in ["19:30", "21:00", "22:30"]:
        return True
    return False


def SeatToInt(seat):
    return (ord(str.upper(seat['row'])) - ord('A')) * 10 + seat['seat']
示例#19
0
 def setUp(self):
     self.my_cinema = Cinema(session)
示例#20
0
# 3 - create a new session
session = base.Session()


# 4 - create films
#bourne_identity = Film("The Bourne Identity", 2002, "Action", 119)
#furious_7 = Film("Furious 7", 2015, "Action", 137)
#pain_and_gain = Film("Pain & Gain", 2013, "Comedy", 129)
#session.add(bourne_identity)
#session.add(furious_7)
#session.add(pain_and_gain)
#c1 = Cinema("123", "123")
#session.add(c1)

#Cinema
cinema1 = Cinema("Kiev", "Velyka Vasylkivska Street, 19")
cinema2 = Cinema("October", "Konstantinovskaya Street, 26")
cinema3 = Cinema("Torch", "Mykola Bazhana Avenue, 3")

#Film
film1 = Film("InterStellar", 2014, "Fantastic", 168)
film2 = Film("Joker", 2019, "Drama", 116)
film3 = Film("Gentlemen", 2019, "Criminal", 113)

#Session
session1 = Session("2020-09-17", "Almandine", film1)
session1.cinemas = [cinema1]
session2 = Session("2020-09-17", "Ultramarine", film2)
session2.cinemas = [cinema2]
session3 = Session("2020-09-18", "Terracotta", film3)
session3.cinemas = [cinema3]
示例#21
0
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import create_engine
from sqlalchemy.orm import Session
from cinema import Cinema

db = 'cinema.db'
Base = declarative_base()
engine = create_engine("sqlite:///cinema.db")
Base.metadata.create_all(engine)
session = Session(bind=engine)

cinema = Cinema(session, db)

cinema.clear_reservation_on_startup()


def start_mess():
    start_message = "Hello, here is the cinema. You can \
use one of the the following commands:\
\n show_movies - print all movies ordered by rating\
\n show_movie_projections <movie_id> - \
print all projections of a given movie\
\n make_reservation\
\n cancel_reservation <name> - disintegrate given person's reservation\
\n exit\
\n help"
    return start_message


def print_func(set_obj):
    for row in set_obj:
示例#22
0
from flask import Flask
from flask_restful import Resource, Api, reqparse, request
from cinema import Cinema
from datetime import datetime

app = Flask(__name__)
api = Api(app)
app.config['SECRET_KEY'] = 'e3esacosdncwefn3rif3ufcs'

basePath = '/api/v1'  #uguale a quello nel file .yaml
c = Cinema()


# validatori dei parametri, data e time
def validDate(date):
    try:
        datetime.strptime(date, '%d%m%Y')
        return True
    except ValueError:
        return False


def validTime(time):
    if time in ['19:30', '21:00', '22:30']:
        return True
    return False


# convertiamo seat in in numero e viceversa

示例#23
0
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')
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")
示例#25
0
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(" ")
示例#26
0
from cinema import Cinema

row = int(input('Enter the number of rows:\n'))
seats = int(input("Enter the number of seats in each row:\n"))
while (True):
    ch = input(
        "1. Show the seats\n2. Buy a ticket\n3. Statistics\n4. Show booked Tickets User Info\n0. Exit\n"
    )
    if ch == "1":
        obj = Cinema()
        obj.show_seats(row, seats)

    if ch == "2":
        obj = Cinema()
        obj.buy_ticket(row, seats)

    if ch == "3":
        obj = Cinema()
        obj.show_statistics(row, seats)

    if ch == "4":
        obj = Cinema()
        obj.show_booked_ticket()

    if ch == "0":
        obj = Cinema()
        obj.exit_method()
        break
示例#27
0
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(" ")
from IPython.display import clear_output
from cinema import Seat, Cinema
from user import User
import mysql.connector

rows = int(input('Enter the number of rows: '))
columns = int(input('Enter the number of columns: '))
cinema = Cinema(rows, columns)


def start_screen():
    print('''Enter your option
    1. Show the seats
    2. Buy a ticket
    3. Statistics
    4. Show booked Tickets User Info
    0. Exit
    ''')
    option = int(input())
    return option


def create_user():
    infos = ['name', 'gender', 'age', 'phoneNo']
    inpt = []
    for info in infos:
        inpt.append(input(f'Enter your {info}: '))
    user = User(inpt[0], inpt[1], int(inpt[2]), int(inpt[3]))
    return user

示例#29
0
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import create_engine
from sqlalchemy.orm import Session
from cinema import Cinema

db = 'cinema.db'
Base = declarative_base()
engine = create_engine("sqlite:///cinema.db")
Base.metadata.create_all(engine)
session = Session(bind=engine)

cinema = Cinema(session, db)

cinema.clear_reservation_on_startup()


def start_mess():
    start_message = "Hello, here is the cinema. You can \
use one of the the following commands:\
\n show_movies - print all movies ordered by rating\
\n show_movie_projections <movie_id> - \
print all projections of a given movie\
\n make_reservation\
\n cancel_reservation <name> - disintegrate given person's reservation\
\n exit\
\n help"

    return start_message


def print_func(set_obj):
示例#30
0
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)
示例#31
0
class TestCinema(unittest.TestCase):
    def setUp(self):
        self.my_cinema = Cinema(session)

    def test_add_movie(self):
        #self.my_cinema.add_movie() add new movie
        movie = session.query(Movie.name, Movie.rating,
                              Movie.id).filter(Movie.name == "Bad boys")
        self.assertEqual(movie[0][0], "Bad boys")
        self.assertEqual(movie[0][1], 7.1)
        self.assertEqual(movie[0][2], 3)

    def test_show_movies(self):
        #self.my_cinema.show_movies()
        movies = session.query(Movie.name).all()
        self.assertEqual(movies, [('The Hunger Games', ), ('Die Hard', ),
                                  ('Bad boys', )])

    #def test_what_movie(self):
    #movie = self.my_cinema.what_movie()
    #self.assertEqual(movie, ['Wtf', '5.5'])

    def test_add_projections(self):
        #self.my_cinema.add_projections() #add one new projection
        projection = session.query(
            Projection.movie_type, Projection.date_time,
            Projection.movie_id).filter(Projection.movie_id == 3)
        self.assertEqual(projection[0][0], "3D")
        self.assertEqual(projection[0][1], datetime(2014, 11, 24, 21, 30))
        self.assertEqual(projection[0][2], 3)

    def test_select_title(self):
        self.assertEqual(self.my_cinema.select_title(2),
                         "Projections for Die Hard")

    #def test_select_projections(self): # samo printva projekciite
    #    self.my_cinema.select_projections(2)

    #def test_show_projections(self): # samo printva projekciite
    #    self.my_cinema.show_movie_projections(2)

    def test_take_spots(self):
        self.assertEqual(self.my_cinema.take_spots(2), 97)

    def test_seats_for_out_if_index(self):
        self.assertFalse(self.my_cinema.check_seats_for_out_index('(2, 44)'))
        self.assertTrue(self.my_cinema.check_seats_for_out_index('(2, 3)'))

    def test_seats_if_are_available(self):
        self.my_cinema.take_spots(2)
        self.my_cinema.show_seats(2)
        self.assertTrue(self.my_cinema.check_seats_if_available("(1, 2)"))
        self.assertFalse(self.my_cinema.check_seats_if_available("(7, 7)"))

    def test_cancel_reservation(self):  #works only once !
        #old_reservation = session.query(Reservation).all()
        #self.assertEqual(len(old_reservation), 6)
        self.my_cinema.cancel_reservation("Ivo")
        new_reservation = session.query(Reservation).all()
        self.assertEqual(len(new_reservation), 5)
from cinema import Cinema
from user_interface import *

gornik = Cinema('Gornik')
gornik.add_room('A', (11, 11))
gornik.add_room('B', (12, 12))
gornik.movie_generator()
gornik.allocation_seat_generator()
show_interface(gornik)

示例#33
0
def buy_a_ticket():

    greenmile = The_Green_Mile()
    # print(greenmile.num_seats())
    shawredemption = The_Shawshank_Redemption()
    # print(shawredemption.num_seats())
    # print(greenmile.get_name())
    f = Cinema("MON15", greenmile)
    f.allocate_person("Anna B.", "2A")
    f.allocate_person("Ewa F.", "2D")
    f.allocate_person("Marcin M.", "4C")
    f.relocate_person("2A", "12B")
    f.relocate_person("2D", "13B")
    f.relocate_person("4C", "12C")
    # print(f.time)
    # print(f.get_day())
    # print(f.get_hour())
    # print(f.get_movie())
    pprint(f.seats)
    print(f.get_empty_seats())
    ticket_printer("Anna Kowalska", "5B", "The Green Mile", "SAT12")
    f.print_tickets(ticket_printer)