def Place_attributes(self): """Tests for Place attributes""" place = Place() self.assertTrue("city_id" in place.__dir__()) self.assertTrue("user_id" in place.__dir__()) self.assertTrue("name" in place.__dir__()) self.assertTrue("description" in place.__dir__()) self.assertTrue("number_rooms" in place.__dir__()) self.assertTrue("number_bathrooms" in place.__dir__()) self.assertTrue("max_guest" in place.__dir__()) self.assertTrue("price_by_night" in place.__dir__()) self.assertTrue("latitude" in place.__dir__()) self.assertTrue("longitude" in place.__dir__()) self.assertTrue("amenity_ids" in place.__dir__())
def test_attrs(self): """Tests that attributes exist in Place class""" new = Place() self.assertTrue("city_id" in new.__dir__()) self.assertTrue("user_id" in new.__dir__()) self.assertTrue("name" in new.__dir__()) self.assertTrue("description" in new.__dir__()) self.assertTrue("number_rooms" in new.__dir__()) self.assertTrue("number_bathrooms" in new.__dir__()) self.assertTrue("max_guest" in new.__dir__()) self.assertTrue("price_by_night" in new.__dir__()) self.assertTrue("latitude" in new.__dir__()) self.assertTrue("longitude" in new.__dir__()) self.assertTrue("amenity_ids" in new.__dir__())
class TestUser(unittest.TestCase): ''' Testing Place class ''' def setUp(self): ''' Creates an instance for place. ''' self.new_place = Place(city_id="Paris", user_id="Betty", description="lovely", number_rooms=3, number_bathrooms=3, max_guest=3, price_by_night=100, latitude=1.1, longitude=2.2) def TearDown(self): pass def test_Place_inheritance(self): ''' tests that the City class Inherits from BaseModel ''' self.assertIsInstance(self.new_place, BaseModel) def test_Place_attributes(self): ''' Checks that the attribute exist. ''' self.assertTrue("city_id" in self.new_place.__dir__()) self.assertTrue("user_id" in self.new_place.__dir__()) self.assertTrue("description" in self.new_place.__dir__()) self.assertTrue("name" in self.new_place.__dir__()) self.assertTrue("number_rooms" in self.new_place.__dir__()) self.assertTrue("max_guest" in self.new_place.__dir__()) self.assertTrue("price_by_night" in self.new_place.__dir__()) self.assertTrue("latitude" in self.new_place.__dir__()) self.assertTrue("longitude" in self.new_place.__dir__()) self.assertTrue("amenity_ids" in self.new_place.__dir__()) @unittest.skipIf(os.getenv('HBNB_TYPE_STORAGE') == 'db', "longitude") def test_type_longitude(self): ''' Test the type of longitude. ''' longitude = getattr(self.new_place, "longitude") self.assertIsInstance(longitude, float) @unittest.skipIf(os.getenv('HBNB_TYPE_STORAGE') == 'db', "latitude") def test_type_latitude(self): ''' Test the type of latitude ''' latitude = getattr(self.new_place, "latitude") self.assertIsInstance(latitude, float) def test_type_amenity(self): ''' Test the type of latitude ''' amenity = getattr(self.new_place, "amenity_ids") self.assertIsInstance(amenity, list) @unittest.skipIf(os.getenv('HBNB_TYPE_STORAGE') == 'db', "price by night") def test_type_price_by_night(self): ''' Test the type of price_by_night ''' price_by_night = getattr(self.new_place, "price_by_night") self.assertIsInstance(price_by_night, int) @unittest.skipIf(os.getenv('HBNB_TYPE_STORAGE') == 'db', "guest") def test_type_max_guest(self): ''' Test the type of max_guest ''' max_guest = getattr(self.new_place, "max_guest") self.assertIsInstance(max_guest, int) @unittest.skipIf(os.getenv('HBNB_TYPE_STORAGE') == 'db', "bathroom") def test_type_number_bathrooms(self): ''' Test the type of number_bathrooms ''' number_bathrooms = getattr(self.new_place, "number_bathrooms") self.assertIsInstance(number_bathrooms, int) @unittest.skipIf(os.getenv('HBNB_TYPE_STORAGE') == 'db', "rooms") def test_type_number_rooms(self): ''' Test the type of number_bathrooms ''' number_rooms = getattr(self.new_place, "number_rooms") self.assertIsInstance(number_rooms, int) @unittest.skipIf(os.getenv('HBNB_TYPE_STORAGE') == 'db', "description") def test_type_description(self): ''' Test the type of description ''' description = getattr(self.new_place, "description") self.assertIsInstance(description, str) @unittest.skipIf(os.getenv('HBNB_TYPE_STORAGE') == 'db', "name") def test_type_name(self): ''' Test the type of name ''' name = getattr(self.new_place, "name") self.assertIsInstance(name, str) @unittest.skipIf(os.getenv('HBNB_TYPE_STORAGE') == 'db', "user id") def test_type_user_id(self): ''' Test the type of user_id ''' user_id = getattr(self.new_place, "user_id") self.assertIsInstance(user_id, str) @unittest.skipIf(os.getenv('HBNB_TYPE_STORAGE') == 'db', "city id") def test_type_city_id(self): ''' Test the type of city_id ''' city_id = getattr(self.new_place, "city_id") self.assertIsInstance(city_id, str)
class TestUser(unittest.TestCase): '''Testing Place class''' def setUp(self): '''Creates an instance for place.''' self.new_place = Place() def TearDown(self): pass def test_Place_inheritance(self): '''tests that the City class Inherits from BaseModel''' self.assertIsInstance(self.new_place, BaseModel) def test_Place_attributes(self): '''Checks that the attribute exist.''' self.assertTrue("city_id" in self.new_place.__dir__()) self.assertTrue("user_id" in self.new_place.__dir__()) self.assertTrue("description" in self.new_place.__dir__()) self.assertTrue("name" in self.new_place.__dir__()) self.assertTrue("number_rooms" in self.new_place.__dir__()) self.assertTrue("max_guest" in self.new_place.__dir__()) self.assertTrue("price_by_night" in self.new_place.__dir__()) self.assertTrue("latitude" in self.new_place.__dir__()) self.assertTrue("longitude" in self.new_place.__dir__()) self.assertTrue("amenity_ids" in self.new_place.__dir__()) def test_type_longitude(self): '''Test the type of longitude.''' longitude = getattr(self.new_place, "longitude") self.assertIsInstance(longitude, float) def test_type_latitude(self): '''Test the type of latitude''' latitude = getattr(self.new_place, "latitude") self.assertIsInstance(latitude, float) def test_type_amenity(self): '''Test the type of latitude''' amenity = getattr(self.new_place, "amenity_ids") self.assertIsInstance(amenity, list) def test_type_price_by_night(self): '''Test the type of price_by_night''' price_by_night = getattr(self.new_place, "price_by_night") self.assertIsInstance(price_by_night, int) def test_type_max_guest(self): '''Test the type of max_guest''' max_guest = getattr(self.new_place, "max_guest") self.assertIsInstance(max_guest, int) def test_type_number_bathrooms(self): '''Test the type of number_bathrooms''' number_bathrooms = getattr(self.new_place, "number_bathrooms") self.assertIsInstance(number_bathrooms, int) def test_type_number_rooms(self): '''Test the type of number_bathrooms''' number_rooms = getattr(self.new_place, "number_rooms") self.assertIsInstance(number_rooms, int) def test_type_description(self): '''Test the type of description''' description = getattr(self.new_place, "description") self.assertIsInstance(description, str) def test_type_name(self): ''' Test the type of name''' name = getattr(self.new_place, "name") self.assertIsInstance(name, str)
class TestUser(unittest.TestCase): ''' Testing Place class ''' def setUp(self): ''' Creates an instance for place. ''' self.new_place = Place() def TearDown(self): pass def test_Place_inheritance(self): ''' tests that the City class Inherits from BaseModel ''' self.assertIsInstance(self.new_place, BaseModel) def test_Place_attributes(self): ''' Checks that the attribute exist. ''' self.assertTrue("city_id" in self.new_place.__dir__()) self.assertTrue("user_id" in self.new_place.__dir__()) self.assertTrue("description" in self.new_place.__dir__()) self.assertTrue("name" in self.new_place.__dir__()) self.assertTrue("number_rooms" in self.new_place.__dir__()) self.assertTrue("max_guest" in self.new_place.__dir__()) self.assertTrue("price_by_night" in self.new_place.__dir__()) self.assertTrue("latitude" in self.new_place.__dir__()) self.assertTrue("longitude" in self.new_place.__dir__()) def test_type_longitude(self): ''' Test the type of longitude. ''' longitude = getattr(self.new_place, "longitude") if longitude: self.assertIsInstance(longitude, float) def test_type_latitude(self): ''' Test the type of latitude ''' latitude = getattr(self.new_place, "latitude") if latitude: self.assertIsInstance(latitude, float) def test_type_price_by_night(self): ''' Test the type of price_by_night ''' price_by_night = getattr(self.new_place, "price_by_night") if price_by_night: self.assertIsInstance(price_by_night, int) def test_type_max_guest(self): ''' Test the type of max_guest ''' max_guest = getattr(self.new_place, "max_guest") if max_guest: self.assertIsInstance(max_guest, int) def test_type_number_bathrooms(self): ''' Test the type of number_bathrooms ''' number_bathrooms = getattr(self.new_place, "number_bathrooms") if number_bathrooms: self.assertIsInstance(number_bathrooms, int) def test_type_number_rooms(self): ''' Test the type of number_bathrooms ''' number_rooms = getattr(self.new_place, "number_rooms") if number_rooms: self.assertIsInstance(number_rooms, int) def test_type_description(self): ''' Test the type of description ''' description = getattr(self.new_place, "description") if description: self.assertIsInstance(description, str) def test_type_name(self): ''' Test the type of name ''' name = getattr(self.new_place, "name") if name: self.assertIsInstance(name, str) def test_type_user_id(self): ''' Test the type of user_id ''' user_id = getattr(self.new_place, "user_id") if user_id: self.assertIsInstance(user_id, str) def test_type_city_id(self): ''' Test the type of city_id ''' city_id = getattr(self.new_place, "city_id") if city_id: self.assertIsInstance(city_id, str) @unittest.skipIf(os.getenv('HBNB_TYPE_STORAGE') == 'db', "skip unless db") def test_Place_inheritence2(self): ''' tests that the Place class Inherits from BaseModel ''' new_place = Place() self.assertIsInstance(new_place, Base)
class TestUser(unittest.TestCase): ''' Testing Place class ''' @classmethod def setUp(cls): ''' Creates an instance for place. ''' self.new_place = Place() cls.new_place.city_id = "6" cls.new_place.user_id = "6" cls.new_place.description = "awesome place" cls.new_place.name = "TheHouse" cls.new_place.number_rooms = 6 cls.new_place.number_bathrooms = 6 cls.new_place.max_guest = 64 cls.new_place.price_by_night = 666 cls.new_place.latitude = 666.888 cls.new_place.longitude = 888.666 cls.new_place.amenity_ids = [] def TearDown(self): pass def test_Place_inheritance(self): ''' tests that the City class Inherits from BaseModel ''' self.assertIsInstance(self.new_place, BaseModel) def test_Place_attributes(self): ''' Checks that the attribute exist. ''' self.assertTrue("city_id" in self.new_place.__dir__()) self.assertTrue("user_id" in self.new_place.__dir__()) self.assertTrue("description" in self.new_place.__dir__()) self.assertTrue("name" in self.new_place.__dir__()) self.assertTrue("number_rooms" in self.new_place.__dir__()) self.assertTrue("max_guest" in self.new_place.__dir__()) self.assertTrue("price_by_night" in self.new_place.__dir__()) self.assertTrue("latitude" in self.new_place.__dir__()) self.assertTrue("longitude" in self.new_place.__dir__()) self.assertTrue("amenity_ids" in self.new_place.__dir__()) def test_type_longitude(self): ''' Test the type of longitude. ''' longitude = getattr(self.new_place, "longitude") self.assertIsInstance(longitude, float) def test_type_latitude(self): ''' Test the type of latitude ''' latitude = getattr(self.new_place, "latitude") self.assertIsInstance(latitude, float) def test_type_amenity(self): ''' Test the type of latitude ''' amenity = getattr(self.new_place, "amenity_ids") self.assertIsInstance(amenity, list) def test_type_price_by_night(self): ''' Test the type of price_by_night ''' price_by_night = getattr(self.new_place, "price_by_night") self.assertIsInstance(price_by_night, int) def test_type_max_guest(self): ''' Test the type of max_guest ''' max_guest = getattr(self.new_place, "max_guest") self.assertIsInstance(max_guest, int) def test_type_number_bathrooms(self): ''' Test the type of number_bathrooms ''' number_bathrooms = getattr(self.new_place, "number_bathrooms") self.assertIsInstance(number_bathrooms, int) def test_type_number_rooms(self): ''' Test the type of number_bathrooms ''' number_rooms = getattr(self.new_place, "number_rooms") self.assertIsInstance(number_rooms, int) def test_type_description(self): ''' Test the type of description ''' description = getattr(self.new_place, "description") self.assertIsInstance(description, str) def test_type_name(self): ''' Test the type of name ''' name = getattr(self.new_place, "name") self.assertIsInstance(name, str) def test_type_user_id(self): ''' Test the type of user_id ''' user_id = getattr(self.new_place, "user_id") self.assertIsInstance(user_id, str) def test_type_city_id(self): ''' Test the type of city_id ''' city_id = getattr(self.new_place, "city_id") self.assertIsInstance(city_id, str)
class TestPlace(unittest.TestCase): ''' Testing Place class ''' def setUp(self): ''' Creates an instance for place. ''' self.new_place = Place() def TearDown(self): pass def test_Place_inheritance(self): ''' tests that the City class Inherits from BaseModel ''' self.assertIsInstance(self.new_place, BaseModel) @unittest.skipIf(getenv('HBNB_TYPE_STORAGE') != 'db', 'Place only inherits from Base when using db') def test_Place_inheritance_db(self): ''' tests that the City class Inherits from Base ''' self.assertIsInstance(self.new_place, Base) def test_Place_attributes(self): ''' Checks that the attribute exist. ''' self.assertTrue("city_id" in self.new_place.__dir__()) self.assertTrue("user_id" in self.new_place.__dir__()) self.assertTrue("description" in self.new_place.__dir__()) self.assertTrue("name" in self.new_place.__dir__()) self.assertTrue("number_rooms" in self.new_place.__dir__()) self.assertTrue("max_guest" in self.new_place.__dir__()) self.assertTrue("price_by_night" in self.new_place.__dir__()) self.assertTrue("latitude" in self.new_place.__dir__()) self.assertTrue("longitude" in self.new_place.__dir__()) @unittest.skipIf(getenv('HBNB_TYPE_STORAGE') == 'db', 'amenity_ids only in JSON file storage') def test_JSON_amenity_attribute(self): self.assertTrue("amenity_ids" in self.new_place.__dir__()) @unittest.skipIf(getenv('HBNB_TYPE_STORAGE') != 'db', 'amenities and review only in db storage') def test_SQL_attribute(self): self.assertTrue("amenities" in self.new_place.__dir__()) self.assertTrue("reviews" in self.new_place.__dir__()) @unittest.skipIf(getenv('HBNB_TYPE_STORAGE') == 'db', 'attributes are NoneType in db') def test_type_longitude(self): ''' Test the type of longitude. ''' longitude = getattr(self.new_place, "longitude") self.assertIsInstance(longitude, float) @unittest.skipIf(getenv('HBNB_TYPE_STORAGE') == 'db', 'attributes are NoneType in db') def test_type_latitude(self): ''' Test the type of latitude ''' latitude = getattr(self.new_place, "latitude") self.assertIsInstance(latitude, float) @unittest.skipIf(getenv('HBNB_TYPE_STORAGE') == 'db', 'amenity_ids only in JSON file storage') def test_type_amenity(self): ''' Test the type of latitude ''' amenity = getattr(self.new_place, "amenity_ids") self.assertIsInstance(amenity, list) @unittest.skipIf(getenv('HBNB_TYPE_STORAGE') == 'db', 'attributes are NoneType in db') def test_type_price_by_night(self): ''' Test the type of price_by_night ''' price_by_night = getattr(self.new_place, "price_by_night") self.assertIsInstance(price_by_night, int) @unittest.skipIf(getenv('HBNB_TYPE_STORAGE') == 'db', 'attributes are NoneType in db') def test_type_max_guest(self): ''' Test the type of max_guest ''' max_guest = getattr(self.new_place, "max_guest") self.assertIsInstance(max_guest, int) @unittest.skipIf(getenv('HBNB_TYPE_STORAGE') == 'db', 'attributes are NoneType in db') def test_type_number_bathrooms(self): ''' Test the type of number_bathrooms ''' number_bathrooms = getattr(self.new_place, "number_bathrooms") self.assertIsInstance(number_bathrooms, int) @unittest.skipIf(getenv('HBNB_TYPE_STORAGE') == 'db', 'attributes are NoneType in db') def test_type_number_rooms(self): ''' Test the type of number_bathrooms ''' number_rooms = getattr(self.new_place, "number_rooms") self.assertIsInstance(number_rooms, int) @unittest.skipIf(getenv('HBNB_TYPE_STORAGE') == 'db', 'attributes are NoneType in db') def test_type_description(self): ''' Test the type of description ''' description = getattr(self.new_place, "description") self.assertIsInstance(description, str) @unittest.skipIf(getenv('HBNB_TYPE_STORAGE') == 'db', 'attributes are NoneType in db') def test_type_name(self): ''' Test the type of name ''' name = getattr(self.new_place, "name") self.assertIsInstance(name, str) @unittest.skipIf(getenv('HBNB_TYPE_STORAGE') == 'db', 'attributes are NoneType in db') def test_type_user_id(self): ''' Test the type of user_id ''' user_id = getattr(self.new_place, "user_id") self.assertIsInstance(user_id, str) @unittest.skipIf(getenv('HBNB_TYPE_STORAGE') == 'db', 'attributes are NoneType in db') def test_type_city_id(self): ''' Test the type of city_id ''' city_id = getattr(self.new_place, "city_id") self.assertIsInstance(city_id, str)