Mercurial > hgrepos > Python > libs > data-schema
comparison tests/test_schema.py @ 42:0e7acd426e3a
An extra unittest to handle schema conditionals after processing schema references
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Thu, 20 Jul 2023 09:20:31 +0200 |
| parents | d2b43423fa4c |
| children | 4ca530618303 |
comparison
equal
deleted
inserted
replaced
| 41:d2b43423fa4c | 42:0e7acd426e3a |
|---|---|
| 1123 ]}) | 1123 ]}) |
| 1124 r = data_schema.process_schema_conditionals(schema, self._ctx) | 1124 r = data_schema.process_schema_conditionals(schema, self._ctx) |
| 1125 self.assertIsNot(r, schema) | 1125 self.assertIsNot(r, schema) |
| 1126 self.assertEqual("string", r["$type"]) | 1126 self.assertEqual("string", r["$type"]) |
| 1127 | 1127 |
| 1128 def test_anyOf_true_indirectly_by_ref(self): | |
| 1129 schema = data_schema._Schema( | |
| 1130 None, | |
| 1131 True, | |
| 1132 {"$ref": "schema:$self#/_lib/s1", | |
| 1133 "_lib": { | |
| 1134 "s1": { | |
| 1135 "cond": [ | |
| 1136 {"when": {"any-of": [ | |
| 1137 False, | |
| 1138 {"ref-not-exists": '#foo3-non'}, | |
| 1139 {"ref-false": '#foo2'}]}, | |
| 1140 "then": {"$type": "string"}}, | |
| 1141 {"when": True, | |
| 1142 "then": {"$type": None}} | |
| 1143 ]}}}) | |
| 1144 r = data_schema.process_schema_conditionals(schema, self._ctx) | |
| 1145 r = data_schema.process_schema_references(r, self._ctx, check_single_ref_key=False) | |
| 1146 self.assertIsNot(r, schema) | |
| 1147 self.assertEqual("string", r["$type"]) | |
| 1148 | |
| 1128 def test_anyOf_false(self): | 1149 def test_anyOf_false(self): |
| 1129 schema = data_schema._Schema( | 1150 schema = data_schema._Schema( |
| 1130 None, True, {"cond": [ | 1151 None, True, {"cond": [ |
| 1131 {"when": {"any-of": [ | 1152 {"when": {"any-of": [ |
| 1132 False, | 1153 False, |
