def test_02_get_hotels_in_city(self): #Verify that no hotels in Abu Dhabi initially exist hotels = Hotel.get_hotels_in_city('Abu Dhabi') self.assertTrue( len(hotels) == 0, msg='No hotels in Abu Dhabi should have been initially existing') #Add 2 hotels to list self.hotel1.add_to_list() self.hotel2.add_to_list() #Verify that 2 hotels are in Abu Dhabi hotels = Hotel.get_hotels_in_city('Abu Dhabi') self.assertTrue(len(hotels) == 2 and\ hotels[0] == self.hotel1 and\ hotels[1] == self.hotel2, msg='2 hotels in Abu Dhabi should have been existing')
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_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 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()))