def test_can_dump_user(self):
     user = TestObjects().get_test_user()
     formatter = ModelFormatter()
     model_as_dict = formatter.model_to_dict(user, include=["_id", "email", "account"])
     assert("password" not in model_as_dict)
     assert("_id" in model_as_dict)
     model_as_dict = formatter.model_to_dict(user, include=["_id", "email", "account", "password"])
     assert("password" in model_as_dict)
 def test_can_dump_user(self):
     user = TestObjects().get_test_user()
     formatter = ModelFormatter()
     model_as_dict = formatter.model_to_dict(
         user, include=["_id", "email", "account"])
     assert ("password" not in model_as_dict)
     assert ("_id" in model_as_dict)
     model_as_dict = formatter.model_to_dict(
         user, include=["_id", "email", "account", "password"])
     assert ("password" in model_as_dict)
 def test_can_load_user(self):
     user = TestObjects().get_test_user()
     formatter = ModelFormatter()
     model_as_dict = formatter.model_to_dict(user, include=["_id", "email", "account"])
     model = formatter.dict_to_model(User, model_as_dict)
     assert(model.id == user.id)
     assert(model.email == user.email)
 def test_can_load_user(self):
     user = TestObjects().get_test_user()
     formatter = ModelFormatter()
     model_as_dict = formatter.model_to_dict(
         user, include=["_id", "email", "account"])
     model = formatter.dict_to_model(User, model_as_dict)
     assert (model.id == user.id)
     assert (model.email == user.email)
Exemple #5
0
 def model_to_dict(self, object_as_model, include=None, exclude=None):
     timer_dict = ModelFormatter.model_to_dict(self, object_as_model, include, exclude)
     timer_dict["id"] = None
     if object_as_model.id is not None:
         timer_dict["id"] = str(object_as_model.id)
     #timer_dict["dateEntered"] = str(object_as_model.dateEntered)
     timer_dict["dateEntered"] = self.fmt_date(object_as_model.dateEntered)
     timer_dict["lastRestart"] = str(object_as_model.lastRestart)
     return timer_dict
 def test_can_convert_user_to_dict_using_model_formatter(self):
     user = TestObjects().get_test_user()
     formatter = ModelFormatter()
     user_dict = formatter.model_to_dict(user)
     # This won't pass because we're using base class implementation
     # assert(user_dict["account"]["name"] == user.account.name)
     #assert(user_dict["confirmed_at"] == None)
     # Important!!! make sure we can convert to JSON:
     as_json = dumps(user_dict)
     assert(isinstance(as_json, str))
 def test_can_convert_user_to_dict_using_model_formatter(self):
     user = TestObjects().get_test_user()
     formatter = ModelFormatter()
     user_dict = formatter.model_to_dict(user)
     # This won't pass because we're using base class implementation
     # assert(user_dict["account"]["name"] == user.account.name)
     #assert(user_dict["confirmed_at"] == None)
     # Important!!! make sure we can convert to JSON:
     as_json = dumps(user_dict)
     assert (isinstance(as_json, str))