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

            updated_client = ClientService.update_username(
                client.id, 'admin42')
            self.assertEqual(updated_client.id, client.id)

            updated_client = ClientService.update_username(987, 'admin42')
            self.assertEqual(updated_client, None)
예제 #2
0
def update_partial_client(client_id):
    username = request.json['username']

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

    client = ClientService.update_username(client_id, username)

    if client == None:
        abort(404)

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