Skip to content

Commit

Permalink
Merge pull request OpenBankProject#27 from PengfeiLi0218/master
Browse files Browse the repository at this point in the history
Bugs fixed and new feature development
  • Loading branch information
simonredfern authored Dec 27, 2018
2 parents 4c0d526 + 7b775e7 commit dbf6236
Show file tree
Hide file tree
Showing 6 changed files with 272 additions and 63 deletions.
2 changes: 1 addition & 1 deletion apitester/base/static/css/bootstrap.min.css

Large diffs are not rendered by default.

26 changes: 23 additions & 3 deletions apitester/runtests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,7 @@ class ProfileOperation(models.Model):
verbose_name="Operation id ",
help_text="Test endpoint opreation id",
blank=True,
null=True,
unique=True,
null=True
)
json_body = models.TextField(
max_length=65535,
Expand All @@ -180,7 +179,7 @@ class ProfileOperation(models.Model):
order = models.IntegerField(
verbose_name="Order",
help_text="Test order",
default=0
default=100
)
urlpath = models.CharField(
max_length=255,
Expand All @@ -190,6 +189,27 @@ class ProfileOperation(models.Model):
null=True,
)

replica_id = models.IntegerField(
verbose_name="Replica id",
help_text="Test Replica id",
default= 1
)

remark = models.CharField(
max_length=255,
verbose_name="remark",
help_text="remark",
blank=True,
null=True,
)

is_deleted = models.IntegerField(
verbose_name="Deleted",
help_text="Deleted",
default=0,
null=False
)

class Meta:
verbose_name = 'Test Profile Operation'
verbose_name_plural = 'Test Profile Operation'
Expand Down
73 changes: 67 additions & 6 deletions apitester/runtests/static/runtests/js/runtests.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@ $(function() {

function runTest(runner) {
//var testpath = runner.data('testpath');
testmethod = runner.data('testmethod');
testconfig_pk = runner.data('testconfig_pk');
operationId = runner.data('operationId');

jsonBody = $(runner).find('textarea[name="params"]').val();
operationId = $(runner).find('input[type="hidden"]').val();
order = $(runner).find('input[name="order"]').val();
replica_id = $(runner).find('input[name="replica_id"]').val();
remark = $(runner).find('textarea[name="remark"]').val();
testmethod = $(runner).find('input[name="method"]').val();
testconfig_pk = $(runner).find('input[name="testconfig_pk"]').val();
path = $(runner).find('input[name="urlpath"]').val();
testpath = 'run/' + testmethod + "/" + path + "/" + testconfig_pk + "/"+ operationId ;
$.post(testpath, {
'num_runs':$(runner).find('input[name="numRun"]').val(),
'json_body': runner.find('textarea').val(),
'csrfmiddlewaretoken': window.CSRF
}, function (data) {
Expand Down Expand Up @@ -50,26 +56,81 @@ $(function() {
runTest(runner);
});
$('.runner button.forSave').click(function() {

var t = $(this)
var runner = $(this).parent().parent().parent();
jsonBody = $(runner).find('textarea').val();
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/save/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) {
t.next().show().fadeOut(1000);
});

setTimeout("window.location.reload()",1000);
setTimeout("window.location.reload(true)",1000);
});

$('.runner button.forCopy').click(function() {
var t = $(this)
var runner = $(this).parent().parent().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/copy/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) {
t.next().show().fadeOut(1000);
});

setTimeout("window.location.reload(true)",1000);
});

$('.runner button.forDelete').click(function() {
var t = $(this)
var runner = $(this).parent().parent().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) {
t.next().show().fadeOut(1000);
});
setTimeout("window.location.reload(true)",1000);

});

