class TestHotel(unittest.TestCase): def setUp(self): self.yolo = Hotel("YOLO", "Utopia", 13) self.tcu = Hotel("The Crack Up", "Laughter", 55) self.swit = Hotel("Swing It", "Laughter", 69) self.tcu_ = Hotel("The Crack Up", "Laughter", 24) self.yolo.add_hotel() self.tcu.add_hotel() def tearDown(self): Hotel.hotels.clear() def test_create_hotel(self): # --<Incorrect Inputs>-- self.assertRaises(TypeError, Hotel, "Horizon", "Rio", 12.5) self.assertRaises(TypeError, Hotel, "Red Rose", 5, 12) self.assertRaises(ValueError, Hotel, "4 Seasons", "Cairo", -10) self.assertRaises(ValueError, Hotel, "Continental", "city" * 13, 11) def test_add_hotel(self): # --<Returned Values>-- self.assertIsNone(self.swit.add_hotel(), msg="Adding a hotel shouldn't return anything!") # --<Incorrect Inputs>-- self.assertRaises(ValueError, self.yolo.add_hotel) self.assertRaises(ValueError, self.tcu_.add_hotel) # -<Effect on the Database>- self.assertIn( self.yolo.city, Hotel.hotels, msg="If the city doesn't exist where is the hotel then?!") self.assertIn(self.tcu.name, Hotel.hotels[self.tcu.city], msg="There's no hotel with that name in this city!") self.assertIs(self.yolo, Hotel.hotels[self.yolo.city][self.yolo.name], msg="The hotel is not the hotel!") self.assertNotIn(self.tcu_, Hotel.hotels[self.tcu_.city].values(), msg="Adding this hotel should've failed!") self.assertIs(self.tcu, Hotel.hotels[self.tcu.city][self.tcu.name], msg="Trying to add a hotel with the same" " name and city messed thing up for" " the original hotel!") def test_get_hotel(self): # --<Incorrect Inputs>-- self.assertRaises(TypeError, Hotel.get_hotels_in_city, ["Delhi"]) self.assertRaises(ValueError, Hotel.get_hotels_in_city, "Cairo" * 11) self.assertRaises(TypeError, Hotel.get_hotel, "Delhi", 17) self.assertRaises(ValueError, Hotel.get_hotel, "Madagascan", "Banana House" * 9) # --<Returned Values>-- self.assertIs(Hotel.get_hotel(self.yolo.city, self.yolo.name), self.yolo, msg="YOLO isn't what we thought!") self.assertEqual(Hotel.get_hotel("Hesitance", self.yolo.name), {}, msg="Hesitance and YOLO don't go together!") self.assertEqual(Hotel.get_hotels_in_city("Mars"), {}, msg="Elon Musk hasn't made it to Mars yet!") self.assertIsInstance(Hotel.get_hotels_in_city(self.tcu.city), dict, msg="The hotels aren't stored in a " "dictionary!") def test_edit_hotel(self): pass def test_delete_hotel(self): # --<Returned Values>-- self.assertIsNone(self.yolo.delete_hotel(), msg="Deleting a hotel shouldn't return anything!") # --<Incorrect Inputs>-- self.assertRaises(ValueError, self.yolo.delete_hotel) self.assertRaises(ValueError, self.tcu_.delete_hotel) # --<Effect on the Database>-- self.assertNotIn(self.yolo.name, Hotel.get_hotels_in_city(self.yolo.city), msg="YOLO was deleted so it " "shouldn't exist!") self.assertIn(self.tcu.name, Hotel.get_hotels_in_city(self.tcu.city), msg="Where did \"The Crack up\" go?!") self.assertIs(Hotel.get_hotel(self.tcu.city, self.tcu.name), self.tcu, msg="Who changed The Crack up?!") def test_get_room(self): # --<Incorrect Inputs>-- self.assertRaises(TypeError, self.yolo.get_room, "Room11") self.assertRaises(ValueError, self.tcu.get_room, -11) self.assertRaises(TypeError, self.swit.get_available_rooms, date.today, date(2020, 1, 1)) self.assertRaises(ValueError, self.tcu_.get_available_rooms, date(2020, 1, 1), date.today()) # --<Returned Values>-- self.assertEqual(self.swit.get_room(70), {}, msg="Who replace the empty dictionary?!") self.assertIsInstance(self.yolo.get_room(5), Room, msg="I asked for a room not a pizza!") self.assertIsInstance(self.tcu.get_available_rooms( date.today(), date(2020, 1, 1)), dict, msg="I want my order " "in a dictionary!") 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 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