def fill_test_data(self): hotel1 = Hotel(1, "Rotana", "Amman", 300, 50) hotel1.add_hotel() hotel12 = Hotel(2, "Royal", "Amman", 250, 35) hotel12.add_hotel() hotel1.list_hotels_in_city() customer1 = Customer("Yahya") customer1.add_customer() reservation1 = Reservation("Rotana", "Yahya", "+962779148786") reservation1.reservation_list_in_hotel()
def do_n(self, args): if len(args) != 0: name = args if name not in self.customer_name_list: print("The customer name \'" + name + "\' does not exist") if name.count("(") == 1 and name.count(")") == 1: new_name = input( "Do you want to create a new customer \'" + name + "\'? (y/n): ") if new_name == 'y': Customer.add_customer(name) self.customer_name_list.append(name) self.prompt = name + ":" else: print( "New name must be entered in the format: name (place)") else: self.prompt = "sale_" + name + ": "
def start_app(): rotana_hotel = Hotel(20, "Rotana", "Abu Dhabi", 200, 40) sheraton_hotel = Hotel(21, "Sheraton", "Abu Dhabi", 300, 100) print Hotel.hotels customer = Customer("name", "0000000000") customer.add_customer("name2", "phone2") print "Customer List : {}".format(customer.customers_list) reservation = Reservation(Hotel.hotels[0][1], Customer.customers_list[0][0]) reservation.add_new_reservation(Hotel.hotels[0][1], Customer.customers_list[0][0]) print "Reservation List: {}".format(reservation.reservation_list) reservation.list_resevrations_for_hotel(Hotel.hotels[0][1])
def test_book_room(self): user = Customer("Mohamed", "Saleh", "+79613203083") # --<Incorrect Inputs>-- self.assertRaises(ValueError, self.tcu.book_room, 5, user, date.today(), date(2020, 1, 1)) user.add_customer() self.assertRaises(ValueError, self.tcu_.book_room, 3, user, date.today(), date(2020, 1, 1)) self.assertRaises(ValueError, self.swit.book_room, 7, user, date.today(), date(2020, 1, 1)) self.swit.add_hotel() self.assertRaises(TypeError, self.yolo.book_room, "11", user, date.today(), date(2020, 1, 1)) self.assertRaises(TypeError, self.swit.book_room, 13, user, (2019, 12, 21), date(2020, 1, 1)) # --<Returned Values>-- self.assertIsNone(self.yolo.book_room(1, user, date.today(), date(2020, 1, 1)), msg="Booking a room shouldn't " "return anything!")
def start_app(): hotels = [ "Best Western", "Hilton", "Hyatt", "InterContinental", "Radisson", "Sheraton", "Westin" ] cities = [ "New York", "Dubai", "Cairo", "Moscow", "Paris", "London", "Tokyo" ] names = [ "Mohamed", "Ahmed", "Mahoud", "Sad", "Ali", "Kaream", "Hussein", "Omar", "Hazem", "Ibrahim" ] i = 0 while i < 25: try: user = Customer( random.choice(names), random.choice(names), "".join(str(random.randint(0, 9)) for _ in range(10))) hotel = Hotel(random.choice(hotels), random.choice(cities), random.randint(50, 100)) user.add_customer() hotel.add_hotel() i += 1 except ValueError: pass for number in Customer.customers: user = Customer.get_customer(number) print("{} {}: {}".format(user.first_name, user.last_name, user.phone_number)) print("=" * 100) for city in Hotel.hotels: print("=" * 100) print("{}:".format(city)) print(list(Hotel.get_hotels_in_city(city).keys()))
class TestCustomer(unittest.TestCase): def setUp(self): self.user = Customer("A", "B", "+123") self.user1 = Customer("mohamed", "Saleh", "+79613206083") self.user2 = Customer("Ahmed", "Eleslamboly", "89618305057") self.user3 = Customer("Mahmoud", "Ali", "89618305057") # +201062479370 self.user1.add_customer() self.user2.add_customer() def tearDown(self): Customer.customers.clear() def test_create_customer(self): # --<Incorrect Inputs>-- self.assertRaises(TypeError, Customer, "Mohamed", "Saleh", 89613206083) self.assertRaises(TypeError, Customer, "Mohamed", 123, "89613206083") self.assertRaises(ValueError, Customer, "Mo7amed", "Saleh", "+201020899838") self.assertRaises(ValueError, Customer, "Mohamed", "Saleh", "2+01020899838") def test_add_customer(self): # --<Returned Values>-- self.assertIsNone(self.user.add_customer(), msg="Adding a customer shouldn't return anything!") # --<Incorrect Inputs>-- self.assertRaises(ValueError, self.user1.add_customer) self.assertRaises(ValueError, self.user3.add_customer) # --<Effect on the Database>-- self.assertIn(self.user1.phone_number, Customer.customers, msg="User 1 wasn't added to the database!") self.assertIn(self.user2.phone_number, Customer.customers, msg="User 2 wasn't added to the database!") self.assertIs(Customer.customers[self.user2.phone_number], self.user2, msg="User 2 isn't assigned to its phone " "number!") self.assertNotIn(self.user3, Customer.customers.values(), msg="Adding this customer should've failed!") self.assertIs(Customer.customers[self.user2.phone_number], self.user2, msg="After trying to add user 3, user 2 " "is no longer assigned to its phone " "number!") def test_get_customer(self): # --<Incorrect Inputs>-- self.assertRaises(TypeError, Customer.get_customer, 89613206083) self.assertRaises(ValueError, Customer.get_customer, "Ahmed") self.assertRaises(ValueError, Customer.get_customer, "1+2") # --<Returned Values>-- self.assertIs(Customer.get_customer(self.user1.phone_number), self.user1, msg="Didn't return User 1!") self.assertNotIsInstance(Customer.get_customer("+0123456789"), Customer, msg="Phone number shouldn't excise!") self.assertEqual(Customer.get_customer("89613206083"), {}, msg="Should return an empty dictionary!") def test_edit_customer(self): # --<Returned Values>-- self.assertIsNone(self.user.edit_customer(), msg="Editing a customer shouldn't return anything!") # --<Incorrect Inputs>-- self.assertRaises(TypeError, self.user1.edit_customer, phone_number=89613206083) self.assertRaises(ValueError, self.user1.edit_customer, age=32) self.assertRaises(ValueError, self.user2.edit_customer, first_name="A7med") self.assertRaises(ValueError, self.user2.edit_customer, phone_number=self.user1.phone_number) # --<Effect on the Database>-- self.assertIs(Customer.get_customer(self.user1.phone_number), self.user1, msg="After trying to assign the " "phone number of user 1 to user" " 2, user 1 is no longer " "assigned to its phone number!") # ============================ self.user1.edit_customer(phone_number="+79613206083", last_name="ragaey", first_name="Mohammed") self.assertEqual(self.user1.first_name, "Mohammed", msg="First name incorrectly edited!") self.assertEqual(self.user1.last_name, "Ragaey", msg="Last name incorrectly edited!") self.assertEqual(self.user1.phone_number, "+79613206083", msg="Phone number incorrectly edited!") # ============================ self.user3.edit_customer(phone_number=self.user1.phone_number) self.assertEqual(self.user3.phone_number, self.user1.phone_number, msg="Phone number not assigned even though " "user 3 isn't in the database!") # ============================ self.user3.edit_customer(phone_number="+201062479370") self.assertEqual(self.user3.phone_number, "+201062479370", msg="Phone number incorrect after editing!") def test_delete_customer(self): # --<Returned Values>-- self.assertIsNone(self.user1.delete_customer(), msg="Deleting a customer shouldn't return anything!") # -<Effect on the Database>- self.assertNotIn(self.user1.phone_number, Customer.customers, msg="User 1 was deleted so it shouldn't exist!") self.assertRaises(ValueError, self.user1.delete_customer) self.assertRaises(ValueError, self.user3.delete_customer) self.assertIn(self.user2.phone_number, Customer.customers, msg="User 2 should still be in the database!") self.assertIs(Customer.get_customer(self.user2.phone_number), self.user2, msg="Trying to delete user 1 while " "having the same phone number as " "user 2 effected user 2!")
def fill_test(self): show=notification.Notifications() Rotana_hotel = Hotel(1,"Rotana","Abu Dhabi",200,40) Rotana_hotel.add_hotel() show.display(Rotana_hotel) # Display General details for ONE hotels Sheraton_hotel = Hotel(2,"Sheraton","Abu Dhabi",300,100) Sheraton_hotel.add_hotel() Hayat_hotel = Hotel(3,"Hayat","Aden",150,100) Hayat_hotel.add_hotel() Crecent_hotel = Hotel(4,"Crecent","Mukala",200,50) Crecent_hotel.add_hotel() Holydayin_hotel = Hotel(5,"Holydayin","Sana'a",200,100) Holydayin_hotel.add_hotel() Rotana_hotel = Hotel(1,"Rotana","Abu Dhabi",200,40) Rotana_hotel.add_hotel() Zero_hotel = Hotel(6,"Zero","Virtual",200,0) # used to check unavailablity condition Zero_hotel.add_hotel() show.display("\t list of the Hotels available") show.display(Hotel.hotels) # Display General details for all hotels show.display(Hayat_hotel.hotel_name) # Display the name for ONE hotel #Create instance objects for 4 customers Saqr_Thabet=Reservation("Hayat","Saqr_thabet","+8613094449161") Ali_Ahmed=Reservation("Holydayin","Ali_ahmed","+8613094449161") Ameer_Nezar=Reservation("Holydayin","Ameer_nezar","+8613094449161") Galal_Taleb=Reservation("Zero","Galal_taleb","+8613228191565") #Create reservations for 4 customers if Saqr_Thabet.add_new_reservation(): s_t=Customer(Saqr_Thabet.hotel_name,Saqr_Thabet.customer,Saqr_Thabet.number) s_t.add_customer() show.display(Saqr_Thabet.message) #show.display(Saqr_Thabet.reservations) #show.send_message(Saqr_Thabet.message,Saqr_Thabet.number) if Ali_Ahmed.add_new_reservation(): m_a=Customer(Ali_Ahmed.hotel_name,Ali_Ahmed.customer,Ali_Ahmed.number) m_a.add_customer() show.display(Ali_Ahmed.message) #show.display(Ali_Ahmed.reservations) #show.send_message(Ali_Ahmed.message,Ali_Ahmed.number) if Ameer_Nezar.add_new_reservation(): m_b=Customer(Ameer_Nezar.hotel_name,Ameer_Nezar.customer,Ameer_Nezar.number) m_b.add_customer() show.display(Ameer_Nezar.message) #show.display(Ameer_Nezar.reservations) #show.send_message(Ameer_Nezar.message,Ameer_Nezar.number) #def Test_reservation_disapproval(): show.display("\t Test_reservation_disapproval ") if Galal_Taleb.add_new_reservation(): # no rooms available m_c=Customer(Galal_Taleb.hotel_name,Galal_Taleb.customer,Galal_Taleb.number) #show.display(Galal_Taleb.message) #show.display(Galal_Taleb.reservations) #m_a1.send_message(Galal_Taleb.message,Galal_Taleb.number) #def Test_misspelled_hotel_name(): show.display("\t Test_misspelled_hotel_name ") Fagr_khalil=Reservation("Holyday","Fagr_Khalil","+8613094449161") Fagr_khalil.add_new_reservation() #def Test_delete_a_customer(): show.display('\t Test_delete_a_customer') show.display(m_b.customer_list) m_a.delete_customer() # delete customer from customer Class show.display(m_b.customer_list) #def Test_reservation_removal(): show.display('\t Test_reservation_removal') show.display(Ameer_Nezar.reservations) Ameer_Nezar.delete_a_reservation() # delete customer booking from reswervation Class show.display(Ameer_Nezar.reservations) #def Test_delete_a_hotel(): show.display('\t Test_delete_a_hotel') show.display(Hotel.hotels) Rotana_hotel.delete_hotel() show.display(Hotel.hotels) #def Test_reservation_in_a_hotel(hotel): show.display("\t Test_reservation_in_a_hotel('Holydayin')") show.display(reservation.list_resevrations_for_hotel('Holydayin')) #from reservation.py #def Test_list_of_available_hotels_in_a_city(city): show.display("\t Test_list_of_available_hotels_in_a_city('Abu Dhabi')") show.display(hotel.list_hotels_in_city('Abu Dhabi')) # from hotel.py