Skip to content

Commit 5112892

Browse files
authored
Merge pull request #61 from hongwei1/master
store the whole swagger into data base and tweaked the webpage
2 parents cddc4d9 + 369b14d commit 5112892

File tree

4 files changed

+213
-187
lines changed

4 files changed

+213
-187
lines changed

apitester/runtests/models.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,21 @@ class ProfileOperation(models.Model):
211211
null=False
212212
)
213213

214+
method = models.CharField(
215+
max_length=255,
216+
verbose_name="method",
217+
help_text="method",
218+
blank=True,
219+
null=False
220+
)
221+
222+
save_time = models.CharField(
223+
max_length=255,
224+
verbose_name="save_time",
225+
help_text="save_time",
226+
blank=True,
227+
null=False
228+
)
214229
class Meta:
215230
verbose_name = 'Test Profile Operation'
216231
verbose_name_plural = 'Test Profile Operation'

apitester/runtests/static/runtests/js/runtests.js

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ $(function() {
2222
var msg = '';
2323
var collapse = '';
2424
var text = `<pre>${escapeHTML(data['text'])}</pre>`;
25+
const collapseId = data['config']['operation_id'].replace(/\./g, '_')
2526
if (!data['success']) {
2627
alertType = 'danger';
2728
msg = '<ul>';
@@ -30,10 +31,10 @@ $(function() {
3031
}
3132
msg += '</ul>';
3233
} else {
33-
collapse = `<button type='button' class='btn btn-xs btn-success pull-right' data-toggle='collapse' data-target='#${data['config']['operation_id']}' aria-expanded='false'><span class='glyphicon glyphicon-chevron-right'></span><span class='glyphicon glyphicon-chevron-down'></span></button>"`;
34-
text = `<div id='${data['config']['operation_id']}' class='collapse'>${text}</div>`;
34+
collapse = `<button type='button' class='btn btn-xs btn-success pull-right' data-toggle='collapse' data-target='#${collapseId}' aria-expanded='false'><span class='glyphicon glyphicon-chevron-right'></span><span class='glyphicon glyphicon-chevron-down'></span></button>"`;
35+
text = `<div id='${collapseId}' class='collapse'>${data['text']}</div>`;
3536
}
36-
var result =`<div class='alert alert-${alertType}'><div class='row'><div class='col-xs-10 col-sm-11'>${data['config']['summary']}<br />${data['config']['urlpath']}<br />Took ${data['execution_time']} ms<br />${msg}</div><div class='col-xs-2 col-sm-1'>${collapse}</div></div>${text}</div>`;
37+
var result =`<div class='alert alert-${alertType}'><div class='row'><div class='col-xs-10 col-sm-11'>${data['config']['summary']}<br />${data['config']['urlpath']}<br />Took ${data['execution_time']} ms<br />Status Code: ${data['status_code']}</div><div class='col-xs-2 col-sm-1'>${collapse}</div></div>${text}</div>`;
3738
$(runner.find('.result')).append(result);
3839
});
3940
}
@@ -48,14 +49,14 @@ $(function() {
4849
remark = $(runner).find('textarea[name="remark"]').val();
4950

5051
$.post('/runtests/delete/json_body', {
51-
'json_body': jsonBody,
52-
'operation_id': operationId,
53-
'profile_id' : window.CURRENT_PROFILE_ID,
52+
'json_body': jsonBody,
53+
'operation_id': operationId,
54+
'profile_id' : window.CURRENT_PROFILE_ID,
5455
'order': order,
55-
'urlpath': urlpath,
56-
'replica_id':replica_id,
57-
'remark':remark,
58-
'csrfmiddlewaretoken': window.CSRF
56+
'urlpath': urlpath,
57+
'replica_id':replica_id,
58+
'remark':remark,
59+
'csrfmiddlewaretoken': window.CSRF
5960
}, function (response) {
6061
$(item_list).remove();
6162
});
@@ -90,6 +91,7 @@ $(function() {
9091
urlpath = $(runner).find('input[name="urlpath"]').val();
9192
replica_id = $(runner).find('input[name="replica_id"]').val();
9293
remark = $(runner).find('textarea[name="remark"]').val();
94+
testmethod = $(runner).find('input[name="method"]').val();
9395

9496
$.post('/runtests/save/json_body', {
9597
'json_body': jsonBody,
@@ -99,9 +101,11 @@ $(function() {
99101
'urlpath': urlpath,
100102
'replica_id':replica_id,
101103
'remark':remark,
104+
'method':testmethod,
102105
'csrfmiddlewaretoken': window.CSRF
103106
}, function (response) {
104107
t.next().show().fadeOut(1000);
108+
location.reload();
105109
});
106110
});
107111

@@ -115,6 +119,7 @@ $(function() {
115119
urlpath = $(runner).find('input[name="urlpath"]').val();
116120
replica_id = $(runner).find('input[name="replica_id"]').val();
117121
remark = $(runner).find('textarea[name="remark"]').val();
122+
testmethod = $(runner).find('input[name="method"]').val();
118123

119124
$.post('/runtests/copy/json_body', {
120125
'json_body': jsonBody,
@@ -124,6 +129,7 @@ $(function() {
124129
'urlpath': urlpath,
125130
'replica_id':replica_id,
126131
'remark':remark,
132+
'method':testmethod,
127133
'csrfmiddlewaretoken': window.CSRF
128134
}, function (response) {
129135
$(item_list).clone(true).insertAfter($(item_list));

apitester/runtests/templates/runtests/index.html

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ <h2>{{ config.name }}</h2>
121121
<div class="hide" id="run-buttons">
122122
<div class="row">
123123
<div class="col-xs-12 col-sm-4">
124-
<button class="btn btn-primary form-control" id="run">Test selected</button>
124+
<button class="btn btn-success form-control" id="run">Run all Selected</button>
125125
</div>
126126
<div class="col-xs-12 col-sm-2">
127127
<button class="btn btn-default form-control" id="checkNone" />Uncheck all</button>
@@ -133,7 +133,7 @@ <h2>{{ config.name }}</h2>
133133
<button class="btn btn-default form-control" id="removeUncheck" />Remove uncheck</button>
134134
</div>
135135
<div class="col-xs-2">
136-
<label>runs num: </label><input type="text" id="numRun" size="1" value=1 />
136+
<label>Repeat: </label><input type="text" id="numRun" size="1" value=1 />
137137
</div>
138138
</div>
139139

@@ -163,8 +163,8 @@ <h2>{{ config.name }}</h2>
163163
</div>
164164
</div>
165165
<div class="col-xs-5">
166-
<input class="form-control" type="text" name="urlpath" size="50" value="{{ call.urlpath }}">
167-
<input class="form-control" type="hidden" name="testconfig_pk" size="1" value="{{ testconfig_pk }}" />
166+
<input class="form-control" type="text" name="urlpath" size="50" value="{{call.urlpath}}">
167+
<input class="form-control" type="hidden" name="testconfig_pk" size="1" value="{{testconfig_pk}}" />
168168
</div>
169169
<div class="col-xs-3">
170170
{% if call.method == "post" or call.method == 'put' %}
@@ -184,7 +184,6 @@ <h2>{{ config.name }}</h2>
184184
</div>
185185
<div class="col-xs-12 col-sm-9 result"></div>
186186

187-
188187
</div>
189188
</li>
190189
</div>

0 commit comments

Comments
 (0)