Exemplo n.º 1
0
    def test_user_create_user_with_same_mail(self):
        user = UserModel(user_schema.load(self.user1))
        user.save()

        res = UserService.create(user_schema.load(self.user1))

        self.assertEqual(res.status_code, 400)
Exemplo n.º 2
0
    def create(cls, mysql):
        service = UserService(mysql)

        try:
            user = service.validate_payload_for_creation_and_hydrate()
        except MissingFieldException as error:
            return jsonify({
                'message': str(error),
                'code': error.get_code()
            }), 400
        except ResourceAlreadyExistsException as error:
            return jsonify({
                'message': str(error),
                'code': error.get_code()
            }), 400

        user = service.create(user)

        return cls.get_by_filter(mysql, 'id', user.get_id())
Exemplo n.º 3
0
 def post(self):
     """Register"""
     return UserService.create(request.parsed_obj)
Exemplo n.º 4
0
    def test_user_create(self):
        res = UserService.create(user_schema.load(self.user1))

        self.assertEqual(res.status_code, 201)