def testCheckOne(self): """ONE operations should return anomalies if there is not one result.""" matcher = checks.Matcher(["ONE"], self.hint) for baseline in self.baselines: self.assertIsInstance( matcher.Detect(baseline, self.one), checks.CheckResult) for result in [self.none, self.some]: self.assertFalse(matcher.Detect(baseline, result))
def testCheckNone(self): """NONE returns an anomaly if there are no results.""" matcher = checks.Matcher(["NONE"], self.hint) for baseline in self.baselines: self.assertIsInstance( matcher.Detect(baseline, self.none), checks.CheckResult) for result in [self.one, self.some]: self.assertFalse(matcher.Detect(baseline, result))
def testMultipleMatch(self): """Checks with multiple match methods emit results if any methods fire.""" matcher = checks.Matcher(["NONE", "ONE"], self.hint) for baseline in self.baselines: for result in [self.none, self.one]: self.assertIsInstance( matcher.Detect(baseline, result), checks.CheckResult) self.assertFalse(matcher.Detect(baseline, self.some))
def testCheckAny(self): """ANY operations should not return anomalies if there are results.""" matcher = checks.Matcher(["ANY"], self.hint) for baseline in self.baselines: for result in [self.one, self.some]: self.assertIsInstance( matcher.Detect(baseline, result), checks.CheckResult) self.assertFalse(matcher.Detect(baseline, self.none))
def testCheckAll(self): """ALL operations return anomalies if input and result counts differ.""" matcher = checks.Matcher(["ALL"], self.hint) will_detect = [(self.one, self.one), (self.some, self.some)] not_detect = [(self.none, self.none), (self.some, self.one), (self.some, self.none)] will_raise = [(self.none, self.one), (self.one, self.some), (self.none, self.some)] for base, result in will_detect: self.assertIsInstance(matcher.Detect(base, result), checks.CheckResult) for base, result in not_detect: self.assertFalse(matcher.Detect(base, result)) for base, result in will_raise: self.assertRaises(checks.ProcessingError, matcher.Detect, base, result)