def RunTestGetRevisionString(self, current_time_str, prev_time_str, expected_rev_str, expected_simple_rev_str, expected_rev_number, expected_rev_date, testname, diff_map_none=False): current_time = datetime.strptime(current_time_str, '%Y-%m-%d-%H') current_time = time.mktime(current_time.timetuple()) prev_time = datetime.strptime(prev_time_str, '%Y-%m-%d-%H') prev_time = time.mktime(prev_time.timetuple()) if diff_map_none: diff_map = None else: diff_map = { 'whole': [[], []], 'skip': [[(testname, 'te_info1')], []], 'nonskip': [[], []], } (rev_str, simple_rev_str, rev_number, rev_date) = (layouttest_analyzer_helpers.GetRevisionString( prev_time, current_time, diff_map)) self.assertEquals(rev_str, expected_rev_str) self.assertEquals(simple_rev_str, expected_simple_rev_str) self.assertEquals(rev_number, expected_rev_number) self.assertEquals(rev_date, expected_rev_date)
def SendEmail(prev_time, prev_analyzer_result_map, analyzer_result_map, anno_map, appended_text_to_email, email_only_change_mode, debug, receiver_email_address, test_group_name, issue_detail_mode): """Send result status email. Args: prev_time: the previous time string that is compared against. prev_analyzer_result_map: previous analyzer result map. Please refer to layouttest_analyzer_helpers.AnalyzerResultMap. analyzer_result_map: current analyzer result map. Please refer to layouttest_analyzer_helpers.AnalyzerResultMap. anno_map: a dictionary that maps bug names to their annotations. appended_text_to_email: the text string to append to the status email. email_only_change_mode: please refer to |options|. debug: please refer to |options|. receiver_email_address: please refer to |options|. test_group_name: please refer to |options|. issue_detail_mode: please refer to |options|. Returns: a tuple of the following: result_change: a boolean indicating whether there is a change in the result compared with the latest past result. diff_map: please refer to layouttest_analyzer_helpers.SendStatusEmail(). simple_rev_str: a simple version of revision string that is sent in the email. rev: the latest revision number for the given test group. rev_date: the latest revision date for the given test group. email_content: email content string (without |appended_text_to_email|) that will be shown on the dashboard. """ rev = '' rev_date = '' email_content = '' if prev_analyzer_result_map: diff_map = analyzer_result_map.CompareToOtherResultMap( prev_analyzer_result_map) result_change = (any(diff_map['whole']) or any(diff_map['skip']) or any(diff_map['nonskip'])) # Email only when |email_only_change_mode| is False or there # is a change in the result compared to the last result. simple_rev_str = '' if not email_only_change_mode or result_change: prev_time_in_float = datetime.strptime(prev_time, '%Y-%m-%d-%H') prev_time_in_float = time.mktime(prev_time_in_float.timetuple()) if debug: cur_time_in_float = datetime.strptime(CUR_TIME_FOR_DEBUG, '%Y-%m-%d-%H') cur_time_in_float = time.mktime(cur_time_in_float.timetuple()) else: cur_time_in_float = time.time() (rev_str, simple_rev_str, rev, rev_date) = (layouttest_analyzer_helpers.GetRevisionString( prev_time_in_float, cur_time_in_float, diff_map)) email_content = analyzer_result_map.ConvertToString( prev_time, diff_map, anno_map, issue_detail_mode) if receiver_email_address: layouttest_analyzer_helpers.SendStatusEmail( prev_time, analyzer_result_map, diff_map, anno_map, receiver_email_address, test_group_name, appended_text_to_email, email_content, rev_str, email_only_change_mode) if simple_rev_str: simple_rev_str = '\'' + simple_rev_str + '\'' else: simple_rev_str = 'undefined' # GViz uses undefined for NONE. else: # Initial result should be written to tread-graph if there are no previous # results. result_change = True diff_map = None simple_rev_str = 'undefined' email_content = analyzer_result_map.ConvertToString( None, diff_map, anno_map) return (result_change, diff_map, simple_rev_str, rev, rev_date, email_content)