Example #1
0
 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!")
Example #2
0
 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?!")