import copy import unittest from probe import observe, validate class DetailTests(unittest.TestCase): @classmethod def setUpClass(cls): cls.report = observe() def test_native(self): validate(self.report) def test_order_is_not_conjunction(self): report = copy.deepcopy(self.report) report["cases"][0]["queries"]["phrase"]["rowids"] = [1, 2, 3] with self.assertRaises(ValueError): validate(report) def test_error_is_not_empty_result(self): report = copy.deepcopy(self.report) report["cases"][1]["queries"]["phrase"] = {"ok": True, "rowids": []} with self.assertRaises(ValueError): validate(report) def test_missing_mode_fails(self): report = copy.deepcopy(self.report) report["cases"].pop() with self.assertRaises(ValueError): validate(report) def test_wrong_error_fails(self): report = copy.deepcopy(self.report) report["cases"][1]["queries"]["phrase"]["error"] = "unrelated error" with self.assertRaises(ValueError): validate(report) def test_integrity_failure_fails(self): report = copy.deepcopy(self.report) report["cases"][0]["internalIntegrity"] = "failed" with self.assertRaises(ValueError): validate(report) if __name__ == "__main__": unittest.main()