def main(): # Create object of Hotel class obj_hotel = Hotel('MARRIOTT', '1 Amiryan Street, Yerevan 0010 Armenia', '+374-10-599000', 'www.marriott.com') # Create objects of Guest class obj_guest1 = Guest('Armen', 'Hakobian', '*****@*****.**', '091-333-402') obj_guest2 = Guest('Ani', 'Hakobian', '*****@*****.**', '077-587-578') # Create objects of Room class obj_room1 = Room(1, 'Yes', 'Yes', 'No') obj_room2 = Room(2, 'No', 'Yes', 'Yes') obj_room3 = Room(3, 'No', 'Yes', 'No') # Add rooms in Hotel obj_hotel.add_room(obj_room1) obj_hotel.add_room(obj_room2) obj_hotel.add_room(obj_room3) # Book rooms obj_hotel.book_room(obj_guest1) obj_hotel.book_room(obj_guest2) # Print hotel info obj_hotel.print_hotel_info() # Print all rooms info obj_hotel.print_all_rooms() # Print room info with a given number (ex. 2) obj_hotel.print_room_info(2) # Print guest info obj_guest1.get_info() # Print all booked rooms info obj_hotel.print_book_info() # or # Print a booked room info by room number obj_hotel.print_book_info(2)
while True: choice = int(input("\n\tEnter your choice: ")) if choice == 1: name = input("\n\tEnter your Name: ") print(f'\n\t\tRooms Available') hotel1.rooms_available() single, double, triple = map( int, input( "\tEnter Number of Single/Double/Triple Rooms(Space Seperated): " ).split()) if hotel1.check_available(single, double, triple): ac = input("\tDo you wish to have AC(Y/N): ") if ac == 'y' or 'Y': ac = True else: ac = False days = int(input("\tEnter Number of Days: ")) customer_obj = Customer(name, single, double, triple, ac, days) hotel1.book_room(customer_obj) customer_obj.print_bill() else: print("\n\t\tRooms Not Available!") elif choice == 2: bill_id = int(input("\n\tEnter Bill ID: ")) hotel1.vaccate_room(bill_id) elif choice == 3: print("\n\t\tThank You!") break
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!")