Skip to content

Commit

Permalink
Merge branch 'master' into unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjsimpson authored Jan 7, 2019
2 parents 7b51b6b + 784f8c9 commit b00d62e
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 47 deletions.
17 changes: 6 additions & 11 deletions apitester/runtests/static/runtests/js/runtests.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ $(function() {

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

jsonBody = $(runner).find('textarea[name="params"]').val();
operationId = $(runner).find('input[type="hidden"]').val();
order = $(runner).find('input[name="order"]').val();
Expand Down Expand Up @@ -77,13 +76,12 @@ $(function() {
}, function (response) {
t.next().show().fadeOut(1000);
});

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

$('.runner button.forCopy').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();
Expand All @@ -101,15 +99,14 @@ $(function() {
'remark':remark,
'csrfmiddlewaretoken': window.CSRF
}, function (response) {
t.next().show().fadeOut(1000);
$(item_list).clone().appendTo($(item_list));
});

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

$('.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();
Expand All @@ -127,11 +124,9 @@ $(function() {
'remark':remark,
'csrfmiddlewaretoken': window.CSRF
}, function (response) {
t.next().show().fadeOut(1000);
});
setTimeout("window.location.reload(true)",1000);

});
$(item_list).remove();
});
});

$('#checkNone').click(function() {
$('.runner').find('input').prop('checked', false);
Expand Down
69 changes: 36 additions & 33 deletions apitester/runtests/templates/runtests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -136,39 +136,42 @@ <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 %}">
<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">{% 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">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>
<div class="col-xs-12 col-sm-9 result"></div>
</div>
</li>
<div>
<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">{% 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">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>
<div class="col-xs-12 col-sm-9 result"></div>


</div>
</li>
</div>
{% endfor %}
</ul>
</div>
Expand Down
8 changes: 5 additions & 3 deletions apitester/runtests/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ def get_post_or_update(self, method, testconfigs, testconfig_pk, path, data, swa
if field in field_names:
request_body[field] = getattr(testconfigs["selected"], field)
else:
request_body[field] = params["properties"][field].get("example", "")
try:
request_body[field] = params["properties"][field].get("example", "")
except:
request_body[field] = None
params = json.dumps(request_body, indent=4)

return [{
Expand Down Expand Up @@ -329,7 +332,6 @@ def get_context_data(self, **kwargs):
for i in range(num_runs):
result = self.run_test(config)
LOGGER.log(logging.INFO,result)
time.sleep(t)
except APIError as err:
context['messages'].append(err)
return context
Expand Down Expand Up @@ -465,4 +467,4 @@ def deleteJsonBody(request):
profile.is_deleted = 1
profile.save()

return JsonResponse({'state': True})
return JsonResponse({'state': True})

0 comments on commit b00d62e

Please sign in to comment.