diff options
author | thuva4 <tharma.thuva@gmail.com> | 2018-04-09 22:39:43 +0530 |
---|---|---|
committer | thuva4 <tharma.thuva@gmail.com> | 2018-04-13 12:35:09 +0530 |
commit | 83750eee8f8c4af04b258a1f1948f6f65e31ab47 (patch) | |
tree | 316bf6a123429ab84f4ab16de4cad8f710f04688 /testapi/testapi-client/testapiclient/cli/results.py | |
parent | c77cf76cbf31e65aa599f71f33d59abc267b4e50 (diff) |
Add CRUD funtionalities for results in testapiclient
Tests included
Change-Id: If0bcac51391c2f2debd27831f10ef89e417f9ad1
Signed-off-by: thuva4 <tharma.thuva@gmail.com>
Diffstat (limited to 'testapi/testapi-client/testapiclient/cli/results.py')
-rw-r--r-- | testapi/testapi-client/testapiclient/cli/results.py | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/testapi/testapi-client/testapiclient/cli/results.py b/testapi/testapi-client/testapiclient/cli/results.py new file mode 100644 index 0000000..56ea71f --- /dev/null +++ b/testapi/testapi-client/testapiclient/cli/results.py @@ -0,0 +1,100 @@ +import json + +from testapiclient.utils import command +from testapiclient.utils import urlparse + + +def results_url(): + return urlparse.resource_join('results') + + +def result_url(parsed_args): + return urlparse.path_join(results_url(), parsed_args.result_id) + + +class ResultGet(command.Lister): + + def get_parser(self, prog_name): + parser = super(ResultGet, self).get_parser(prog_name) + parser.add_argument('-case', + help='Search results using tesetcase') + parser.add_argument('-build-tag', + help='Search results using build tag') + parser.add_argument('-from', + help='Search results using from date') + parser.add_argument('-last', + help='Search results using last date') + parser.add_argument('-scenario', + help='Search results using scenario') + parser.add_argument('-period', + help='Search results using period') + parser.add_argument('-project', + help='Search results using project') + parser.add_argument('-to', + help='Search results using to') + parser.add_argument('---version', + help='Search results using version') + parser.add_argument('-criteria', + help='Search results using version') + parser.add_argument('-installer', + help='Search results using installer') + parser.add_argument('-pod', + help='Search results using pod') + parser.add_argument('-page', + help='Search results using page') + return parser + + def take_action(self, parsed_args): + columns = ( + '_id', + 'pod_name', + 'project_name', + 'case_name', + 'installer', + 'version', + 'scenario', + 'criteria', + 'start_date' + ) + data = self.app.client_manager.get( + urlparse.query_by(results_url(), + ['case', 'build_tag', 'from', 'last', + 'scenario', 'period', 'project', + 'to', 'version', + 'criteria', 'installer', 'pod', 'page'], + parsed_args)) + return self.format_output(columns, data.get('results', [])) + + +class ResultGetOne(command.ShowOne): + + def get_parser(self, prog_name): + parser = super(ResultGetOne, self).get_parser(prog_name) + parser.add_argument('result_id', + help='Search result by result id') + return parser + + def take_action(self, parsed_args): + return self.format_output( + self.app.client_manager.get(result_url(parsed_args))) + + +class ResultCreate(command.ShowOne): + + def get_parser(self, prog_name): + parser = super(ResultCreate, self).get_parser(prog_name) + parser.add_argument('result', + type=json.loads, + help='Result create request format:\n' + '\'{"project_name" : "","scenario" : "",' + '"stop_date" : "", "case_name" : "",' + '"build_tag" : "", "version" : "",' + '"pod_name" : "" , "criteria" : "",' + '"installer" : "", "start_date" : "",' + '"details" : ""}\'') + return parser + + def take_action(self, parsed_args): + return self.format_output( + self.app.client_manager.post( + results_url(), parsed_args.result)) |