#!/usr/bin/python # -*- coding: utf-8 -*- # --------------------------------------------------------------------------------------------------------- # Author : Ulrich Carmesin # Source : gitea.ucarmesin.de # --------------------------------------------------------------------------------------------------------- """ this module implements the functionality of a test-step which is defined in the test-specification and is executed by any executer there are 2 kinds of test-step a) execute specific component in the job b) execute specific test-entity in the test-suite-execution """ import basic.constants as B import tools.data_const as D import tools.job_const as J # import utils.i18n_tool LIST_ARGS = [ "start", # for starting the specified main-program "fct" # for calling the specified component-function ] # in specification there are used sequential numbers (testcases: 1..7, testsuites: 1..14, testplan: 1..15) # in job-parameter there are stored unique ids # so there are some mapping-issues: # * start is always 1 in start_dialog - map the id for parametrization # * getNextId depending of granularity # * map def getNextStepID(job, snr=0, sid="", gran=""): if gran == "": gran = getattr(job.par, B.PAR_GRAN) if gran not in [B.SUBJECT_TESTPLAN, B.SUBJECT_TESTSUITE, B.SUBJECT_TESTCASE]: raise Exception("granularty not set in parameter") if sid == "": snr += 1 if gran == B.SUBJECT_TESTCASE: return J.STEPS_TESTCASE[snr - 1] elif gran == B.SUBJECT_TESTSUITE: return J.STEPS_TESTSUITE[snr - 1] elif gran == B.SUBJECT_TESTPLAN: return J.STEPS_TESTPLAN[snr - 1] else: return getNextStepID(job, mapStepIDtoNr(job, sid, gran)) def mapStepIDtoNr(job, sid="", gran=""): if gran == "": gran = getattr(job.par, B.PAR_GRAN) if gran not in [B.SUBJECT_TESTPLAN, B.SUBJECT_TESTSUITE, B.SUBJECT_TESTCASE]: raise Exception("granularty not set in parameter") if sid not in J.STEPS_DEFINITON: raise Exception("step-id does not exist {}".format(sid)) if gran not in J.STEPS_DEFINITON[sid]: raise Exception("step-id {} does not exist in gran {}".format(sid, gran)) return J.STEPS_DEFINITON[sid][gran]