def testCheckSome(self): """SOME operations should return anomalies if there is >1 result.""" matcher = checks.Matcher(["SOME"], self.hint) for baseline in self.baselines: self.assertIsInstance(matcher.Detect(baseline, self.some), checks.CheckResult) for result in [self.none, self.one]: 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 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 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 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)