def test_amenity_save(self): """test_amenity_save test Test instance class """ my_amenity = Amenity() my_amenity.first_name = "Jerry" my_amenity.last_name = "Mouse" my_amenity.email = "*****@*****.**" my_amenity.password = "******" my_amenity.save() self.assertTrue(path.exists("file.json")) os.remove("file.json")
def test_amenity_instance(self): """test_amenity_instance test Test instance class """ my_amenity = Amenity() my_amenity.first_name = "Jerry" my_amenity.last_name = "Mouse" my_amenity.email = "*****@*****.**" my_amenity.password = "******" self.assertEqual(my_amenity.first_name, "Jerry") self.assertEqual(my_amenity.last_name, "Mouse") self.assertEqual(my_amenity.email, "*****@*****.**") self.assertEqual(my_amenity.password, "root")
def test_create_new(self): """tests if valid instance of Amenity is created""" my_amenity = Amenity() my_amenity.first_name = "Betty" my_amenity.last_name = "Holberton" my_amenity.email = "*****@*****.**" my_amenity.password = "******" self.assertEqual(str, type(my_amenity.first_name)) self.assertEqual(str, type(my_amenity.last_name)) self.assertEqual(str, type(my_amenity.email)) self.assertEqual(str, type(my_amenity.password)) self.assertEqual(my_amenity.first_name, "Betty") my_amenity.first_name = "bob" self.assertEqual(my_amenity.first_name, "bob") my_amenity.first_name = "" self.assertEqual(my_amenity.first_name, "")
#!/usr/bin/python3 from models import storage from models.base_model import BaseModel from models.amenity import Amenity all_objs = storage.all() print("-- Reloaded objects --") for obj_id in all_objs.keys(): obj = all_objs[obj_id] print(obj) print("-- Create a new User --") my_user = Amenity() my_user.first_name = "Betty" my_user.last_name = "Holberton" my_user.email = "*****@*****.**" my_user.password = "******" my_user.save() print(my_user) print("-- Create a new User 2 --") my_user2 = Amenity() my_user2.first_name = "John" my_user2.email = "*****@*****.**" my_user2.password = "******" my_user2.save() print(my_user2)