$('#checkNone').click(function() {
Expand Down
48 changes: 27 additions & 21 deletions apitester/runtests/templates/runtests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -136,34 +136,40 @@ <h2>{{ config.name }}</h2>

<ul class="hide" id="test-list">
{% for call in calls %}
<li class="runner" data-testpath="{% url 'runtests-run' testmethod=call.method testpath=call.urlpath|urlencode testconfig_pk=testconfig_pk operation_id=call.operationId %}" data-testmethod="{{ call.method }}" data-testconfig_pk="{{ testconfig_pk }}" data-operation_id="{{ call.operationId }}">
<div class="row">
<div class="col-xs-5 col-sm-2">
<div class="checkbox">
<label><input type="checkbox" checked="checked" /> {{ call.summary }}</label><input type="hidden" value="{{ call.operationId }}">
</div>
</div>
<div class="col-xs-4">
<span> {{ call.method |upper}} </span> <input style="display: inline-block;width:85%" class="form-control" type="text" name="urlpath" value="{{ call.urlpath }}">
<li class="runner" data-testpath="{% url 'runtests-run' testmethod=call.method testpath=call.urlpath|urlencode testconfig_pk=testconfig_pk operation_id=call.operationId %}">
<div class="row">
<div class="col-xs-5 col-sm-2">
<div class="checkbox">
<label><input type="checkbox" checked="checked" /> <textarea class="form-control" name="remark" cols="20" rows="5">{{call.summary}}</textarea></label><input type="hidden" value="{{ call.operationId }}">
</div>
</div>
<div class="col-xs-5">
<input class="form-control" type="text" name="urlpath" size="50" value="{{ call.urlpath }}">
<input class="form-control" type="hidden" name="testconfig_pk" size="1" value="{{ testconfig_pk }}" />
</div>
<div class="col-xs-3">
{% if call.method == "post" or call.method == 'put' %}
<textarea class="form-control" name="" id="" cols="30" rows="5">
{{call.params}}
</textarea>
<!--<textarea class="form-control" name="" id="" cols="30" rows="5">{% for key, value in call.params.items %}{{key}}:{{value}}{% endfor %}</textarea>-->
<textarea class="form-control" name="params" id="" cols="20" rows="5">{{call.params}}</textarea>
{% endif %}
</div>
<div class="col-xs-1"><input class="form-control" type="text" name="order" size="1" value="{{ call.order }}" /></div>
<div class="col-xs-1">{{ call.method |upper}}</div>
<div class="col-xs-1">order: <input class="form-control" type="text" name="order" size="1" value="{{ call.order }}" /></div>
<div class="col-xs-1">runs num: <input class="form-control" type="text" name="numRun" size="1" value=1 /></div>
<div class="col-xs-1"><input class="form-control" type="hidden" name="replica_id" size="1" value="{{ call.replica_id }}" /></div>
<div class="col-xs-1">{{ call.method |upper}}<input class="form-control" type="hidden" name="method" size="1" value="{{ call.method }}" /></div>
<div class="col-xs-1 col-sm-1">
<button class="btn btn-default forTest" id="forTest">Test</button>
<button class="btn btn-default forCopy" id="forCopy">Copy</button>
</div>
<div class="col-xs-1 col-sm-1">
<button class="btn btn-success forDelete" id="forDelete">Delete</button>
<button class="btn btn-success forSave" id="forSave">Save</button><span style="display: none;margin-left: 5px;background-color:#00cc00">saved.</span>

<div class="col-xs-2 col-sm-1">
<button class="btn btn-default forTest">Test</button>
<button class="btn btn-success forSave">Save</button><span style="display: none;margin-left: 5px;background-color:#00cc00">saved.</span>
</div>
<div class="col-xs-12 col-sm-9 result"></div>
</div>
</li>
{% endfor %}
<div class="col-xs-12 col-sm-9 result"></div>
</div>
</li>
{% endfor %}
</ul>
</div>
{% endblock content %}
Expand Down
10 changes: 8 additions & 2 deletions apitester/runtests/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
TestConfigurationCreateView,
TestConfigurationUpdateView,
TestConfigurationDeleteView,
saveJsonBody
)
saveJsonBody,
copyJsonBody, deleteJsonBody)


urlpatterns = [
url(r'^$',
Expand All @@ -35,4 +36,9 @@
name='runtests-testconfig-delete'),
url(r'save/json_body', saveJsonBody,
name='runtests-save-json_body'),
url(r'copy/json_body', copyJsonBody,
name='runtests-copy-json_body'),
url(r'delete/json_body', deleteJsonBody,
name='runtests-delete-json_body'),

]
Loading

0 comments on commit dbf6236

Please sign in to comment.