testopia_update: Add functionality to list templates
PATCH 1/1 testopia_update: Add functionality to list templates
From: Jose Perez Carranza <[email protected]>
Add support to list available templates per specific releases
Signed-off-by Jose Perez Carranza <[email protected]>
--- testopia_update.py | 18 ++++++++++++++++-- testopia_update/product/__init__.py | 9 +++++++-- 2 files changed, 23 insertions(+), 4 deletions(-)
testopia_update.py +16 -2
@@ -109,6 +109,8 @@ def get_args(): parser.add_argument('--list-products', required=False, action="store_true", dest="list_products", default=False, help='List available products.') + parser.add_argument('--list-templates', required=False, action="store_true", + dest="list_templates", default=False, help='List available templates.') parser.add_argument('-a', '--action', required=False, dest='action', choices=ACTIONS,
@@ -148,8 +150,8 @@ def get_args(): dest="old_project_version", help='Version of the project to clone from') parser.add_argument('--clone-templates', required=False, - dest="clone_templates", help='clone templates from one brnach to \ - another or same branch (only avaibale) \ + dest="clone_templates", help='clone templates from one branch to \ + another or same branch (only available) \ with setup action', const='Y', nargs='?') parser.add_argument('--new-branch', required=False, dest="new_branch", help='New branch to clone the Templates')
@@ -195,6 +197,18 @@ if __name__ == '__main__': print("%s\n" % p.name) sys.exit(0) + if args.list_templates: + if not args.project_version: + logger.error("--project-version should be specified") + else: + args.product_name = 'Dummy' + product = get_product_class(args.product_name, products) + summary = 'TRTEMP_' + args.project_version + templates = product.get_test_run_list(None, summary) + for t in templates: + print ("%s - %s " % (t['run_id'], t['summary'])) + sys.exit(0) + if args.action == 'setup': setup_opts = ['clone_templates', 'project_version','branch_name', 'old_project_version', 'product_name']
testopia_update/product/__init__.py +7 -2
@@ -216,8 +216,13 @@ class Product(object): return tr_id def get_test_run_list(self, test_plan, temp_summary): - list_test_runs = self.testopia.testrun_list(plan_id=test_plan['plan_id'], - summary=temp_summary) + try: + plan_id = test_plan['plan_id'] + except: + plan_id = test_plan + + list_test_runs = self.testopia.testrun_list(plan_id, + summary=temp_summary) return list_test_runs
Signature · 1 line
2.11.0