Exemple #1
0
def test_dates_match_false():
    """
    Uses util.dates_match with two non-matching datetime objects.
    """
    first_date = datetime.datetime(2018, 11, 27, 10)
    second_date = datetime.datetime(2016, 11, 27, 11)
    assert_equals(util.do_dates_match(first_date, second_date), False)
Exemple #2
0
def match(tgen_logs, tor_logs, date_filter):
    log_pairs = []
    for tgen_log in tgen_logs:
        m = re.search(r'(\d+-\d+-\d+)', tgen_log)
        if m:
            date = m.group(0)
            fdate = datetime.datetime.strptime(date, "%Y-%m-%d")
            found = False
            if date_filter is None or util.do_dates_match(date_filter, fdate):
                for tor_log in tor_logs:
                    if date in tor_log:
                        log_pairs.append((tgen_log, tor_log, fdate))
                        found = True
                        break
                if not found:
                    logging.warning(
                        'Skipping file {0}, could not find a match for it'.
                        format(tgen_log))

        else:
            logging.warning(
                'Filename {0} does not contain a date'.format(tgen_log))
    if not log_pairs:
        logging.warning(
            'Could not find any log matches. No analyses will be performed')
    return log_pairs
Exemple #3
0
def test_dates_match():
    """
    Uses util.dates_match with two matching datetime objects.
    """
    first_date = datetime.datetime(2018, 11, 27, 10)
    second_date = datetime.datetime(2018, 11, 27, 11)
    assert(util.do_dates_match(first_date, second_date))