external/testopia: Modify commands to get Product and Environment
PATCH 1/4 external/testopia: Modify commands to get Product and Environment
From: Jose Perez Carranza <[email protected]>
Modify commands to get Product and Environment name providing the ID.
--- external/testopia.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
external/testopia.py +2 -2
@@ -627,7 +627,7 @@ class Testopia(object): Result: The product name for the respective id or empty string if an error occurs. """ - return self.do_command("Product.lookup_name_by_id", [self._number_noop(id)]) + return self.do_command("TestopiaProduct.get", [self._number_noop(id)]) def product_get_milestones(self, product_id):
@@ -1629,7 +1629,7 @@ class Testopia(object): Result: The TestRun environment name for the respective id or empty string if an error occurs. """ - return self.do_command("TestRun.lookup_environment_name_by_id", [self._number_noop(id)]) + return self.do_command("Environment.get", [self._number_noop(id)]) ############################## TestCaseRun ##################################
Signature · 1 line
2.11.0
PATCH 2/4 poduct/init: Add functions to get product and environment names
From: Jose Perez Carranza <[email protected]>
Add functions as follows:
- get_test_plan_by_id : Get test plan providing the plan ID
- get_product_name: Get product name providing the product ID
- get_environment_by_id: Get environment providing the environment ID
--- testopia_update/product/__init__.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
testopia_update/product/__init__.py +17 -0
@@ -32,6 +32,17 @@ class Product(object): return tp + def get_test_plan_by_id(self, plan_id): + tp = self.testopia.testplan_get(plan_id) + + return tp + + def get_product_name(self, product_id): + prod_name = self.testopia.product_lookup_name_by_id(product_id) + + return prod_name + + def get_environment(self, tp, env_name): tp_envs = self.testopia.product_get_environments(tp['product_id']) for tp_env in tp_envs:
@@ -47,6 +58,12 @@ class Product(object): tp_envs = self.testopia.product_get_environments(tp['product_id']) return [tp_env['name'] for tp_env in tp_envs] + def get_environment_by_id(self, env_id): + environment_id = self.testopia.testrun_lookup_environment_name_by_id(env_id) + + return environment_id + + def _format_build_name(self, project_version, project_revision): return "%s: %s" % (project_version, project_revision)
Signature · 1 line
2.11.0
PATCH 3/4 testopia_update/utils: Add utils directory
In reply to [email protected]From: Jose Perez Carranza <[email protected]>
Add utils directory to be used as the repository for different utilities
-wikimaker.py : scripts that creates the wiki report data saves it to the data inside a file to be copied on the already created wiki page
--- testopia_update/utils/__init__.py | 0 testopia_update/utils/wikimaker.py | 203 +++++++++++++++++++++++++++++++++++++ 2 files changed, 203 insertions(+) create mode 100644 testopia_update/utils/__init__.py create mode 100644 testopia_update/utils/wikimaker.py
testopia_update/utils/__init__.py new file +0 -0
testopia_update/utils/wikimaker.py new file +203 -0
203 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH 4/4 testopia_update: Add support to create_wiki functionality
In reply to [email protected]From: Jose Perez Carranza <[email protected]>
Add option that allows using –create-wiki under setup option,this potion takes date and project as a parameter and search for tests runs and generates the wiki report data in a file.
--- testopia_update.py | 78 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 58 insertions(+), 20 deletions(-)
testopia_update.py +58 -20
@@ -8,6 +8,7 @@ import ConfigParser from external.testopia import Testopia from testopia_update.product import get_products, get_product_class +from testopia_update.utils.wikimaker import create_wiki DEFAULT_CONFIG_FILE = "testopia_update.config" DEFAULT_STORE_LOCATION = "/tmp/testopia_update"
@@ -153,6 +154,10 @@ def get_args(): 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('--create-wiki', required=False, + dest="create_wiki", help='create a wiki page for the final report of \ + the QA test cycle (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')
@@ -204,34 +209,67 @@ if __name__ == '__main__': 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'] + if args.clone_templates: + setup_opts = ['clone_templates', 'project_version','branch_name', + 'old_project_version', 'product_name'] - load_opts(args, setup_opts, opts) + load_opts(args, setup_opts, opts) + + product = get_product_class(args.product_name, products) + test_plan = product.get_test_plan(args.branch_name) + temp_summary = 'TRTEMP_' + args.old_project_version + temp_list = product.get_test_run_list(test_plan,temp_summary) + if not temp_list: + logger.error("%s: No templates found with %s string on %s" + % (sys.argv[0], temp_summary, args.branch_name)) + + for tr in temp_list: + if args.new_branch and args.new_branch != args.branch_name: + kwargs['new_branch'] = args.new_branch + + new_template = product.clone_template(tr, + args.old_project_version,args.project_version, + **kwargs) + + logger.info("%s: Template was created with (%d), Summary (%s)" + % (sys.argv[0], new_template['run_id'], + new_template['summary'])) + + elif args.create_wiki: + setup_opts = ['create_wiki', 'project_date', 'project_version'] + + load_opts(args, setup_opts, opts) + + args.product_name = 'Dummy' + product = get_product_class(args.product_name, products) + summary = args.project_date + '_' + args.project_version + + templates = product.get_test_run_list(None, summary) + wikivars = '' + wikivars_list = [] + idx=0 + for t in templates: + idx += 1 + plan = product.get_test_plan_by_id(t['plan_id']) + prod = testopia.product_lookup_name_by_id(plan['product_id']) + env = product.get_environment_by_id(t['environment_id']) + env_name = env['name'].replace(' ','_') + var = str(idx) + '_' + str(prod['name']) + '_' + env_name + wikivars_list.append(var) + wikivars += ''.join(["{{#vardefine:", var, '| ', + str(t['run_id']), '}}', '\n' ]) + + print(wikivars) + create_wiki(wikivars, wikivars_list) - product = get_product_class(args.product_name, products) - test_plan = product.get_test_plan(args.branch_name) - temp_summary = 'TRTEMP_' + args.old_project_version - temp_list = product.get_test_run_list(test_plan,temp_summary) - if not temp_list: - logger.error("%s: No templates found with %s string on %s" - % (sys.argv[0], temp_summary, args.branch_name)) - - for tr in temp_list: - if args.new_branch and args.new_branch != args.branch_name: - kwargs['new_branch'] = args.new_branch - - new_template = product.clone_template(tr, args.old_project_version, - args.project_version, **kwargs) - logger.info("%s: Template was created with (%d), Summary (%s)" - % (sys.argv[0], new_template['run_id'], - new_template['summary'])) sys.exit(0)
Signature · 1 line
2.11.0