from __builtin__ import str from rfaUtils import getLog, qaPrint, getLocalEnv, getTestCases, closeLog, getArguments # process command line arguments arguments = getArguments(sys.argv) # read properties localProperties = getLocalEnv('local.properties') if localProperties == -1: sys.exit('[ERROR]Could not read properties') if 'log_dir' not in localProperties.keys(): sys.exit("[ERROR]log_dir property is missing") # get the log file handle log = getLog(arguments['testName'], localProperties['log_dir']) # exit if log creation failed if log == -1: sys.exit("[ERROR]Could not create log file") qaPrint(log, "[INFO]Test suite starts") # read test cases test_cases = getTestCases(arguments['trid'], log) if test_cases == -1: qaPrint(log, '[ERROR]Could not read test cases') closeLog(log) sys.exit() else: qaPrint(log,
''' Created on Oct 19, 2016 @author: sashaalexander @author: team X ''' from rfaUtils import getLog, qaPrint import sys # get the log file handle log = getLog() # exit if log creation failed if log == -1: sys.exit("Unable to create log file") message = "It is working, right?" # call qaPrint to print a message with timestamp and write it to the log file qaPrint(log, message) qaPrint(log, "Me like what me see") # close the log file if it open if not log.closed: log.close()
# exit if dictionary of testrun properties failed if testrun_properties == -1: sys.exit("Unable to open " + properties_file + " file or invalid format of the file content, the required format is key=value.") # exit if key or value in dictionary does't exist def usage(key): try: if testrun_properties[key]: return testrun_properties[key] else: return sys.exit("Value of " + key + " is not found. Check parameters in " + properties_file + " file." ) except KeyError: return sys.exit("Key " + key + " is not found. Check parameters in " + properties_file + " file." ) # getting the log file handle log = getLog(usage('log_dir'), getAppName()) # exit if log creation failed if log == -1: sys.exit("Unable to create log file") # creating list of parameter names tc_parameter_names = ["rest_URL", "HTTP_method", "HTTP_RC_desired", "param_list"] message = "It is working, right?" # call qaPrint to print a message with time stamp and write it to the log file qaPrint(log, message) qaPrint(log, "Me like what me see") # if we want to check how getLocalEnv works qaPrint(log, "Dictionary of parameters from " + properties_file + " is: %s" % testrun_properties) # if we want to check how getTestCases works qaPrint(log, "Dictionary of test cases from " + trid_file + " is: %s" % getTestCases(trid_file, tc_parameter_names))