예제 #1
0
    def test_update(self):
        with self.current_api.app_context():
            ClientService.add('admin1', '*****@*****.**')
            client = ClientService.get_by_email('*****@*****.**')

            updated_client = ClientService.update(client.id, 'admin42',
                                                  '*****@*****.**')
            self.assertEqual(updated_client.id, client.id)

            updated_client = ClientService.update(987, 'admin42',
                                                  '*****@*****.**')
            self.assertEqual(updated_client, None)
예제 #2
0
def update_user(client_id):

    username = request.json['username']
    email = request.json['email']

    if ClientService.get_by_username(username):
        return jsonify({'error': 'This username already exists!'})

    if ClientService.get_by_email(email):
        return jsonify({'error': 'This email already exists!'})

    client = ClientService.update(client_id, username, email)

    if client == None:
        abort(404)

    client_schema = ClientSchema()
    return client_schema.jsonify(client)