# creation of a City
city = City(state_id=state.id, name="San Francisco")
city.save()

# creation of a User
user = User(email="*****@*****.**", password="******")
user.save()

# creation of 2 Places
place_1 = Place(user_id=user.id, city_id=city.id, name="House 1")
place_1.save()
place_2 = Place(user_id=user.id, city_id=city.id, name="House 2")
place_2.save()

# creation of 3 various Amenity
amenity_1 = Amenity(name="Wifi")
amenity_1.save()
amenity_2 = Amenity(name="Cable")
amenity_2.save()
amenity_3 = Amenity(name="Oven")
amenity_3.save()

# link place_1 with 2 amenities
place_1.amenities.append(amenity_1)
place_1.amenities.append(amenity_2)

# link place_2 with 3 amenities
place_2.amenities.append(amenity_1)
place_2.amenities.append(amenity_2)
place_2.amenities.append(amenity_3)
Example #2
0
 def test_to_dict_updated_at(self):
     """test 'updated_at' is in dictionary returned by to_dict method"""
     a = Amenity()
     a_dictionary = a.to_dict()
     self.assertIn('updated_at', a_dictionary)
Example #3
0
 def test_init_arg(self):
     """pass in arg to new instance"""
     a0 = Amenity(12)
     self.assertEqual(type(a0).__name__, "Amenity")
     self.assertFalse(hasattr(a0, "12"))
Example #4
0
 def test_save_updated_at(self):
     """save method changing updated_at attr to current datetime test"""
     a = Amenity()
     prev_updated_at = a.updated_at
     a.save()
     self.assertNotEqual(prev_updated_at, a.updated_at)
Example #5
0
 def test_class_name_user(self):
     """test __class__ key in dictionary value is State"""
     a = Amenity()
     a_dictionary = a.to_dict()
     self.assertEqual('Amenity', a_dictionary['__class__'])
Example #6
0
 def test_name_default(self):
     """tests default value of name attr"""
     a = Amenity()
     self.assertEqual("", a.name)
Example #7
0
 def test_updated_at(self):
     """created_at attr test"""
     a = Amenity()
     self.assertEqual(datetime, type(a.updated_at))
Example #8
0
 def setUp(cls):
     """setup instance"""
     cls.a1 = Amenity()
     cls.a1.name = "Gym"
Example #9
0
 def test_init_arg(self):
     """pass in arg to new instance"""
     b1 = Amenity(23)
     self.assertEqual(type(b1).__name__, "Amenity")
     self.assertFalse(hasattr(b1, "23"))
Example #10
0
 def test_has_class_attrs(self):
     """
     Testing if class has class variables
     """
     a = Amenity()
     self.assertTrue("name" in dir(a))
 def test_class(self):
     """ Testing if class exists. """
     my_model = Amenity()
     help = "<class 'models.amenity.Amenity'>"
     self.assertEqual(str(type(my_model)), help)
    def test_inheritance(self):
        """Tests if class inherits from BaseModel"""

        amenity_example = Amenity()
        self.assertTrue(issubclass(amenity_example.__class__, BaseModel))
    def test_class_name(self):
        """ tests if the class is named correctly"""

        amenity_example = Amenity()
        self.assertEqual(amenity_example.__class__.__name__, "Amenity")
 def setUpClass(cls):
     """set up for test"""
     cls.amenity = Amenity()
     cls.amenity.name = "Breakfast"
Example #15
0
 def test_dict_to_created_at_attr_type(self):
     """test dict -> instance's created_at attr type"""
     a = Amenity()
     a_dictionary = a.to_dict()
     a2 = Amenity(**a_dictionary)
     self.assertEqual(type(datetime.now()), type(a2.created_at))
Example #16
0
 def test_str_method(self):
     """Tests to see if each method is printing accurately"""
     b1 = Amenity()
     b1printed = b1.__str__()
     self.assertEqual(b1printed,
                      "[Amenity] ({}) {}".format(b1.id, b1.__dict__))
Example #17
0
 def test_amenity_type(self):
     """tests amenity instance is created"""
     a = Amenity()
     self.assertEqual(type(Amenity()), type(a))
Example #18
0
 def test_is_instance(self):
     """ Test inheritance of BaseModel """
     my_user = Amenity()
     self.assertTrue(isinstance(my_user, BaseModel))
Example #19
0
 def test_id(self):
     """id attr test"""
     a = Amenity()
     self.assertEqual(str, type(a.id))
Example #20
0
 def test_field_types(self):
     """ Test type of attributes """
     my_user = Amenity()
     self.assertTrue(type(my_user.name) == str)
Example #21
0
 def test_created_and_updated_at_init(self):
     """created_at and updated_at attrs initialized
     to current datetime test"""
     a = Amenity()
     self.assertEqual(a.created_at, a.updated_at)
Example #22
0
 def setUpClass(cls):
     cls.amenity1 = Amenity()
     cls.amenity1.name = "Hot Tub"
Example #23
0
 def test_class_name(self):
     """test __class__ key in dictionary"""
     a = Amenity()
     a_dictionary = a.to_dict()
     self.assertIn('__class__', a_dictionary)
Example #24
0
 def test_dict_to_instance(self):
     """test dict -> instance"""
     a = Amenity()
     a_dictionary = a.to_dict()
     a2 = Amenity(**a_dictionary)
     self.assertEqual(type(a), type(a2))
Example #25
0
 def test_to_dict_id_str(self):
     """test type of 'id' value is a str"""
     a = Amenity()
     a_dictionary = a.to_dict()
     self.assertEqual(str, type(a_dictionary['id']))
Example #26
0
 def test_dict_to_id_attr_type(self):
     """test dict -> instance's id attr"""
     a = Amenity()
     a_dictionary = a.to_dict()
     a2 = Amenity(**a_dictionary)
     self.assertEqual(str, type(a2.id))
Example #27
0
 def test_to_dict_updated_at_str(self):
     """test type of 'updated_at' value is a str"""
     a = Amenity()
     a_dictionary = a.to_dict()
     self.assertEqual(str, type(a_dictionary['updated_at']))
Example #28
0
 def test_dict_to_created_at_attr(self):
     """test dict -> instance's created_at attr"""
     a = Amenity()
     a_dictionary = a.to_dict()
     a2 = Amenity(**a_dictionary)
     self.assertEqual(a.created_at, a2.created_at)
Example #29
0
 def test_str_method(self):
     """test that each method is printing accurately"""
     a3 = Amenity()
     a3printed = a3.__str__()
     self.assertEqual(a3printed,
                      "[Amenity] ({}) {}".format(a3.id, a3.__dict__))
Example #30
0
 def test_field_types(self):
     """ Test field attributes of user """
     my_Amenity = Amenity()
     self.assertTrue(type(my_Amenity.name) == str)