def test_create_to_dict(self): """ test to verified if the dic is created """ user = User() dict_new = user.to_dict() self.assertEqual(type(dict_new), dict)
def test_to_dict_creat(self): """test to_dict method create dictionary with correct att""" user = User() new_dict = user.to_dict() self.assertEqual(type(new_dict), dict) for attr in user.__dict__: self.assertTrue(attr in new_dict) self.assertTrue("__class__" in new_dict)
def test_values_to_dict(self): """test to verified de values in a dic""" user = User() dict_new = user.to_dict() self.assertEqual(dict_new["__class__"], "User") self.assertEqual(type(dict_new["created_at"]), str) self.assertEqual(type(dict_new["updated_at"]), str) self.assertEqual(type(dict_new["id"]), str)
def test_to_dict_result(self): """ Tests the result of the dict """ user = User() new_dict = user.to_dict() self.assertEqual(new_dict["__class__"], "User") self.assertEqual(type(new_dict["created_at"]), str) self.assertEqual(type(new_dict["updated_at"]), str) self.assertEqual(type(new_dict["id"]), str)
def test_to_dict_values(self): """test the values in dict""" time = "%Y-%m-%dT%H:%M:%S.%f" user = User() new_dict = user.to_dict() self.assertEqual(new_dict["__class__"], "User") self.assertEqual(type(new_dict[c]), str) self.assertEqual(type(new_dict[u]), str) self.assertEqual(new_dict[c], user.created_at.strftime(time)) self.assertEqual(new_dict[u], user.updated_at.strftime(time))
def test_str(self): """test that the str method has the correct output""" user = User() string = "[User] ({}) {}".format(user.id, user.to_dict()) self.assertEqual(string, str(user))
def test_to_dict_f(self): """ Tests the dictionary that comes from the father class """ user = User() new_dict = user.to_dict() self.assertEqual(type(new_dict), dict)