def test_CleanTimestamp_OnlyColons_ColonsBecomeUnderscores(self): test_timestamp = "12:00:00" expected_timestamp = "12_00_00" cleaned_timestamp = clean_timestamp(test_timestamp) self.assertEqual(expected_timestamp, cleaned_timestamp)
def test_CleanTimestamp_OnlyPeriods_PeriodsBecomeUnderscores(self): test_timestamp = "12.00.00" expected_timestamp = "12_00_00" cleaned_timestamp = clean_timestamp(test_timestamp) self.assertEqual(expected_timestamp, cleaned_timestamp)
def test_CleanTimestamp_ColonsAndPeriods_ColonsAndPeriodsBecomeUnderscores(self): test_timestamp = "2016.01.01 12:00:00" expected_timestamp = "2016_01_01_12_00_00" cleaned_timestamp = clean_timestamp(test_timestamp) self.assertEqual(expected_timestamp, cleaned_timestamp)
def _get_xunit_command(output_path): timestamp = clean_timestamp(datetime.now().isoformat()) full_filename = "{}_{}{}".format(PYTEST_RESULT_FILENAME, timestamp, XML_EXTENSION) folder_name = "{}_{}".format(PYTEST_ARTIFACT_FOLDER_NAME, timestamp) output_file = os.path.join(output_path, full_filename) output_folder = os.path.join(output_path, folder_name) return "--junitxml={} --logs_path={}".format(output_file, output_folder)
def _get_xunit_flags(output_path): timestamp = clean_timestamp(datetime.now().isoformat()) output_folder = os.path.join(output_path, timestamp, ARTIFACT_FOLDER) results_file = os.path.join(output_folder, RESULT_XML_FILENAME) log.info("Setting results folder to {}".format(output_folder)) return [ "--junitxml={}".format(results_file), "--logs_path={}".format(output_folder) ]
def _get_xunit_flags(output_path): timestamp = clean_timestamp(datetime.now().isoformat()) current_folder = os.path.abspath(output_path) output_folder = os.path.join( current_folder, # Absolute path where lmbr_test command is invoked OR user defined path if using --output-path arg in cmd. timestamp, # Timestamp folder name in YYYY_MM_DDTHH_MM_SSSSS format. ARTIFACT_FOLDER) results_file = os.path.join(output_folder, RESULT_XML_FILENAME) log.info("Setting results folder to {}".format(output_folder)) #Linux if sys.platform == "linux" or sys.platform == "linux2": lmbr_test_path = os.path.join(os.getcwd(), "lmbr_test.sh") #OS X elif sys.platform == "darwin": lmbr_test_path = os.path.join(os.getcwd(), "lmbr_test.sh") #Windows elif sys.platform == "win32": lmbr_test_path = os.path.join(os.getcwd(), "lmbr_test.cmd") #replacing double backslash with single forward slash. #python subprocess has a bug where it can't recognize file if path contains double backslash. lmbr_test_path = lmbr_test_path.replace(os.sep, '/') argument_call = [lmbr_test_path, "pysetup", "check", "ly_test_tools"] process = subprocess_with_timeout(argument_call, 120) #LyTestTools is installed if process returns 0. if process == 0: return [ "--junitxml={}".format(results_file), "--output-path={}".format(output_folder) ] else: return [ "--junitxml={}".format(results_file), "--logs_path={}".format(output_folder) ]
def test_CleanTimestamp_NoColonsNoPeriods_StringIsUnchanged(self): test_timestamp = "20160101T120000" cleaned_timestamp = clean_timestamp(test_timestamp) self.assertEqual(test_timestamp, cleaned_timestamp)
def test_CleanTimestamp_TimestampIsNotString_RaisesInvalidUseError(self): with self.assertRaises(InvalidUseError) as ex: clean_timestamp(123)
def test_CleanTimestamp_TimestampIsEmptyString_ReturnsEmptyString(self): cleaned_timestamp = clean_timestamp("") self.assertEqual("", cleaned_timestamp)
def _get_xunit_command(output_path): timestamp = clean_timestamp(datetime.now().isoformat()) full_filename = "{}_{}{}".format(PYTEST_RESULT_FILENAME, timestamp, XML_EXTENSION) output_file = os.path.join(output_path, full_filename) return "--junitxml={}".format(output_file)