def test_movie_world_rent_dvd_already_rented(self): movie_world = MovieWorld("Test") d = DVD("A", 1, 1254, "February", 10) c = Customer("Pesho", 20, 4) c2 = Customer("Gosho", 26, 2) movie_world.add_customer(c) movie_world.add_customer(c2) movie_world.add_dvd(d) movie_world.rent_dvd(4, 1) result = movie_world.rent_dvd(2, 1) self.assertEqual(result, "DVD is already rented")
def test_customer_init(self): Customer.id = 1 c = Customer("Pesho", "addr.", "*****@*****.**") self.assertEqual(c.id, 1) self.assertEqual(c.name, "Pesho") self.assertEqual(c.address, "addr.") self.assertEqual(c.email, "*****@*****.**")
def test_gym_add_customer(self): Gym.id = 1 g = Gym() c = Customer("Pesho", "addr.", "*****@*****.**") g.add_customer(c) g.add_customer(c) self.assertEqual(g.customers, [c])
def test_movie_world_return_dvd_unsuccessful(self): movie_world = MovieWorld("Test") d = DVD("A", 1, 1254, "February", 10) c = Customer("Pesho", 20, 4) movie_world.add_customer(c) movie_world.add_dvd(d) result = movie_world.return_dvd(4, 1) self.assertEqual(result, "Pesho does not have that DVD")
def test_movie_world_rent_dvd_already_rented_by_user(self): movie_world = MovieWorld("Test") d = DVD("A", 1, 1254, "February", 10) c = Customer("Pesho", 20, 4) movie_world.add_customer(c) movie_world.add_dvd(d) movie_world.rent_dvd(4, 1) result = movie_world.rent_dvd(4, 1) self.assertEqual(result, "Pesho has already rented A")
def test_movie_world_rent_dvd_no_permision(self): movie_world = MovieWorld("Test") d = DVD("A", 1, 1254, "February", 18) c = Customer("Pesho", 16, 4) movie_world.add_customer(c) movie_world.add_dvd(d) result = movie_world.rent_dvd(4, 1) self.assertEqual(result, "Pesho should be at least 18 to rent this movie")
def test_movie_world_repr(self): movie_world = MovieWorld("Test") d = DVD("A", 1, 1254, "February", 10) c = Customer("Pesho", 20, 4) movie_world.add_customer(c) movie_world.add_dvd(d) movie_world.rent_dvd(4, 1) actual = repr(movie_world).strip('\n') expected = "4: Pesho of age 20 has 1 rented DVD's (A)\n1: A (February 1254) has age restriction 10. Status: rented" self.assertEqual(actual, expected)
def test_movie_world_rent_dvd_success(self): movie_world = MovieWorld("Test") d = DVD("A", 1, 1254, "February", 10) c = Customer("Pesho", 20, 4) movie_world.add_customer(c) movie_world.add_dvd(d) result = movie_world.rent_dvd(4, 1) self.assertEqual(result, "Pesho has successfully rented A") self.assertEqual(d.is_rented, True) self.assertEqual(c.rented_dvds[0], d)
def parseFile(self): #fileLoc = open("./dataTSP/Solomon/100/1TSP_100/" + self.filename) fileLoc = open("./dataTSP/TSPLIB/" + self.filename) lines = fileLoc.readlines() depot = lines[5].split() self.depot = Depot(float(depot[0]), float(depot[1])) count = 0 for line in lines[6:]: vertex = line.split() self.vertices.append( Customer(float(vertex[0]), float(vertex[1]), int(vertex[-1]), count)) count += 1 # print(self.vertices[2].coordinate, " ", self.vertices[2].release) return
def test_gym_subscription_info(self): Gym.id = 1 Subscription.id = 1 ExercisePlan.id = 1 Equipment.id = 1 Trainer.id = 1 Customer.id = 1 g = Gym() s = Subscription("10.02.2020", 1, 1, 1) p = ExercisePlan(1, 1, 10) e = Equipment("Pesho") t = Trainer("Pesho") c = Customer("Pesho", "addr.", "*****@*****.**") g.add_subscription(s) g.add_customer(c) g.add_equipment(e) g.add_plan(p) g.add_trainer(t) self.assertEqual(g.subscription_info(1), "Subscription <1> on 10.02.2020\nCustomer <1> Pesho; Address: addr.; Email: [email protected]\nTrainer <1> Pesho\nEquipment <1> Pesho\nPlan <1> with duration 10 minutes")
from project.customer import Customer from project.equipment import Equipment from project.exercise_plan import ExercisePlan from project.gym import Gym from project.subscription import Subscription from project.trainer import Trainer customer = Customer("John", "Maple Street", "*****@*****.**") equipment = Equipment("Treadmill") trainer = Trainer("Peter") subscription = Subscription("14.05.2020", 1, 1, 1) plan = ExercisePlan(1, 1, 20) gym = Gym() gym.add_customer(customer) gym.add_equipment(equipment) gym.add_trainer(trainer) gym.add_plan(plan) gym.add_subscription(subscription) print(Customer.get_next_id()) print(gym.subscription_info(1)) # c = Customer("Sofia", "Lozen", "*****@*****.**") # print(c) # # m = Customer("Sofia", "Lozen", "*****@*****.**") # print(c) # print(m)
from project.customer import Customer from project.dvd import DVD from project.movie_world import MovieWorld if __name__ == '__main__': c1 = Customer("John", 16, 1) c2 = Customer("Anna", 55, 2) d1 = DVD("Black Widow", 1, 2020, "April", 18) d2 = DVD.from_date(2, "The Croods 2", "23.12.2020", 3) movie_world = MovieWorld("The Best Movie Shop") movie_world.add_customer(c1) movie_world.add_customer(c2) movie_world.add_dvd(d1) movie_world.add_dvd(d2) print(movie_world.rent_dvd(1, 1)) print(movie_world.rent_dvd(2, 1)) print(movie_world.rent_dvd(1, 1)) print(movie_world)
def test_customer_init(self): c = Customer("Pesho", 22, 1) self.assertEqual(c.name, "Pesho") self.assertEqual(c.age, 22) self.assertEqual(c.id, 1)
from project.customer import Customer from project.dvd import DVD from project.movie_world import MovieWorld c1 = Customer("John", age=16, id=1) c2 = Customer("Anna", age=55, id=2) d1 = DVD("Black Widow", id=1, creation_year=2020, creation_month="April", age_restriction=18) d2 = DVD.from_date(2, "The Croods 2", "23.12.2020", 3) movie_world = MovieWorld("The Best Movie Shop") movie_world.add_customer(c1) movie_world.add_customer(c2) movie_world.add_dvd(d1) movie_world.add_dvd(d2) print(movie_world.rent_dvd(1, 1)) print(movie_world.rent_dvd(2, 1)) print(movie_world.rent_dvd(1, 2)) print(movie_world)
from project.customer import Customer from project.dvd import DVD from project.movie_world import MovieWorld customer = Customer('Atanas', 18, 123) dvd = DVD('CONG: In the Wild', 555, 1998, 'August', 18) dvd2 = DVD.from_date(777, 'CHE', '12.09.1988', 18) # dvd.is_rented = True movie_world = MovieWorld("Gaco") movie_world.add_customer(customer) movie_world.add_dvd(dvd) movie_world.add_dvd(dvd2) print(movie_world.rent_dvd(123, 555)) print(movie_world.rent_dvd(123, 555)) print(movie_world.return_dvd(123, 555)) print(movie_world.return_dvd(123, 555)) print(movie_world.rent_dvd(123, 777)) print(movie_world)
def test_customer_repr(self): Customer.id = 1 c = Customer("Pesho", "addr.", "*****@*****.**") self.assertEqual(str(c), "Customer <1> Pesho; Address: addr.; Email: [email protected]")
def test_customer_repr(self): c = Customer("Pesho", 22, 1) self.assertEqual(repr(c), "1: Pesho of age 22 has 0 rented DVD's ()")
def test_customer_static_method(self): Customer.id = 1 self.assertEqual(Customer.get_next_id(), 1)
def test_movie_world_add_customer_success(self): movie_world = MovieWorld("Test") c = Customer("Pesho", 20, 4) movie_world.add_customer(c) self.assertEqual(movie_world.customers, [c])
def test_movie_world_add_customer_overflow(self): movie_world = MovieWorld("Test") for _ in range(11): movie_world.add_customer(Customer("Pesho", 20, 4)) self.assertEqual(len(movie_world.customers), 10)
from project.customer import Customer from project.equipment import Equipment from project.exercise_plan import ExercisePlan from project.gym import Gym from project.subscription import Subscription from project.trainer import Trainer customer = Customer("John", "Maple Street", "*****@*****.**") customer2 = Customer("Atanas", "test", "*****@*****.**") equipment = Equipment("Treadmill") equipment2 = Equipment("Push Ups") trainer = Trainer("Peter") trainer2 = Trainer("Gosho") subscription = Subscription("14.05.2020", 1, 1, 1) subscription2 = Subscription("05.11.2020", 2, 2, 2) plan = ExercisePlan(1, 1, 20) plan2 = ExercisePlan.from_hour(2, 2, 3) gym = Gym() gym.add_customer(customer2) gym.add_equipment(equipment2) gym.add_trainer(trainer2) gym.add_plan(plan2) gym.add_subscription(subscription2) # print(Customer.get_next_id()) # # print(gym.subscription_info(1)) print(gym.subscription_info(2))