summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--testapi/opnfv_testapi/handlers/sign_handlers.py2
-rw-r--r--testapi/opnfv_testapi/ui/components/projects/project/project.html22
-rw-r--r--testapi/opnfv_testapi/ui/components/projects/project/projectController.js6
-rw-r--r--testapi/opnfv_testapi/ui/components/scenarios/modals/customModal.html6
-rw-r--r--testapi/testapi-client/setup.cfg4
-rw-r--r--testapi/testapi-client/testapiclient/cli/deployresults.py100
-rw-r--r--testapi/testapi-client/testapiclient/tests/unit/test_deployresults.py109
7 files changed, 226 insertions, 23 deletions
diff --git a/testapi/opnfv_testapi/handlers/sign_handlers.py b/testapi/opnfv_testapi/handlers/sign_handlers.py
index 7540662..2039971 100644
--- a/testapi/opnfv_testapi/handlers/sign_handlers.py
+++ b/testapi/opnfv_testapi/handlers/sign_handlers.py
@@ -46,7 +46,7 @@ class SigninReturnHandler(SignBaseHandler):
dbapi.db_update(self.table, q_user, login_user)
self.clear_cookie(constants.TESTAPI_ID)
- self.set_secure_cookie(constants.TESTAPI_ID, user)
+ self.set_secure_cookie(constants.TESTAPI_ID, user, 1)
self.redirect(url=CONF.ui_url)
diff --git a/testapi/opnfv_testapi/ui/components/projects/project/project.html b/testapi/opnfv_testapi/ui/components/projects/project/project.html
index b6a751c..2762fff 100644
--- a/testapi/opnfv_testapi/ui/components/projects/project/project.html
+++ b/testapi/opnfv_testapi/ui/components/projects/project/project.html
@@ -16,25 +16,11 @@
<div class="table-responsive">
<table class="table" ng-data="ctrl.data.pods">
<tbody>
- <tr style="padding:9px">
- <td class="podsTableTd">Id&nbsp;:</td>
- <td class="podsTableLeftTd">{{ctrl.data._id}}</td>
+ <tr ng-repeat-start="(index, detail) in ctrl.data_field" style="padding:9px">
+ <td class="podsTableTd">{{detail | capitalize}}&nbsp;:</td>
+ <td width="85%" class="podsTableLeftTd">{{ctrl.data[index]}}</td>
</tr>
- <tr style="padding:9px">
- <td class="podsTableTd">Name&nbsp;:</td>
- <td width="90%" class="podsTableLeftTd">{{ctrl.data.name}}</td>
- </tr>
- <tr style="padding:9px">
- <td class="podsTableTd">Creator&nbsp;:</td>
- <td width="90%" class="podsTableLeftTd">{{ctrl.data.creator}}</td>
- </tr>
- <tr style="padding:9px">
- <td class="podsTableTd">Created&nbsp;at&nbsp;:</td>
- <td width="90%" class="podsTableLeftTd">{{ctrl.data['creation_date']}}</td>
- </tr>
- <tr style="padding:9px">
- <td class="podsTableTd">Description&nbsp;:</td>
- <td width="90%" class="podsTableLeftTd">{{ctrl.data.description}}</td>
+ <tr ng-repeat-end=>
</tr>
</tbody>
</table>
diff --git a/testapi/opnfv_testapi/ui/components/projects/project/projectController.js b/testapi/opnfv_testapi/ui/components/projects/project/projectController.js
index 78b805d..9dc9e27 100644
--- a/testapi/opnfv_testapi/ui/components/projects/project/projectController.js
+++ b/testapi/opnfv_testapi/ui/components/projects/project/projectController.js
@@ -21,7 +21,7 @@
ProjectController.$inject = [
'$scope', '$http', '$filter', '$state', '$window', '$uibModal', 'testapiApiUrl','raiseAlert',
- 'confirmModal'
+ 'confirmModal', 'dataFieldService'
];
/**
@@ -30,12 +30,13 @@
* through projects declared in TestAPI.
*/
function ProjectController($scope, $http, $filter, $state, $window, $uibModal, testapiApiUrl,
- raiseAlert, confirmModal) {
+ raiseAlert, confirmModal, dataFieldService) {
var ctrl = this;
ctrl.name = $state.params['name'];
ctrl.url = testapiApiUrl + '/projects/' + ctrl.name;
ctrl.loadDetails = loadDetails;
+ ctrl.data_field = {}
/**
* This will contact the TestAPI to get a listing of declared projects.
@@ -45,6 +46,7 @@
ctrl.projectsRequest =
$http.get(ctrl.url).success(function (data) {
ctrl.data = data;
+ ctrl.data_field = dataFieldService.dataFunction(ctrl.data, ctrl.data_field)
}).catch(function (error) {
ctrl.data = null;
ctrl.showError = true;
diff --git a/testapi/opnfv_testapi/ui/components/scenarios/modals/customModal.html b/testapi/opnfv_testapi/ui/components/scenarios/modals/customModal.html
index 0cd2663..4225749 100644
--- a/testapi/opnfv_testapi/ui/components/scenarios/modals/customModal.html
+++ b/testapi/opnfv_testapi/ui/components/scenarios/modals/customModal.html
@@ -6,14 +6,16 @@
<legend>{{customModalCtrl.data.text}}</legend>
<div class="row">
<div class="update-project">
- <label for="cpid" class="control-label col-sm-4">Custom: </label>
+ <label for="cpid" class="control-label col-sm-2">Custom: </label>
<table cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td>
<div class="col-sm-12">
<input type="text" class="form-control" ng-model="customModalCtrl.custom"/>
- <p class="help-block"></p>
+ <p class="help-block">
+ Please separate multiple customs with space or comma
+ </p>
</div>
</td>
</tr>
diff --git a/testapi/testapi-client/setup.cfg b/testapi/testapi-client/setup.cfg
index 2427c57..b89fba4 100644
--- a/testapi/testapi-client/setup.cfg
+++ b/testapi/testapi-client/setup.cfg
@@ -60,6 +60,10 @@ testapi =
scenario score create = testapiclient.cli.scenarios:ScoreCreate
+ deployresult create = testapiclient.cli.deployresults:DeployresultCreate
+ deployresult get = testapiclient.cli.deployresults:DeployresultGet
+ deployresult getone = testapiclient.cli.deployresults:DeployresultGetOne
+
[egg_info]
tag_build =
tag_date = 0
diff --git a/testapi/testapi-client/testapiclient/cli/deployresults.py b/testapi/testapi-client/testapiclient/cli/deployresults.py
new file mode 100644
index 0000000..a6fe13e
--- /dev/null
+++ b/testapi/testapi-client/testapiclient/cli/deployresults.py
@@ -0,0 +1,100 @@
+import json
+
+from testapiclient.utils import command
+from testapiclient.utils import urlparse
+
+
+def deployresults_url():
+ return urlparse.resource_join('deployresults')
+
+
+def deployresult_url(parsed_args):
+ return urlparse.path_join(deployresults_url(), parsed_args.deployresult_id)
+
+
+class DeployresultGet(command.Lister):
+
+ def get_parser(self, prog_name):
+ parser = super(DeployresultGet, self).get_parser(prog_name)
+ parser.add_argument('-build-id',
+ help='Search deployresults using build tag')
+ parser.add_argument('-from',
+ help='Search deployresults using from date')
+ parser.add_argument('-scenario',
+ help='Search deployresults using scenario')
+ parser.add_argument('-period',
+ help='Search deployresults using period')
+ parser.add_argument('-page',
+ help='Search deployresults using page')
+ parser.add_argument('-to',
+ help='Search deployresults using to')
+ parser.add_argument('---version',
+ help='Search deployresults using version')
+ parser.add_argument('-last',
+ help='Search deployresults using last date')
+ parser.add_argument('-pod-name',
+ help='Search deployresults using pod')
+ parser.add_argument('-criteria',
+ help='Search deployresults using version')
+ parser.add_argument('-installer',
+ help='Search deployresults using installer')
+ parser.add_argument('-job-name',
+ help='Search deployresults using project')
+
+ return parser
+
+ def take_action(self, parsed_args):
+ columns = (
+ '_id',
+ 'pod_name',
+ 'version',
+ 'criteria',
+ 'start_date',
+ 'stop_date',
+ 'scenario',
+ 'installer',
+
+ )
+ data = self.app.client_manager.get(
+ urlparse.query_by(deployresults_url(),
+ ['build_id', 'from', 'last',
+ 'scenario', 'period', 'job_name',
+ 'to', 'version',
+ 'criteria', 'installer', 'pod_name', 'page'],
+ parsed_args))
+ return self.format_output(columns, data.get('deployresults', []))
+
+
+class DeployresultGetOne(command.ShowOne):
+
+ def get_parser(self, prog_name):
+ parser = super(DeployresultGetOne, self).get_parser(prog_name)
+ parser.add_argument('deployresult_id',
+ help='Search deployresult by deployresult id')
+ return parser
+
+ def take_action(self, parsed_args):
+ return self.format_output(
+ self.app.client_manager.get(deployresult_url(parsed_args)))
+
+
+class DeployresultCreate(command.ShowOne):
+
+ def get_parser(self, prog_name):
+ parser = super(DeployresultCreate, self).get_parser(prog_name)
+ parser.add_argument('deployresult',
+ type=json.loads,
+ help='Deployresult create request format:\n'
+ '\'{"job_name" : "","scenario" : "",'
+ '"stop_date" : "", "build_id" : "",'
+ '"upstream_job_name": "",'
+ '"version" : "", "pod_name" : "",'
+ '"criteria" : "", "installer" : "",'
+ '"upstream_build_id" : "",'
+ '"start_date" : "", "details" : ""}\'')
+ return parser
+
+ def take_action(self, parsed_args):
+ return self.format_output(
+ self.app.client_manager.post(
+ deployresults_url(), parsed_args.deployresult))
diff --git a/testapi/testapi-client/testapiclient/tests/unit/test_deployresults.py b/testapi/testapi-client/testapiclient/tests/unit/test_deployresults.py
new file mode 100644
index 0000000..0e0385b
--- /dev/null
+++ b/testapi/testapi-client/testapiclient/tests/unit/test_deployresults.py
@@ -0,0 +1,109 @@
+import json
+
+from mock import mock
+from six.moves.urllib import parse
+import testtools
+
+from testapiclient.cli import deployresults
+from testapiclient.tests.unit import fakes
+from testapiclient.tests.unit import utils
+from testapiclient.utils import clientmanager
+
+
+class DeployresultTest(utils.TestCommand):
+ def setUp(self):
+ super(DeployresultTest, self).setUp()
+ self.base_url = parse.urljoin(self.api_url, 'deployresults')
+ self.deployresult_json = {
+ 'job_name': 'daisy-deploy',
+ 'scenario': 'test-scenario',
+ 'stop_date': '2018-04-09 13:44:53',
+ 'upstream_job_name': 'test-job',
+ 'build_id': 'test-build',
+ 'version': 'test-version',
+ 'pod_name': 'test-pod',
+ 'criteria': 'test-criteria',
+ 'installer': 'test-installer',
+ 'start_date': '2018-04-09 13:44:53',
+ 'details': 'test-details',
+ 'upstream_build_id': 'test-stream'
+ }
+ self.deployresult_string = json.dumps(self.deployresult_json)
+
+
+class DeployresultGetTest(DeployresultTest):
+
+ def setUp(self):
+ super(DeployresultGetTest, self).setUp()
+ self.deployresults_rsp = {'deployresults': [self.deployresult_json]}
+
+ def test_get(self):
+ self.get_mock.return_value = fakes.FakeResponse(
+ data=self.deployresults_rsp)
+ deployresult_get = deployresults.DeployresultGet(
+ self.app, mock.Mock())
+ args = ['-job-name', 'dfs']
+ verifies = [('job_name', 'dfs')]
+ parsed_args = self.check_parser(deployresult_get, args, verifies)
+ deployresult_get.take_action(parsed_args)
+ self.get_mock.assert_called_once_with(
+ self.base_url + '?job_name=dfs',
+ headers=clientmanager.ClientManager.headers)
+
+ def test_get_all(self):
+ self.get_mock.return_value = fakes.FakeResponse(
+ data=self.deployresults_rsp)
+ deployresult_get = deployresults.DeployresultGet(
+ self.app, mock.Mock())
+ args = []
+ verifies = []
+ parsed_args = self.check_parser(deployresult_get, args, verifies)
+ deployresult_get.take_action(parsed_args)
+ self.get_mock.assert_called_once_with(
+ self.base_url,
+ headers=clientmanager.ClientManager.headers)
+
+ def test_get_one(self):
+ self.get_mock.return_value = fakes.FakeResponse(
+ data=self.deployresult_json)
+ deployresult_get_one = deployresults.DeployresultGetOne(
+ self.app, mock.Mock())
+ args = ['def']
+ verifies = [('deployresult_id', 'def')]
+ parsed_args = self.check_parser(
+ deployresult_get_one, args, verifies)
+ deployresult_get_one.take_action(parsed_args)
+ self.get_mock.assert_called_once_with(
+ self.base_url + '/def',
+ headers=clientmanager.ClientManager.headers)
+
+
+class DeployresultCreateTest(DeployresultTest):
+
+ def setUp(self):
+ super(DeployresultCreateTest, self).setUp()
+
+ def test_create_success(self):
+ succ_rsp = {
+ 'href': '{}/{}'.format(self.base_url,
+ self.deployresult_json.get('project_name'))
+ }
+ self.post_mock.return_value = fakes.FakeResponse(data=succ_rsp)
+ deployresult_create = deployresults.DeployresultCreate(
+ self.app, mock.Mock())
+ args = [self.deployresult_string]
+ verifies = [('deployresult', self.deployresult_json)]
+ parsed_args = self.check_parser(deployresult_create, args, verifies)
+ deployresult_create.take_action(parsed_args)
+ self.post_mock.assert_called_once()
+
+ def test_create_failure(self):
+ with testtools.ExpectedException(Exception, 'Create failed: Error'):
+ self.post_mock.return_value = utils.FAKE_FAILURE
+ deployresult_create = deployresults.DeployresultCreate(
+ self.app, mock.Mock())
+ args = [self.deployresult_string]
+ verifies = [('deployresult', self.deployresult_json)]
+ parsed_args = self.check_parser(
+ deployresult_create, args, verifies)
+ deployresult_create.take_action(parsed_args)