From 14ba055e55bf52d98ea76c94cca286fec8864bea Mon Sep 17 00:00:00 2001 From: PengfeiLi0218 Date: Tue, 15 Jan 2019 00:20:30 +0800 Subject: [PATCH 1/6] bugs: --- .../runtests/static/runtests/js/runtests.js | 20 ++++++++++++++----- .../runtests/templates/runtests/index.html | 2 +- apitester/runtests/views.py | 5 +++-- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/apitester/runtests/static/runtests/js/runtests.js b/apitester/runtests/static/runtests/js/runtests.js index 14e25d7..a96e133 100644 --- a/apitester/runtests/static/runtests/js/runtests.js +++ b/apitester/runtests/static/runtests/js/runtests.js @@ -38,14 +38,23 @@ $(function() { }); } + function clearjQueryCache(){ + for (var x in jQuery.cache){ + delete jQuery.cache[x]; + } + } + $('#run').click(function() { $('.result').empty(); var runners = $('.runner'); - for (var i=0; i < runners.length; i++) { - var runner = $(runners[i]); - if (runner.find('input').is(':checked')) { - runTest(runner); - } + var runNum =$('#numRun'); + for(var j=0; j < $(runNum).val(); j++){ + for (var i=0; i < runners.length; i++) { + var runner = $(runners[i]); + if (runner.find('input').is(':checked')) { + runTest(runner); + } + } } }); @@ -75,6 +84,7 @@ $(function() { 'remark':remark, 'csrfmiddlewaretoken': window.CSRF }, function (response) { + clearjQueryCache(); t.next().show().fadeOut(1000); }); }); diff --git a/apitester/runtests/templates/runtests/index.html b/apitester/runtests/templates/runtests/index.html index 3c2173e..1068ba6 100644 --- a/apitester/runtests/templates/runtests/index.html +++ b/apitester/runtests/templates/runtests/index.html @@ -130,7 +130,7 @@

{{ config.name }}

