def test_translate_serieslist_to_regex(series, matches, nonmatches): pattern = translate_serieslist_to_regex(series) for string in matches: assert pattern.match(string), "%s doesn't match %s" % (string, series) for string in nonmatches: assert not pattern.match(string), "%s matches %s" % (string, series)
def get_pattern(self): """ Returns a compiled regexp pattern that represents the target metrics of this rule. """ series = extract_series_name(self.target) pat = translate_serieslist_to_regex(series) return pat