def runTest(testName): global exitCode, DIR_REPORT, exitMsg exitCode = 0 DIR_REPORT = os.path.join(DIR_REPORT, testName) util_core.mkdir(DIR_REPORT) util_core.clearDirectory(DIR_REPORT, recursive) # Check if file is already reachable using the file name given. try: initDriver() logging.debug('\nTEST:\tName=%s' % (testName)) logging.debug('Processing: %s' % (testName)) testPath = os.path.join(DIR_TEST, testName+'.'+EXT_TEST) testObject = util_core.loadTestfile(testPath) logging.info("TEST:\tTest File Loaded! %s" % testName) util_core.displayTest(testObject) executeTest(testName, testObject) exitMsg = 'Test processed with overall status: %s' % (exitCode) except: exitCode = PYSEL_SEV1 logging.critical("ERROR!") logging.error(traceback.format_exc()) finally: quitDriver() endSummary(DIR_REPORT) return exitCode
def create_exec(testObject): execObject = testObject os.system("clear") _displayBanner("EXEC", Style.BRIGHT + Fore.RED) print "\nCurrent Test:" util_core.displayTest(testObject) print "\nPlease Enter the Range of Steps to execute:" startIndex = max(int(raw_input("Enter number of first step: ")) - 1, 0) endIndex = min(int(raw_input("Enter number of last step: ")), len(testObject["steps"])) numSteps = endIndex - startIndex execObject["steps"] = testObject["steps"][startIndex:numSteps] os.system("clear") _displayBanner("EXEC", Style.BRIGHT + Fore.RED) print "\nCurrent Test:" util_core.displayTest(execObject) choices = ["execute"] choice = _promptChoice(choices) testSteps = testObject.get("steps") if choice and choice == "execute": for step in testSteps: status = _execStep(step) return testObject
def runTest(testName): global exitCode, DIR_REPORT, exitMsg exitCode = 0 DIR_REPORT = os.path.join(DIR_REPORT, testName) util_core.mkdir(DIR_REPORT) util_core.clearDirectory(DIR_REPORT, recursive) # Check if file is already reachable using the file name given. try: initDriver() logging.debug('\nTEST:\tName=%s' % (testName)) logging.debug('Processing: %s' % (testName)) testPath = os.path.join(DIR_TEST, testName + '.' + EXT_TEST) testObject = util_core.loadTestfile(testPath) logging.info("TEST:\tTest File Loaded! %s" % testName) util_core.displayTest(testObject) executeTest(testName, testObject) exitMsg = 'Test processed with overall status: %s' % (exitCode) except: exitCode = PYSEL_SEV1 logging.critical("ERROR!") logging.error(traceback.format_exc()) finally: quitDriver() endSummary(DIR_REPORT) return exitCode
def create_exec(testObject): execObject = testObject os.system('clear') _displayBanner("EXEC", Style.BRIGHT + Fore.RED) print "\nCurrent Test:" util_core.displayTest(testObject) print "\nPlease Enter the Range of Steps to execute:" startIndex = max(int(raw_input("Enter number of first step: ")) - 1, 0) endIndex = min(int(raw_input("Enter number of last step: ")), len(testObject["steps"])) numSteps = endIndex - startIndex execObject["steps"] = testObject["steps"][startIndex:numSteps] os.system('clear') _displayBanner("EXEC", Style.BRIGHT + Fore.RED) print "\nCurrent Test:" util_core.displayTest(execObject) choices = ["execute"] choice = _promptChoice(choices) testSteps = testObject.get('steps') if choice and choice == "execute": for step in testSteps: status = _execStep(step) return testObject
def create_review(testObject): defaultObject = testObject while True: os.system("clear") _displayBanner("REVIEW", Style.BRIGHT + Fore.CYAN) _displayHelp("review") print "\nCurrent Test:" util_core.displayTest(testObject) choices = ["delete", "commit"] choice = _promptChoice(choices) if not choice: return defaultObject if choice == "commit": return testObject if choice == "delete": stepDel = int(raw_input("Enter Step to Delete: ")) - 1 try: del testObject["steps"][stepDel] except Exception, e: raiseError("Error deleteing step (%s)" % stepDel, e)
def create_review(testObject): defaultObject = testObject while True: os.system('clear') _displayBanner("REVIEW", Style.BRIGHT + Fore.CYAN) _displayHelp("review") print "\nCurrent Test:" util_core.displayTest(testObject) choices = ["delete", "commit"] choice = _promptChoice(choices) if not choice: return defaultObject if choice == "commit": return testObject if choice == "delete": stepDel = int(raw_input("Enter Step to Delete: ")) - 1 try: del testObject["steps"][stepDel] except Exception, e: raiseError("Error deleteing step (%s)" % stepDel, e)
def create_import(testObject): defaultObject = testObject importData = {"steps": []} while True: os.system("clear") _displayBanner("IMPORT", Style.BRIGHT + Fore.BLUE) _displayHelp("import") print "\nCurrent Import Data:" util_core.displayTest(importData) choices = ["open", "setRange", "importData"] choice = _promptChoice(choices) if not choice: return defaultObject # OPEN: display available files for import if choice == "open": testList = util_core.getTestList(TEST_BASE_DIR) util_core.drawTestTable(testList) testIndex = int(raw_input("Enter Number of test to import: ")) - 1 print Fore.YELLOW + "Loading Test.." + Style.RESET_ALL try: testPath = testList[testIndex] importData = util_core.loadTestfile(testPath) except Exception, e: raiseError("Error loading test", e) # SETRANGE: Prunes the steps of importData to the range specified if choice == "setRange": startIndex = max(int(raw_input("Enter number of first step to include (start step): ")) - 1, 0) endIndex = min( int(raw_input("Enter number of last step to include (end step): ")), len(importData["steps"]) ) numSteps = endIndex - startIndex importData["steps"] = importData["steps"][startIndex:numSteps] # IMPORTDATA: Imports the test above or below a particular test number if choice == "importData": os.system("clear") _displayBanner("IMPORT", Style.BRIGHT + Fore.BLUE) print "\nCurrent Test:" util_core.displayTest(testObject) print "\nCurrent Import Data:" util_core.displayTest(importData) posChoices = ["before", "after"] choice = _promptChoice(posChoices, lType="Insert_Position") if choice: try: importIndex = int(raw_input("Enter Index to insert import data %s: " % choice)) if choice == "before": importIndex = max(importIndex - 1, 0) stepInserts = importData["steps"] for stepInsert in reversed(stepInserts): testObject["steps"].insert(importIndex, stepInsert) os.system("clear") _displayBanner("IMPORT", Style.BRIGHT + Fore.BLUE) print Fore.GREEN + "Import Successful!" print "\nCurrent Test:" util_core.displayTest(testObject) comChoices = ["commit"] comChoice = _promptChoice(comChoices) if comChoice and comChoice == "commit": return testObject except Exception, e: raiseError("Error importing test!", e)
def create_import(testObject): defaultObject = testObject importData = {"steps": []} while True: os.system('clear') _displayBanner("IMPORT", Style.BRIGHT + Fore.BLUE) _displayHelp("import") print "\nCurrent Import Data:" util_core.displayTest(importData) choices = ["open", "setRange", "importData"] choice = _promptChoice(choices) if not choice: return defaultObject # OPEN: display available files for import if choice == "open": testList = util_core.getTestList(TEST_BASE_DIR) util_core.drawTestTable(testList) testIndex = int(raw_input("Enter Number of test to import: ")) - 1 print Fore.YELLOW + "Loading Test.." + Style.RESET_ALL try: testPath = testList[testIndex] importData = util_core.loadTestfile(testPath) except Exception, e: raiseError("Error loading test", e) # SETRANGE: Prunes the steps of importData to the range specified if choice == "setRange": startIndex = max( int( raw_input( "Enter number of first step to include (start step): ") ) - 1, 0) endIndex = min( int( raw_input( "Enter number of last step to include (end step): ")), len(importData["steps"])) numSteps = endIndex - startIndex importData["steps"] = importData["steps"][startIndex:numSteps] # IMPORTDATA: Imports the test above or below a particular test number if choice == "importData": os.system("clear") _displayBanner("IMPORT", Style.BRIGHT + Fore.BLUE) print "\nCurrent Test:" util_core.displayTest(testObject) print "\nCurrent Import Data:" util_core.displayTest(importData) posChoices = ["before", "after"] choice = _promptChoice(posChoices, lType="Insert_Position") if choice: try: importIndex = int( raw_input("Enter Index to insert import data %s: " % choice)) if choice == "before": importIndex = max(importIndex - 1, 0) stepInserts = importData["steps"] for stepInsert in reversed(stepInserts): testObject["steps"].insert(importIndex, stepInsert) os.system("clear") _displayBanner("IMPORT", Style.BRIGHT + Fore.BLUE) print Fore.GREEN + "Import Successful!" print "\nCurrent Test:" util_core.displayTest(testObject) comChoices = ["commit"] comChoice = _promptChoice(comChoices) if comChoice and comChoice == "commit": return testObject except Exception, e: raiseError("Error importing test!", e)