- +
diff --git a/apitester/runtests/views.py b/apitester/runtests/views.py index 6e71c61..825271e 100644 --- a/apitester/runtests/views.py +++ b/apitester/runtests/views.py @@ -418,7 +418,8 @@ def saveJsonBody(request): 'profile_id': profile_id, 'order': order, 'urlpath': urlpath, - 'remark':remark + 'remark':remark, + 'is_deleted':0 } profile_list = ProfileOperation.objects.update_or_create( @@ -451,7 +452,7 @@ def copyJsonBody(request): replica_id = max([profile.replica_id for profile in profile_list])+1 - ProfileOperation.objects.create(profile_id = profile_id, operation_id = operation_id, json_body = json_body, order = order, urlpath = urlpath, remark=remark, replica_id = replica_id) + ProfileOperation.objects.create(profile_id = profile_id, operation_id = operation_id, json_body = json_body, order = order, urlpath = urlpath, remark=remark, replica_id = replica_id, is_deleted=0) return JsonResponse({'state': True}) From 473c50f3b131571939b79a89f6b3dc837c8d2024 Mon Sep 17 00:00:00 2001 From: PengfeiLi0218 Date: Tue, 15 Jan 2019 00:22:18 +0800 Subject: [PATCH 2/6] bugs: --- apitester/runtests/static/runtests/js/runtests.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/apitester/runtests/static/runtests/js/runtests.js b/apitester/runtests/static/runtests/js/runtests.js index a96e133..849ec6e 100644 --- a/apitester/runtests/static/runtests/js/runtests.js +++ b/apitester/runtests/static/runtests/js/runtests.js @@ -38,12 +38,6 @@ $(function() { }); } - function clearjQueryCache(){ - for (var x in jQuery.cache){ - delete jQuery.cache[x]; - } - } - $('#run').click(function() { $('.result').empty(); var runners = $('.runner'); @@ -84,7 +78,6 @@ $(function() { 'remark':remark, 'csrfmiddlewaretoken': window.CSRF }, function (response) { - clearjQueryCache(); t.next().show().fadeOut(1000); }); }); From dbbac945bb0a657b31a1d6aefe500d91ad543256 Mon Sep 17 00:00:00 2001 From: PengfeiLi0218 Date: Tue, 15 Jan 2019 21:22:29 +0800 Subject: [PATCH 3/6] fix the delete algorithm: not reappear any more after deleted --- .../runtests/static/runtests/js/runtests.js | 56 ++++++++++++------- .../runtests/templates/runtests/index.html | 3 + apitester/runtests/views.py | 35 ++++++------ 3 files changed, 56 insertions(+), 38 deletions(-) diff --git a/apitester/runtests/static/runtests/js/runtests.js b/apitester/runtests/static/runtests/js/runtests.js index 849ec6e..44ea8dd 100644 --- a/apitester/runtests/static/runtests/js/runtests.js +++ b/apitester/runtests/static/runtests/js/runtests.js @@ -38,6 +38,29 @@ $(function() { }); } + function deleteTest(runner){ + var item_list = $(runner).parent(); + jsonBody = $(runner).find('textarea[name="params"]').val(); + operationId = $(runner).find('input[type="hidden"]').val(); + order = $(runner).find('input[name="order"]').val(); + urlpath = $(runner).find('input[name="urlpath"]').val(); + replica_id = $(runner).find('input[name="replica_id"]').val(); + remark = $(runner).find('textarea[name="remark"]').val(); + + $.post('/runtests/delete/json_body', { + 'json_body': jsonBody, + 'operation_id': operationId, + 'profile_id' : window.CURRENT_PROFILE_ID, + 'order': order, + 'urlpath': urlpath, + 'replica_id':replica_id, + 'remark':remark, + 'csrfmiddlewaretoken': window.CSRF + }, function (response) { + $(item_list).remove(); + }); + } + $('#run').click(function() { $('.result').empty(); var runners = $('.runner'); @@ -108,28 +131,8 @@ $(function() { }); $('.runner button.forDelete').click(function() { - var t = $(this) var runner = $(this).parent().parent().parent(); - var item_list = $(runner).parent(); - jsonBody = $(runner).find('textarea[name="params"]').val(); - operationId = $(runner).find('input[type="hidden"]').val(); - order = $(runner).find('input[name="order"]').val(); - urlpath = $(runner).find('input[name="urlpath"]').val(); - replica_id = $(runner).find('input[name="replica_id"]').val(); - remark = $(runner).find('textarea[name="remark"]').val(); - - $.post('/runtests/delete/json_body', { - 'json_body': jsonBody, - 'operation_id': operationId, - 'profile_id' : window.CURRENT_PROFILE_ID, - 'order': order, - 'urlpath': urlpath, - 'replica_id':replica_id, - 'remark':remark, - 'csrfmiddlewaretoken': window.CSRF - }, function (response) { - $(item_list).remove(); - }); + deleteTest(runner) }); $('#checkNone').click(function() { @@ -140,6 +143,17 @@ $(function() { $('.runner').find('input').prop('checked', true); }); + $('#removeUncheck').click(function() { + var runners = $('.runner'); + + for (var i=0; i < runners.length; i++) { + var runner = $(runners[i]); + if (!runner.find('input').is(':checked')) { + deleteTest(runner) + } + } + }); + $('#select-testconfig').change(function() { var configPk = $(this).val(); if (configPk) { diff --git a/apitester/runtests/templates/runtests/index.html b/apitester/runtests/templates/runtests/index.html index 1068ba6..4c54a25 100644 --- a/apitester/runtests/templates/runtests/index.html +++ b/apitester/runtests/templates/runtests/index.html @@ -129,6 +129,9 @@

{{ config.name }}

+
+ +
diff --git a/apitester/runtests/views.py b/apitester/runtests/views.py index 825271e..e1b5440 100644 --- a/apitester/runtests/views.py +++ b/apitester/runtests/views.py @@ -73,32 +73,33 @@ def get_post_or_update(self, method, testconfigs, testconfig_pk, path, data, swa try: objs = ProfileOperation.objects.filter( profile_id=testconfig_pk, - operation_id=data[method]['operationId'], - is_deleted=0 + operation_id=data[method]['operationId'] ) except ProfileOperation.DoesNotExist: objs = None request_body = {} urlpath = self.get_urlpath(testconfigs["selected"], path) + if objs is not None and len(objs)>0: objs_list = [] for obj in objs: - params = obj.json_body - order = obj.order - urlpath = obj.urlpath - replica_id = obj.replica_id - remark = obj.remark if obj.remark is not None else data[method]['summary'] - objs_list.append({ - 'urlpath': urlpath, - 'method': method, - 'order': order, - 'params': params, - 'summary': remark, - 'operationId': data[method]['operationId'], - 'replica_id':replica_id, - 'responseCode': 200, - }) + if obj.is_deleted==0: + params = obj.json_body + order = obj.order + urlpath = obj.urlpath + replica_id = obj.replica_id + remark = obj.remark if obj.remark is not None else data[method]['summary'] + objs_list.append({ + 'urlpath': urlpath, + 'method': method, + 'order': order, + 'params': params, + 'summary': remark, + 'operationId': data[method]['operationId'], + 'replica_id':replica_id, + 'responseCode': 200, + }) return objs_list elif method == 'post' or method == 'put': From 9ba802cd52068f2e58aa21e4e44bcbfd36a3b6ef Mon Sep 17 00:00:00 2001 From: PengfeiLi0218 Date: Thu, 24 Jan 2019 20:00:48 +0800 Subject: [PATCH 4/6] bugs: #51 set OAUTH_BASE_URL in local_settings.py --- apitester/apitester/settings.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apitester/apitester/settings.py b/apitester/apitester/settings.py index 764cb03..3cfeea0 100644 --- a/apitester/apitester/settings.py +++ b/apitester/apitester/settings.py @@ -157,6 +157,10 @@ 'handlers': ['console'], 'level': 'INFO', }, + 'apitester':{ + 'handlers': ['console'], + 'level': 'INFO', + } }, } @@ -186,9 +190,11 @@ GATEWAYLOGIN_HAS_CBS = False API_HOST = 'http://127.0.0.1:8080' +#API_HOST = 'https://apisandbox.openbankproject.com' API_BASE_PATH = '/obp/v' API_VERSION = '3.0.0' +OAUTH_BASE_URL='http://127.0.0.1:9090' # Always save session SESSION_SAVE_EVERY_REQUEST = True @@ -210,4 +216,5 @@ # Settings here might use parts overwritten in local settings API_ROOT = API_HOST + API_BASE_PATH + API_VERSION -OAUTH_BASE_URL='http://127.0.0.1:8000' \ No newline at end of file + +#OAUTH_BASE_URL='https://apisandbox.openbankproject.com' \ No newline at end of file From 9596af86480af1210991df70b4508cd104507c8f Mon Sep 17 00:00:00 2001 From: PengfeiLi0218 Date: Thu, 24 Jan 2019 20:05:38 +0800 Subject: [PATCH 5/6] bugs: --- apitester/apitester/settings.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/apitester/apitester/settings.py b/apitester/apitester/settings.py index 3cfeea0..09c764d 100644 --- a/apitester/apitester/settings.py +++ b/apitester/apitester/settings.py @@ -156,10 +156,6 @@ 'obp': { 'handlers': ['console'], 'level': 'INFO', - }, - 'apitester':{ - 'handlers': ['console'], - 'level': 'INFO', } }, } From 58d1ec7db07844959e28541858e1f0427a087f19 Mon Sep 17 00:00:00 2001 From: PengfeiLi0218 Date: Thu, 31 Jan 2019 21:49:11 +0800 Subject: [PATCH 6/6] something wrong in readme file --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 076b7b2..b806074 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,7 @@ API_HOST = '' # Consumer key + secret to authenticate the _app_ against the API # When the app is created on the API, the redirect URL should point to this -# host + /obp, e.g. `http://localhost:8000/obp` +# host + /obp, e.g. `http://localhost:8000` OAUTH_CONSUMER_KEY = '' OAUTH_CONSUMER_SECRET = ''