diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 3b245634..9690a181 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.1.2 +current_version = 0.1.3 [bumpversion:file:setup.cfg] diff --git a/aquarius/app/assets.py b/aquarius/app/assets.py index c065215a..a0b9bdfc 100644 --- a/aquarius/app/assets.py +++ b/aquarius/app/assets.py @@ -4,7 +4,7 @@ from datetime import datetime import pytz -from flask import Blueprint, jsonify, request +from flask import Blueprint, request from oceandb_driver_interface.search_model import QueryModel, FullTextModel from aquarius.app.dao import Dao @@ -34,7 +34,7 @@ def get_assets(): asset_with_id = dao.get_assets() asset_ids = [a['id'] for a in asset_with_id] resp_body = dict({'ids': asset_ids}) - return jsonify(resp_body), 200 + return _sanitize_record(resp_body), 200 @assets.route('/ddo/', methods=['GET']) @@ -57,7 +57,7 @@ def get_ddo(id): """ try: asset_record = dao.get(id) - return jsonify(asset_record), 200 + return _sanitize_record(asset_record), 200 except Exception as e: logging.error(e) return '"%s asset_id is not in OceanDB' % id, 404 @@ -89,7 +89,7 @@ def get_metadata(id): i = i + 1 if service['type'] == 'Metadata': metadata = asset_record['service'][i] - return jsonify(metadata), 200 + return _sanitize_record(metadata), 200 except Exception as e: logging.error(e) return '"%s asset_id is not in OceanDB' % id, 404 @@ -441,7 +441,9 @@ def get_asset_ddos(): args.append(query) assets_with_id = dao.get_assets() assets_metadata = {a['id']: a for a in assets_with_id} - return jsonify(json.dumps(assets_metadata)), 200 + for i in assets_metadata: + _sanitize_record(i) + return json.dumps(assets_metadata), 200 @assets.route('/ddo/query', methods=['GET']) @@ -482,9 +484,10 @@ def query_text(): offset=int(data.get('offset', 100)), page=int(data.get('page', 0))) query_result = dao.query(search_model) + for i in query_result: _sanitize_record(i) - return jsonify(json.dumps(query_result)), 200 + return json.dumps(query_result), 200 @assets.route('/ddo/query', methods=['POST']) @@ -537,7 +540,7 @@ def query_ddo(): query_result = dao.query(search_model) for i in query_result: _sanitize_record(i) - return jsonify(json.dumps(query_result)), 200 + return json.dumps(query_result), 200 def _sanitize_record(data_record): diff --git a/setup.cfg b/setup.cfg index 71c8599b..8865b15a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.1.2 +current_version = 0.1.3 commit = True tag = True diff --git a/setup.py b/setup.py index 6f27ef31..e09f796a 100644 --- a/setup.py +++ b/setup.py @@ -74,6 +74,6 @@ test_suite='tests', tests_require=test_requirements, url='https://github.com/oceanprotocol/aquarius', - version='0.1.2', + version='0.1.3', zip_safe=False, ) diff --git a/tests/test_api.py b/tests/test_api.py index df9e436f..fb780630 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -83,14 +83,14 @@ def test_query_metadata(client): content_type='application/json') assert len(json.loads(client.post(BaseURLs.BASE_AQUARIUS_URL + '/assets/ddo/query', data=json.dumps({"query": {}}), - content_type='application/json').json)) == 2 + content_type='application/json').data.decode('utf-8'))) == 2 assert len(json.loads(client.post(BaseURLs.BASE_AQUARIUS_URL + '/assets/ddo/query', data=json.dumps({"query": {"id": "did:op:123456789abcdefghi"}}), - content_type='application/json').json)) == 1 + content_type='application/json').data.decode('utf-8'))) == 1 assert len(json.loads(client.get(BaseURLs.BASE_AQUARIUS_URL + '/assets/ddo/query?text=Office', - ).json)) == 2 + ).data.decode('utf-8'))) == 2 assert len(json.loads(client.get(BaseURLs.BASE_AQUARIUS_URL + '/assets/ddo/query?text=112233445566778899', - ).json)) == 1 + ).data.decode('utf-8'))) == 1 client.delete(BaseURLs.BASE_AQUARIUS_URL + '/assets/ddo/%s' % json.loads(post.data.decode('utf-8'))['id']) client.delete( BaseURLs.BASE_AQUARIUS_URL + '/assets/ddo/%s' % json.loads(post2.data.decode('utf-8'))['id'])