Exemplo n.º 1
0
def insert():
    """
    Validates and inserts user
    """
    new_user = request.json 
    user = UserModel(new_user)
    user.validate()
    unique_fields = [{"email"}]
    repository.insert_one_unique_fields(COLLECTION_NAME, user.to_dict(), unique_fields)
    return {"message": "success!"}, 201
Exemplo n.º 2
0
 def test_to_dict(self):
     correct = {"email": "*****@*****.**", "name": "correct name"}
     new_user = UserModel(correct)
     user_dict = new_user.to_dict()
     self.assertTrue(user_dict["email"] == correct["email"] and user_dict["name"] == correct["name"])