Mercurial > hgrepos > Python > libs > data-schema
changeset 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 |
| files | tests/test_schema.py |
| diffstat | 1 files changed, 21 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/test_schema.py Thu Jul 20 02:04:17 2023 +0200 +++ b/tests/test_schema.py Thu Jul 20 09:20:31 2023 +0200 @@ -1125,6 +1125,27 @@ self.assertIsNot(r, schema) self.assertEqual("string", r["$type"]) + def test_anyOf_true_indirectly_by_ref(self): + schema = data_schema._Schema( + None, + True, + {"$ref": "schema:$self#/_lib/s1", + "_lib": { + "s1": { + "cond": [ + {"when": {"any-of": [ + False, + {"ref-not-exists": '#foo3-non'}, + {"ref-false": '#foo2'}]}, + "then": {"$type": "string"}}, + {"when": True, + "then": {"$type": None}} + ]}}}) + r = data_schema.process_schema_conditionals(schema, self._ctx) + r = data_schema.process_schema_references(r, self._ctx, check_single_ref_key=False) + self.assertIsNot(r, schema) + self.assertEqual("string", r["$type"]) + def test_anyOf_false(self): schema = data_schema._Schema( None, True, {"cond": [
