summaryrefslogtreecommitdiffstats
path: root/cvp
diff options
context:
space:
mode:
Diffstat (limited to 'cvp')
-rw-r--r--cvp/3rd_party/static/testapi-ui/components/application/application.html2
-rw-r--r--cvp/3rd_party/static/testapi-ui/components/results/resultsController.js31
-rw-r--r--cvp/opnfv_testapi/resources/result_handlers.py7
3 files changed, 25 insertions, 15 deletions
diff --git a/cvp/3rd_party/static/testapi-ui/components/application/application.html b/cvp/3rd_party/static/testapi-ui/components/application/application.html
index acf8ea3e..bb79340a 100644
--- a/cvp/3rd_party/static/testapi-ui/components/application/application.html
+++ b/cvp/3rd_party/static/testapi-ui/components/application/application.html
@@ -159,7 +159,7 @@ urpose. Once we understand more about your product or service, we can determine
</div>
</div>
<div class="Actions">
- <a class="btn btn-success cvp-btn medium accent-color regular-button" ng-click="ctrl.openConfirmModal()" />submit</a>
+ <button class="btn btn-success cvp-btn" ng-click="ctrl.openConfirmModal()">Submit</button>
</div>
<div class="results-table" style="margin-top:30px;overflow:scroll">
<table class="table table-striped table-hover">
diff --git a/cvp/3rd_party/static/testapi-ui/components/results/resultsController.js b/cvp/3rd_party/static/testapi-ui/components/results/resultsController.js
index 4476618c..0b0bbbc8 100644
--- a/cvp/3rd_party/static/testapi-ui/components/results/resultsController.js
+++ b/cvp/3rd_party/static/testapi-ui/components/results/resultsController.js
@@ -254,23 +254,28 @@
$http.post(uploadUrl, fd, {
transformRequest: angular.identity,
headers: {'Content-Type': undefined}
- })
- .success(function(data){
+ }).then(function(data){
+
+ if(data.data.code && data.data.code != 0){
+ alert(data.data.msg);
+ return;
+ }
+
ctrl.uploadState = "";
- data.filename = file.name;
+ data.data.filename = file.name;
var createTestUrl = testapiApiUrl + "/tests"
- $http.post(createTestUrl, data)
- .success(function(data, status){
- if (data.code && data.code != 0) {
- alert(data.msg);
- } else {
- ctrl.update();
- }
+
+ $http.post(createTestUrl, data.data).then(function(data){
+ if (data.data.code && data.data.code != 0) {
+ alert(data.data.msg);
+ } else {
+ ctrl.update();
+ }
+ }, function(error){
});
- })
- .error(function(data, status){
- ctrl.uploadState = "Upload failed. Error code is " + status;
+ }, function(error){
+ ctrl.uploadState = "Upload failed. Error code is " + error.status;
});
}
diff --git a/cvp/opnfv_testapi/resources/result_handlers.py b/cvp/opnfv_testapi/resources/result_handlers.py
index 8cb9a347..2e65ba44 100644
--- a/cvp/opnfv_testapi/resources/result_handlers.py
+++ b/cvp/opnfv_testapi/resources/result_handlers.py
@@ -248,7 +248,12 @@ class ResultsUploadHandler(ResultsCLHandler):
fileinfo = self.request.files['file'][0]
tar_in = tarfile.open(fileobj=io.BytesIO(fileinfo['body']),
mode="r:gz")
- results = tar_in.extractfile('results/results.json').read()
+ try:
+ results = tar_in.extractfile('results/results.json').read()
+ except KeyError:
+ msg = 'Uploaded results must contain at least one passing test.'
+ self.finish_request({'code': 403, 'msg': msg})
+ return
results = results.split('\n')
result_ids = []
for result in results: