Mercurial > hgrepos > Python > libs > data-schema
annotate tests/test_schema.py @ 28:db3491e1b590
Allow to customize the loading of the schema dict
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Sat, 08 Jul 2023 13:51:20 +0200 |
| parents | c3a0fe8d4587 |
| children | 68286d27f27d |
| rev | line source |
|---|---|
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2 import copy |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
3 import datetime |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
4 import re |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
5 import unittest |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
6 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
7 import _config |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
8 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
9 import configmix.yaml |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
10 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
11 import data_schema |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
12 import data_schema.util |
|
16
2a9e7c4b717e
Problem severity now is also an enum
Franz Glasner <fzglas.hg@dom66.de>
parents:
15
diff
changeset
|
13 from data_schema import SEVERITY, ERRORS, WARNINGS |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
14 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
15 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
16 TYPE_RE = type(re.compile(r"\A.+\Z")) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
17 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
18 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
19 def _test_generic_validator_for_yaml(obj, schema, context): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
20 """Callback for loading test1.schema.yml: Always successful""" |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
21 yield from () |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
22 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
23 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
24 class YAML(unittest.TestCase): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
25 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
26 """Tests to load Python objects from YAML with complex Python-specific |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
27 tags. |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
28 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
29 .. seealso:: https://pyyaml.org/wiki/PyYAMLDocumentation |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
30 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
31 """ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
32 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
33 def test_load_python_name(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
34 y = configmix.yaml.load("key: !!python/name:data_schema.validate") |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
35 self.assertTrue(callable(y["key"])) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
36 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
37 def test_load_re(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
38 y = configmix.yaml.load("key: !!python/object/apply:re.compile\n - '^[0-9]+$'") |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
39 self.assertTrue(isinstance(y["key"], TYPE_RE)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
40 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
41 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
42 class SchemaInYAML(unittest.TestCase): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
43 def test_file(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
44 with data_schema.util.get_data_stream( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
45 _config.FILEURI_PREFIX + "test1.schema.yml", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
46 basedir=_config.config.getvar_s("projectdir")) as f: |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
47 schema = data_schema._Schema( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
48 None, True, configmix.yaml.load(f)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
49 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
50 def test_data(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
51 with data_schema.util.get_data_stream( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
52 "data:testschematalib:test2.schema.yml") as f: |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
53 schema = data_schema._Schema( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
54 None, True, configmix.yaml.load(f)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
55 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
56 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
57 class SchemaCheck(unittest.TestCase): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
58 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
59 def test_root_creation(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
60 schema = data_schema._Schema(None, True) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
61 self.assertIsInstance(schema, dict) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
62 self.assertEqual(0, len(schema)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
63 self.assertFalse(schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
64 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
65 def test_root_creation_wrong(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
66 self.assertRaises( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
67 ValueError, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
68 data_schema._Schema, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
69 None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
70 False) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
71 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
72 def test_root_properties(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
73 schema = data_schema._Schema(None, True) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
74 self.assertIsNone(schema.parent) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
75 self.assertIs(schema, schema.ROOT) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
76 self.assertTrue(schema.is_sub_root) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
77 self.assertIs(schema, schema.SELF) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
78 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
79 def test_dict_len_bool(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
80 schema = data_schema._Schema(None, True, a=1, b=2) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
81 self.assertTrue(schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
82 self.assertEqual(2, len(schema)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
83 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
84 def test_equality(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
85 schema1 = data_schema._Schema(None, True, a=1, b=2) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
86 schema2 = data_schema._Schema(None, True, b=2, a=1) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
87 self.assertEqual(schema1, schema2) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
88 self.assertIsNot(schema1, schema2) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
89 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
90 def test_copy(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
91 schema = data_schema._Schema(None, True, type="str") |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
92 schema2 = schema.copy() |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
93 self.assertEqual(schema, schema2) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
94 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
95 def test_deepcopy(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
96 d1 = {} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
97 schema = data_schema._Schema(None, True, type="str", b=d1) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
98 schema2 = copy.deepcopy(schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
99 self.assertEqual(schema, schema2) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
100 self.assertIs(schema["b"], d1) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
101 self.assertIsNot(schema2["b"], d1) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
102 self.assertIs(schema.parent, schema2.parent) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
103 self.assertIs(schema.is_sub_root, schema2.is_sub_root) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
104 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
105 def test_nested_copy(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
106 d1 = {} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
107 d2 = {} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
108 root_schema = data_schema._Schema(None, True, type="str", b=d1) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
109 child_schema = data_schema._Schema(root_schema, True, type="bool", b=d2) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
110 copied_child = child_schema.copy() |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
111 self.assertIs(copied_child.ROOT, root_schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
112 self.assertIs(copied_child.SELF, copied_child) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
113 self.assertIsNot(copied_child.SELF, root_schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
114 self.assertEqual(child_schema, copied_child) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
115 self.assertIs(copied_child["b"], d2) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
116 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
117 def test_nested_deepcopy(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
118 d1 = {} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
119 d2 = {} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
120 root_schema = data_schema._Schema(None, True, type="str", b=d1) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
121 child_schema = data_schema._Schema(root_schema, True, type="bool", b=d2) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
122 copied_child = copy.deepcopy(child_schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
123 self.assertIs(copied_child.ROOT, root_schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
124 self.assertIs(copied_child.SELF, copied_child) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
125 self.assertEqual(child_schema, copied_child) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
126 self.assertIsNot(copied_child["b"], d2) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
127 self.assertNotEqual(root_schema, child_schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
128 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
129 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
130 class ContextCheck(unittest.TestCase): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
131 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
132 def test_root_without_settings(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
133 self.assertRaises(TypeError, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
134 data_schema.Context, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
135 None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
136 root_object=object(), |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
137 schema=dict()) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
138 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
139 def test_root_context(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
140 obj = object() |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
141 schema = object() |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
142 settings = data_schema.ValidationSettings( |
|
28
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
143 skip_keys=[], break_on_keynames_problems=True, |
|
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
144 schema_loader=data_schema.default_schema_loader) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
145 ctx = data_schema.Context( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
146 None, root_object=obj, root_schema=schema, settings=settings) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
147 self.assertEqual("<ROOT>", str(ctx)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
148 self.assertTrue(ctx.root_object is obj) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
149 self.assertTrue(ctx.root_schema is schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
150 self.assertTrue(ctx.settings is settings) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
151 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
152 def test_parent_of_root_context(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
153 obj = object() |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
154 schema = object() |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
155 settings = data_schema.ValidationSettings( |
|
28
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
156 skip_keys=[], break_on_keynames_problems=True, |
|
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
157 schema_loader=data_schema.default_schema_loader) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
158 ctx = data_schema.Context( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
159 None, root_object=obj, root_schema=schema, settings=settings) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
160 self.assertTrue(ctx.is_root) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
161 self.assertIsNone(ctx.parent) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
162 try: |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
163 ctx.safe_parent |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
164 except TypeError: |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
165 pass |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
166 else: |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
167 self.fail( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
168 "Context.safe_parent was expected to raise for a root context") |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
169 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
170 def test_root_context_init_root_empty(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
171 settings = data_schema.ValidationSettings( |
|
28
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
172 skip_keys=[], break_on_keynames_problems=True, |
|
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
173 schema_loader=data_schema.default_schema_loader) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
174 self.assertRaises( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
175 TypeError, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
176 data_schema.Context, None, key="key", settings=settings) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
177 self.assertRaises( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
178 TypeError, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
179 data_schema.Context, None, index="key", settings=settings) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
180 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
181 def test_root_context_init_only_one_of_key_index(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
182 settings = data_schema.ValidationSettings( |
|
28
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
183 skip_keys=[], break_on_keynames_problems=True, |
|
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
184 schema_loader=data_schema.default_schema_loader) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
185 root = data_schema.Context(None, settings=settings) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
186 self.assertRaises( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
187 ValueError, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
188 data_schema.Context, root, key="key", index="index") |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
189 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
190 def test_root_context_init_exactly_one(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
191 settings = data_schema.ValidationSettings( |
|
28
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
192 skip_keys=[], break_on_keynames_problems=True, |
|
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
193 schema_loader=data_schema.default_schema_loader) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
194 root = data_schema.Context(None, settings=settings) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
195 self.assertRaises(TypeError, data_schema.Context, root) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
196 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
197 def test_nonroot_rootobj_schema(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
198 settings = data_schema.ValidationSettings( |
|
28
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
199 skip_keys=[], break_on_keynames_problems=True, |
|
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
200 schema_loader=data_schema.default_schema_loader) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
201 obj = object() |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
202 schema = object() |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
203 ctx = data_schema.Context( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
204 None, root_object=obj, root_schema=schema, settings=settings) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
205 self.assertEqual("<ROOT>", str(ctx)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
206 self.assertTrue(ctx.root_object is obj) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
207 self.assertTrue(ctx.root_schema is schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
208 self.assertTrue(ctx.settings is settings) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
209 self.assertRaises(TypeError, data_schema.Context, ctx, index=0, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
210 root_object=object()) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
211 self.assertRaises(TypeError, data_schema.Context, ctx, index=0, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
212 root_schema=object()) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
213 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
214 def test_str(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
215 settings = data_schema.ValidationSettings( |
|
28
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
216 skip_keys=[], break_on_keynames_problems=True, |
|
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
217 schema_loader=data_schema.default_schema_loader) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
218 root = data_schema.Context(None, settings=settings) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
219 ctx1 = data_schema.Context(root, key="key1") |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
220 ctx2 = data_schema.Context(ctx1, index=2) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
221 ctx3 = data_schema.Context(ctx2, key="key3") |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
222 self.assertEqual("key1 / INDEX:2 / key3", str(ctx3)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
223 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
224 def test_repr(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
225 settings = data_schema.ValidationSettings( |
|
28
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
226 skip_keys=[], break_on_keynames_problems=True, |
|
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
227 schema_loader=data_schema.default_schema_loader) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
228 root = data_schema.Context(None, settings=settings) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
229 ctx1 = data_schema.Context(root, key="key1") |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
230 ctx2 = data_schema.Context(ctx1, index=2) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
231 ctx3 = data_schema.Context(ctx2, key="key3") |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
232 self.assertEqual("<Context path=`key1 / INDEX:2 / key3'>", repr(ctx3)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
233 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
234 def test_root(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
235 settings = data_schema.ValidationSettings( |
|
28
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
236 skip_keys=[], break_on_keynames_problems=True, |
|
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
237 schema_loader=data_schema.default_schema_loader) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
238 root = data_schema.Context(None, settings=settings) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
239 self.assertTrue(root.is_root) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
240 self.assertTrue(root is root.root) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
241 self.assertTrue(root.settings is settings) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
242 ctx1 = data_schema.Context(root, key="key1") |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
243 self.assertFalse(ctx1.is_root) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
244 self.assertTrue(ctx1.root is root) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
245 self.assertTrue(ctx1.settings is settings) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
246 ctx2 = data_schema.Context(ctx1, index=2) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
247 self.assertTrue(ctx2.settings is settings) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
248 ctx3 = data_schema.Context(ctx2, key="key3") |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
249 self.assertEqual("key1 / INDEX:2 / key3", str(ctx3)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
250 self.assertFalse(ctx3.is_root) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
251 self.assertTrue(ctx3.root is root) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
252 self.assertTrue(ctx3.settings is settings) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
253 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
254 def test_extra_settings_in_between(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
255 settings = data_schema.ValidationSettings( |
|
28
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
256 skip_keys=[], break_on_keynames_problems=True, |
|
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
257 schema_loader=data_schema.default_schema_loader) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
258 settings2 = data_schema.ValidationSettings( |
|
28
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
259 skip_keys=[], break_on_keynames_problems=True, |
|
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
260 schema_loader=data_schema.default_schema_loader) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
261 root = data_schema.Context(None, settings=settings) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
262 self.assertTrue(root.is_root) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
263 self.assertTrue(root is root.root) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
264 self.assertTrue(root.settings is settings) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
265 ctx1 = data_schema.Context(root, key="key1") |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
266 self.assertFalse(ctx1.is_root) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
267 self.assertTrue(ctx1.root is root) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
268 self.assertTrue(ctx1.settings is settings) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
269 ctx2 = data_schema.Context(ctx1, index=2, settings=settings2) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
270 self.assertTrue(ctx2.settings is settings2) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
271 ctx3 = data_schema.Context(ctx2, key="key3") |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
272 self.assertEqual("key1 / INDEX:2 / key3", str(ctx3)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
273 self.assertFalse(ctx3.is_root) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
274 self.assertTrue(ctx3.root is root) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
275 self.assertTrue(ctx3.settings is settings2) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
276 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
277 def test_key_xor_index(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
278 settings = data_schema.ValidationSettings( |
|
28
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
279 skip_keys=[], break_on_keynames_problems=True, |
|
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
280 schema_loader=data_schema.default_schema_loader) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
281 root = data_schema.Context(None, settings=settings) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
282 self.assertRaises( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
283 ValueError, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
284 data_schema.Context, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
285 root, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
286 index=0, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
287 key="huhu") |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
288 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
289 def test_keyindex_requires_key(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
290 settings = data_schema.ValidationSettings( |
|
28
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
291 skip_keys=[], break_on_keynames_problems=True, |
|
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
292 schema_loader=data_schema.default_schema_loader) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
293 self.assertRaises( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
294 ValueError, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
295 data_schema.Context, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
296 None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
297 key_index=0, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
298 settings=settings) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
299 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
300 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
301 class SchemaReferences(unittest.TestCase): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
302 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
303 def setUp(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
304 self.empty_schema = data_schema._Schema(None, True) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
305 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
306 def test_no_fragment(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
307 ctx = data_schema.Context(None, root_object={"foo": "bar"}, settings=None) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
308 self.assertRaises(data_schema.SchemaError, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
309 data_schema.try_get_reference, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
310 "object:", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
311 ctx, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
312 self.empty_schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
313 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
314 def test_empty_fragment(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
315 ctx = data_schema.Context(None, root_object={"foo": "bar"}, settings=None) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
316 r = data_schema.try_get_reference( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
317 "object:#", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
318 ctx, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
319 self.empty_schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
320 self.assertIs(r, ctx.root_object) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
321 self.assertIs(r, ctx.current_object) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
322 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
323 def test_point_fragment_with_root(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
324 ctx = data_schema.Context(None, root_object={"foo": "bar"}, settings=None) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
325 r = data_schema.try_get_reference( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
326 "object:#.", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
327 ctx, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
328 self.empty_schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
329 self.assertIs(r, ctx.root_object) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
330 self.assertIs(r, ctx.current_object) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
331 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
332 def test_point_fragment_with_current_object(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
333 current_object = { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
334 "current": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
335 "object": "value"}} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
336 root_object = {"root": current_object} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
337 ctx = data_schema.Context(None, current_object=current_object, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
338 root_object=root_object, settings=None) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
339 r = data_schema.try_get_reference( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
340 "object:#.", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
341 ctx, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
342 self.empty_schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
343 self.assertIs(r, ctx.current_object) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
344 self.assertIs(r, current_object) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
345 self.assertIsNot(r, ctx.root_object) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
346 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
347 r = data_schema.try_get_reference( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
348 "object:#.current", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
349 ctx, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
350 self.empty_schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
351 self.assertEqual({"object": "value"}, r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
352 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
353 r = data_schema.try_get_reference( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
354 "object:#.current.object", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
355 ctx, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
356 self.empty_schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
357 self.assertEqual("value", r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
358 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
359 def test_point_fragment_with_invalid_current_object_refs(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
360 current_object = { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
361 "current": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
362 "object": "value"}} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
363 root_object = {"root": current_object} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
364 ctx = data_schema.Context(None, current_object=current_object, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
365 root_object=root_object, settings=None) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
366 r = data_schema.try_get_reference( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
367 "object:#.", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
368 ctx, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
369 self.empty_schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
370 self.assertIs(r, ctx.current_object) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
371 self.assertIs(r, current_object) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
372 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
373 r = data_schema.try_get_reference( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
374 "object:#.non-current", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
375 ctx, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
376 self.empty_schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
377 self.assertIsNone(r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
378 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
379 r = data_schema.try_get_reference( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
380 "object:#.non-current.object", ctx, self.empty_schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
381 self.assertIsNone(r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
382 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
383 r = data_schema.try_get_reference( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
384 "object:#.current.non-object", ctx, self.empty_schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
385 self.assertIsNone(r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
386 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
387 self.assertRaises( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
388 data_schema.SchemaError, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
389 data_schema.try_get_reference, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
390 "object:#.current..", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
391 ctx, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
392 self.empty_schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
393 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
394 self.assertRaises( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
395 TypeError, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
396 data_schema.try_get_reference, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
397 "object:#..current.object", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
398 ctx, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
399 self.empty_schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
400 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
401 def test_fragment_with_current_object_and_root(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
402 current_object = { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
403 "current": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
404 "object": "value"}} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
405 root_object = {"root": current_object} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
406 ctx = data_schema.Context(None, current_object=current_object, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
407 root_object=root_object, settings=None) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
408 r = data_schema.try_get_reference( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
409 "object:#", ctx, self.empty_schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
410 self.assertIs(r, ctx.root_object) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
411 self.assertIs(r, root_object) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
412 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
413 def test_default_schema_ref(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
414 ctx = data_schema.Context(None, root_object={"foo": "bar"}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
415 settings=None) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
416 r = data_schema.try_get_reference("#foo", ctx, self.empty_schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
417 self.assertEqual("bar", r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
418 r = data_schema.try_get_reference("#bar", ctx, self.empty_schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
419 self.assertIsNone(r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
420 sentinel = object() |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
421 r = data_schema.try_get_reference("#bar", ctx, self.empty_schema, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
422 default=sentinel) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
423 self.assertIs(r, sentinel) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
424 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
425 def test_object_schema_ref(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
426 ctx = data_schema.Context(None, root_object={"foo": "bar"}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
427 settings=None) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
428 r = data_schema.try_get_reference("object:#foo", ctx, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
429 self.empty_schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
430 self.assertEqual("bar", r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
431 r = data_schema.try_get_reference("object:#bar", ctx, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
432 self.empty_schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
433 self.assertIsNone(r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
434 sentinel = object() |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
435 r = data_schema.try_get_reference( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
436 "object:#bar", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
437 ctx, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
438 self.empty_schema, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
439 default=sentinel) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
440 self.assertIs(r, sentinel) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
441 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
442 def test_nested_keys(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
443 sentinel = object() |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
444 ctx = data_schema.Context( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
445 None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
446 root_object={"foo": "bar", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
447 "k1": {"k2": "v2", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
448 "k3": None}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
449 "k4": None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
450 "k5": [1, 2, 3]}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
451 settings=None) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
452 r = data_schema.try_get_reference( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
453 "#k1.k2", ctx, self.empty_schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
454 self.assertEqual("v2", r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
455 r = data_schema.try_get_reference( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
456 "#k1.k3", ctx, self.empty_schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
457 self.assertIsNone(r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
458 r = data_schema.try_get_reference( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
459 "#k1.k3.fornone", ctx, self.empty_schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
460 self.assertIsNone(r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
461 r = data_schema.try_get_reference( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
462 "#k1.k3.fornone", ctx, self.empty_schema, default=sentinel) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
463 self.assertIs(r, sentinel) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
464 r = data_schema.try_get_reference( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
465 "#k5.0", ctx, self.empty_schema, default=sentinel) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
466 self.assertIs(r, sentinel) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
467 r = data_schema.try_get_reference( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
468 "#k6", ctx, self.empty_schema, default=sentinel) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
469 self.assertIs(r, sentinel) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
470 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
471 def test_url_quoted_fragment(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
472 ctx = data_schema.Context( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
473 None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
474 root_object={"foo": "bar", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
475 "k1": {"k2": "v2", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
476 "k3": None}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
477 "k4": None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
478 "k5": [1, 2, 3]}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
479 settings=None) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
480 r = data_schema.try_get_reference( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
481 "#fo%6F", ctx, self.empty_schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
482 self.assertEqual("bar", r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
483 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
484 def test_no_duplicate_unquoting_in_fragment(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
485 ctx = data_schema.Context( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
486 None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
487 root_object={"fo%o": "bar"}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
488 settings=None) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
489 r = data_schema.try_get_reference( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
490 "#fo%25o", ctx, self.empty_schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
491 self.assertEqual("bar", r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
492 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
493 def test_schema_ref_must_have_fragment(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
494 ctx = data_schema.Context(None, root_schema={"foo": "bar"}, settings=None) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
495 self.assertRaises( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
496 data_schema.SchemaError, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
497 data_schema.try_get_reference, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
498 "schema:", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
499 ctx, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
500 self.empty_schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
501 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
502 def test_schema_ref_must_have_absolute_fragment(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
503 ctx = data_schema.Context(None, root_schema={"foo": "bar"}, settings=None) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
504 self.assertRaises( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
505 data_schema.SchemaError, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
506 data_schema.try_get_reference, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
507 "schema:#", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
508 ctx, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
509 self.empty_schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
510 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
511 def test_schema_ref_root_schema(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
512 schema = data_schema._Schema( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
513 None, True, {"foo": "bar"}) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
514 ctx = data_schema.Context(None, root_schema=schema, settings=None) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
515 r = data_schema.try_get_reference( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
516 "schema:#/", ctx, schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
517 self.assertIs(r, schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
518 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
519 def test_unknown_schema_ref_yet(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
520 ctx = data_schema.Context(None, root_object={"foo": "bar"}, settings=None) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
521 self.assertRaises( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
522 data_schema.SchemaError, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
523 data_schema.try_get_reference, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
524 "data:#", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
525 ctx, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
526 self.empty_schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
527 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
528 def test_schema_not_found(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
529 sentinel = object() |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
530 root_schema = data_schema._Schema(None, True, {"foo": "bar"}) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
531 ctx = data_schema.Context(None, root_schema=root_schema, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
532 settings=None) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
533 r = data_schema.try_get_reference( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
534 "schema:#/foo/bar", ctx, root_schema, default=sentinel) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
535 self.assertIs(r, sentinel) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
536 r = data_schema.try_get_reference( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
537 "schema:#/foo2", ctx, root_schema, default=sentinel) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
538 self.assertIs(r, sentinel) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
539 r = data_schema.try_get_reference( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
540 "schema:#/foo3", ctx, root_schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
541 self.assertIsNone(r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
542 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
543 def test_schema_is_found(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
544 subsubschema = {"foo3": "bar3"} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
545 subschema = {"foo2": subsubschema} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
546 schema = data_schema._Schema(None, True, {"foo": subschema}) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
547 ctx = data_schema.Context(None, root_schema=schema, settings=None) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
548 r = data_schema.try_get_reference( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
549 "schema:#/foo/foo2", ctx, schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
550 self.assertEqual(subsubschema, r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
551 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
552 def test_schema_with_trailing_slash_is_found(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
553 subsubschema = {"foo3": "bar3"} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
554 subschema = {"foo2": subsubschema} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
555 schema = data_schema._Schema(None, True, {"foo": subschema}) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
556 ctx = data_schema.Context(None, root_schema=schema, settings=None) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
557 r = data_schema.try_get_reference( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
558 "schema:#/foo/foo2/", ctx, schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
559 self.assertIsNone(r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
560 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
561 def test_schema_is_found_with_quoted_fragment(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
562 subsubschema = {"foo3": "bar3"} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
563 subschema = {"foo2": subsubschema} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
564 schema = data_schema._Schema(None, True, {"foo": subschema}) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
565 ctx = data_schema.Context(None, root_schema=schema, settings=None) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
566 r = data_schema.try_get_reference( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
567 "schema:#/f%6Fo/foo%32", ctx, schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
568 self.assertEqual(subsubschema, r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
569 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
570 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
571 class SchemaConditionals(unittest.TestCase): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
572 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
573 def setUp(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
574 self._ctx = data_schema.Context( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
575 None, root_object={"foo": "bar", "foo2": None}, settings=None) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
576 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
577 def test_no_cond(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
578 schema = data_schema._Schema(None, True, {"type": None}) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
579 self.assertIs(data_schema.process_schema_conditionals( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
580 schema, self._ctx), |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
581 schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
582 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
583 def test_cond_is_none(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
584 schema = data_schema._Schema(None, True, {"type": None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
585 "cond": None}) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
586 self.assertIs(data_schema.process_schema_conditionals( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
587 schema, self._ctx), |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
588 schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
589 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
590 def test_ambiguous(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
591 schema = data_schema._Schema(None, True, {"type": None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
592 "cond": None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
593 "match": None}) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
594 self.assertRaises( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
595 data_schema.SchemaError, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
596 data_schema.process_schema_conditionals, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
597 schema, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
598 self._ctx) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
599 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
600 def test_cond_not_a_sequence(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
601 schema = data_schema._Schema(None, True, {"type": None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
602 "cond": {"type": None}}) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
603 self.assertRaises( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
604 data_schema.SchemaError, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
605 data_schema.process_schema_conditionals, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
606 schema, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
607 self._ctx) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
608 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
609 def test_match_not_a_sequence(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
610 schema = data_schema._Schema( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
611 None, True, {"type": None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
612 "match": {"type": None}}) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
613 self.assertRaises( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
614 data_schema.SchemaError, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
615 data_schema.process_schema_conditionals, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
616 schema, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
617 self._ctx) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
618 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
619 def test_condline_not_a_dict(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
620 schema = data_schema._Schema(None, True, {"type": None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
621 "cond": [None]}) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
622 self.assertRaises( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
623 data_schema.SchemaError, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
624 data_schema.process_schema_conditionals, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
625 schema, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
626 self._ctx) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
627 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
628 def test_matchline_not_a_dict(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
629 schema = {"type": None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
630 "match": [None]} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
631 self.assertRaises( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
632 data_schema.SchemaError, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
633 data_schema.process_schema_conditionals, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
634 schema, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
635 self._ctx) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
636 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
637 def test_cond_unknown_predicate(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
638 schema = data_schema._Schema( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
639 None, True, {"type": None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
640 "cond": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
641 {"unexisting-when-xxxx": None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
642 "then": {}} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
643 ]}) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
644 self.assertRaises( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
645 data_schema.SchemaError, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
646 data_schema.process_schema_conditionals, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
647 schema, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
648 self._ctx) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
649 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
650 def test_match_unknown_predicate(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
651 schema = data_schema._Schema( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
652 None, True, {"type": None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
653 "match": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
654 {"unexisting-when-xxxx": None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
655 "then": {}} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
656 ]}) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
657 self.assertRaises( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
658 data_schema.SchemaError, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
659 data_schema.process_schema_conditionals, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
660 schema, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
661 self._ctx) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
662 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
663 def test_simple_replace_when_true(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
664 schema = data_schema._Schema( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
665 None, True, {"type": None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
666 "require": ["huhu", "haha"], |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
667 "cond": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
668 {"when": True, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
669 "then": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
670 "require": ["r1", "r2", "r3"], |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
671 "new-key": None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
672 }} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
673 ]}) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
674 r = data_schema.process_schema_conditionals(schema, self._ctx) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
675 self.assertIsNot(r, schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
676 self.assertEqual(["r1", "r2", "r3"], r["require"]) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
677 self.assertTrue("new-key" in r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
678 self.assertIsNone(r["new-key"]) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
679 self.assertFalse("cond" in r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
680 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
681 def test_simple_replace_when_not_false(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
682 schema = data_schema._Schema( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
683 None, True, {"type": None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
684 "require": ["huhu", "haha"], |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
685 "cond": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
686 {"when": {"not": False}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
687 "then": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
688 "require": ["r1", "r2", "r3"], |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
689 "new-key": None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
690 }} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
691 ]}) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
692 r = data_schema.process_schema_conditionals(schema, self._ctx) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
693 self.assertIsNot(r, schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
694 self.assertEqual(["r1", "r2", "r3"], r["require"]) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
695 self.assertTrue("new-key" in r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
696 self.assertIsNone(r["new-key"]) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
697 self.assertFalse("cond" in r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
698 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
699 def test_simple_merge_when_true(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
700 schema = data_schema._Schema( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
701 None, True, {"type": None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
702 "require": ["huhu", "haha"], |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
703 "old-key": "here I am", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
704 "cond": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
705 {"when": True, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
706 "then-merge": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
707 "require": ["r1", "r2", "r3"], |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
708 "new-key": None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
709 "old-key": "{{::DEL::}}" |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
710 }} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
711 ]}) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
712 r = data_schema.process_schema_conditionals(schema, self._ctx) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
713 self.assertIsNot(r, schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
714 self.assertEqual(["huhu", "haha", "r1", "r2", "r3"], r["require"]) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
715 self.assertTrue("new-key" in r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
716 self.assertIsNone(r["new-key"]) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
717 self.assertFalse("old-key" in r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
718 self.assertFalse("cond" in r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
719 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
720 def test_simple_replace_first_wins_1(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
721 schema = data_schema._Schema( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
722 None, True, {"type": None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
723 "require": ["huhu", "haha", "hehe"], |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
724 "cond": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
725 {"when": True, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
726 "then": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
727 "new-key2": "v2"}}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
728 {"when": True, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
729 "then": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
730 "require": ["r1", "r2", "r3"], |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
731 "new-key": None}} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
732 ]}) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
733 r = data_schema.process_schema_conditionals(schema, self._ctx) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
734 self.assertIsNot(r, schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
735 self.assertEqual(["huhu", "haha", "hehe"], r["require"]) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
736 self.assertTrue("new-key2" in r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
737 self.assertEqual("v2", r["new-key2"]) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
738 self.assertFalse("cond" in r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
739 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
740 def test_simple_replace_first_wins_2(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
741 schema = data_schema._Schema( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
742 None, True, {"type": None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
743 "require": ["huhu", "haha", "hehe"], |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
744 "cond": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
745 {"when": False, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
746 "then": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
747 "new-key2": "v2"}}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
748 {"when": True, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
749 "then": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
750 "require": ["r1", "r2", "r3"], |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
751 "new-key": None}} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
752 ]}) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
753 r = data_schema.process_schema_conditionals(schema, self._ctx) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
754 self.assertIsNot(r, schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
755 self.assertEqual(["r1", "r2", "r3"], r["require"]) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
756 self.assertTrue("new-key" in r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
757 self.assertIsNone(r["new-key"]) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
758 self.assertFalse("new-key2" in r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
759 self.assertFalse("cond" in r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
760 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
761 def test_simple_replace_when_false(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
762 schema = data_schema._Schema( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
763 None, True, {"type": None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
764 "require": ["huhu", "haha"], |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
765 "cond": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
766 {"when": False, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
767 "then": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
768 "require": ["r1", "r2", "r3"], |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
769 "new-key": None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
770 }} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
771 ]}) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
772 r = data_schema.process_schema_conditionals(schema, self._ctx) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
773 self.assertIsNot(r, schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
774 self.assertEqual(["huhu", "haha"], r["require"]) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
775 self.assertFalse("new-key" in r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
776 self.assertFalse("cond" in r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
777 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
778 def test_simple_replace_when_ref_true(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
779 schema = data_schema._Schema( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
780 None, True, {"type": None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
781 "require": ["huhu", "haha"], |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
782 "cond": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
783 {"when-ref-true": '#foo', |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
784 "then": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
785 "require": ["r1", "r2", "r3"], |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
786 "new-key": None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
787 }} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
788 ]}) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
789 r = data_schema.process_schema_conditionals(schema, self._ctx) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
790 self.assertIsNot(r, schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
791 self.assertEqual(["r1", "r2", "r3"], r["require"]) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
792 self.assertTrue("new-key" in r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
793 self.assertIsNone(r["new-key"]) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
794 self.assertFalse("cond" in r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
795 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
796 def test_simple_replace_when_ref_true_2(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
797 schema = data_schema._Schema( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
798 None, True, {"type": None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
799 "require": ["huhu", "haha"], |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
800 "cond": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
801 {"when": {"ref-true": '#foo'}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
802 "then": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
803 "require": ["r1", "r2", "r3"], |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
804 "new-key": None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
805 }} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
806 ]}) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
807 r = data_schema.process_schema_conditionals(schema, self._ctx) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
808 self.assertIsNot(r, schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
809 self.assertEqual(["r1", "r2", "r3"], r["require"]) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
810 self.assertTrue("new-key" in r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
811 self.assertIsNone(r["new-key"]) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
812 self.assertFalse("cond" in r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
813 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
814 def test_simple_replace_when_ref_is_not_true(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
815 schema = data_schema._Schema( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
816 None, True, {"type": None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
817 "require": ["huhu", "haha"], |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
818 "cond": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
819 {"when-ref-true": '#not-a-foo', |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
820 "then": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
821 "require": ["r1", "r2", "r3"], |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
822 "new-key": None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
823 }} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
824 ]}) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
825 r = data_schema.process_schema_conditionals(schema, self._ctx) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
826 self.assertIsNot(r, schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
827 self.assertEqual(["huhu", "haha"], r["require"]) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
828 self.assertTrue("new-key" not in r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
829 self.assertFalse("cond" in r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
830 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
831 def test_simple_replace_when_ref_is_not_true_2(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
832 schema = data_schema._Schema( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
833 None, True, {"type": None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
834 "require": ["huhu", "haha"], |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
835 "cond": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
836 {"when": {"ref-true": '#not-a-foo'}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
837 "then": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
838 "require": ["r1", "r2", "r3"], |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
839 "new-key": None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
840 }} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
841 ]}) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
842 r = data_schema.process_schema_conditionals(schema, self._ctx) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
843 self.assertIsNot(r, schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
844 self.assertEqual(["huhu", "haha"], r["require"]) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
845 self.assertTrue("new-key" not in r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
846 self.assertFalse("cond" in r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
847 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
848 def test_simple_replace_when_ref_exists(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
849 schema = data_schema._Schema( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
850 None, True, {"type": None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
851 "require": ["huhu", "haha"], |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
852 "cond": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
853 {"when-ref-exists": '#foo2', |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
854 "then": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
855 "require": ["r1", "r2", "r3"], |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
856 "new-key": None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
857 }}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
858 {"when": True, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
859 "then": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
860 "new-key3": "val"}} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
861 ]}) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
862 r = data_schema.process_schema_conditionals(schema, self._ctx) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
863 self.assertIsNot(r, schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
864 self.assertEqual(["r1", "r2", "r3"], r["require"]) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
865 self.assertTrue("new-key" in r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
866 self.assertIsNone(r["new-key"]) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
867 self.assertFalse("new-key3" in r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
868 self.assertFalse("cond" in r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
869 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
870 def test_simple_replace_when_ref_exists_2(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
871 schema = data_schema._Schema( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
872 None, True, {"type": None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
873 "require": ["huhu", "haha"], |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
874 "cond": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
875 {"when": {"ref-exists": '#foo2'}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
876 "then": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
877 "require": ["r1", "r2", "r3"], |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
878 "new-key": None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
879 }}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
880 {"when": True, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
881 "then": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
882 "new-key3": "val"}} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
883 ]}) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
884 r = data_schema.process_schema_conditionals(schema, self._ctx) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
885 self.assertIsNot(r, schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
886 self.assertEqual(["r1", "r2", "r3"], r["require"]) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
887 self.assertTrue("new-key" in r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
888 self.assertIsNone(r["new-key"]) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
889 self.assertFalse("new-key3" in r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
890 self.assertFalse("cond" in r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
891 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
892 def test_simple_replace_when_ref_exists_is_false(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
893 schema = data_schema._Schema( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
894 None, True, {"type": None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
895 "cond": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
896 {"when-ref-exists": '#foo-not-existing', |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
897 "then": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
898 "require": ["r1", "r2", "r3"], |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
899 "new-key": None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
900 }}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
901 {"when": True, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
902 "then": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
903 "new-key3": "val"}} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
904 ]}) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
905 r = data_schema.process_schema_conditionals(schema, self._ctx) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
906 self.assertIsNot(r, schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
907 self.assertFalse("require" in r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
908 self.assertFalse("new-key" in r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
909 self.assertEqual("val", r["new-key3"]) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
910 self.assertFalse("cond" in r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
911 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
912 def test_simple_replace_when_ref_exists_is_false_2(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
913 schema = data_schema._Schema( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
914 None, True, {"type": None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
915 "cond": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
916 {"when": {"ref-exists": '#foo-not-existing'}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
917 "then": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
918 "require": ["r1", "r2", "r3"], |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
919 "new-key": None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
920 }}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
921 {"when": True, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
922 "then": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
923 "new-key3": "val"}} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
924 ]}) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
925 r = data_schema.process_schema_conditionals(schema, self._ctx) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
926 self.assertIsNot(r, schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
927 self.assertFalse("require" in r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
928 self.assertFalse("new-key" in r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
929 self.assertEqual("val", r["new-key3"]) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
930 self.assertFalse("cond" in r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
931 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
932 def test_allOf_true(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
933 schema = data_schema._Schema( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
934 None, True, {"cond": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
935 {"when": {"all-of": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
936 True, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
937 {"ref-exists": '#foo2'}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
938 {"ref-true": '#foo'}]}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
939 "then": {"type": "string"}}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
940 {"when": True, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
941 "then": {"type": None}} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
942 ]}) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
943 r = data_schema.process_schema_conditionals(schema, self._ctx) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
944 self.assertIsNot(r, schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
945 self.assertEqual("string", r["type"]) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
946 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
947 def test_allOf_false(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
948 schema = data_schema._Schema( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
949 None, True, {"cond": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
950 {"when": {"all-of": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
951 True, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
952 {"ref-exists": '#foo-non-existing'}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
953 {"ref-true": '#foo'}]}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
954 "then": {"type": "string"}}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
955 {"when": True, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
956 "then": {"type": None}} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
957 ]}) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
958 r = data_schema.process_schema_conditionals(schema, self._ctx) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
959 self.assertIsNot(r, schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
960 self.assertIsNone(r["type"]) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
961 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
962 def test_short_allOf_true(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
963 schema = data_schema._Schema( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
964 None, True, {"cond": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
965 {"when": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
966 True, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
967 {"ref-exists": '#foo2'}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
968 {"ref-true": '#foo'}], |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
969 "then": {"type": "string"}}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
970 {"when": True, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
971 "then": {"type": None}} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
972 ]}) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
973 r = data_schema.process_schema_conditionals(schema, self._ctx) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
974 self.assertIsNot(r, schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
975 self.assertEqual("string", r["type"]) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
976 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
977 def test_short_allOf_false(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
978 schema = data_schema._Schema( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
979 None, True, {"cond": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
980 {"when": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
981 True, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
982 {"ref-exists": '#foo-non-existing'}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
983 {"ref-true": '#foo'}], |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
984 "then": {"type": "string"}}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
985 {"when": True, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
986 "then": {"type": None}} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
987 ]}) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
988 r = data_schema.process_schema_conditionals(schema, self._ctx) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
989 self.assertIsNot(r, schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
990 self.assertIsNone(r["type"]) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
991 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
992 def test_anyOf_true(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
993 schema = data_schema._Schema( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
994 None, True, {"cond": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
995 {"when": {"any-of": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
996 False, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
997 {"ref-exists": '#foo2'}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
998 {"ref-true": '#foo'}]}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
999 "then": {"type": "string"}}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1000 {"when": True, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1001 "then": {"type": None}} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1002 ]}) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1003 r = data_schema.process_schema_conditionals(schema, self._ctx) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1004 self.assertIsNot(r, schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1005 self.assertEqual("string", r["type"]) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1006 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1007 def test_anyOf_false(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1008 schema = data_schema._Schema( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1009 None, True, {"cond": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1010 {"when": {"any-of": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1011 False, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1012 {"ref-exists": '#foo2-non'}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1013 {"ref-true": '#foo2'}]}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1014 "then": {"type": "string"}}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1015 {"when": True, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1016 "then": {"type": None}} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1017 ]}) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1018 r = data_schema.process_schema_conditionals(schema, self._ctx) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1019 self.assertIsNot(r, schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1020 self.assertIsNone(r["type"]) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1021 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1022 def test_oneOf_true(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1023 schema = data_schema._Schema( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1024 None, True, {"cond": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1025 {"when": {"one-of": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1026 False, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1027 {"ref-exists": '#foo2'}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1028 {"not": {"ref-true": '#foo'}}]}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1029 "then": {"type": "string"}}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1030 {"when": True, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1031 "then": {"type": None}} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1032 ]}) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1033 r = data_schema.process_schema_conditionals(schema, self._ctx) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1034 self.assertIsNot(r, schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1035 self.assertEqual("string", r["type"]) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1036 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1037 def test_oneOf_false(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1038 schema = data_schema._Schema( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1039 None, True, {"cond": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1040 {"when": {"one-of": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1041 False, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1042 {"ref-exists": '#foo2'}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1043 {"ref-true": '#foo'}]}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1044 "then": {"type": "string"}}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1045 {"when": True, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1046 "then": {"type": None}} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1047 ]}) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1048 r = data_schema.process_schema_conditionals(schema, self._ctx) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1049 self.assertIsNot(r, schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1050 self.assertIsNone(r["type"]) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1051 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1052 def test_oneOf_false_2(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1053 schema = data_schema._Schema( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1054 None, True, {"cond": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1055 {"when": {"one-of": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1056 False, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1057 {"not": {"ref-exists": '#foo2'}}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1058 {"not": {"ref-true": '#foo'}}]}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1059 "then": {"type": "string"}}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1060 {"when": True, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1061 "then": {"type": None}} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1062 ]}) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1063 r = data_schema.process_schema_conditionals(schema, self._ctx) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1064 self.assertIsNot(r, schema) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1065 self.assertIsNone(r["type"]) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1066 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1067 def test_match_nothing(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1068 schema = data_schema._Schema( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1069 None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1070 True, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1071 { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1072 "match": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1073 {"when": False, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1074 "then": {"new-key": None}}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1075 {"when": False, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1076 "then": {"new-key2": None}} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1077 ]}) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1078 r = data_schema.process_schema_conditionals(schema, self._ctx) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1079 self.assertFalse("new-key" in r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1080 self.assertFalse("new-key2" in r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1081 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1082 def test_match_all(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1083 schema = data_schema._Schema( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1084 None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1085 True, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1086 { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1087 "match": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1088 {"when": True, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1089 "then": {"new-key": "value"}}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1090 {"when": True, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1091 "then": {"new-key2": "value2"}} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1092 ]}) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1093 r = data_schema.process_schema_conditionals(schema, self._ctx) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1094 self.assertEqual("value", r["new-key"]) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1095 self.assertEqual("value2", r["new-key2"]) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1096 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1097 def test_match_some(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1098 schema = data_schema._Schema( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1099 None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1100 True, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1101 { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1102 "match": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1103 {"when": True, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1104 "then": {"new-key": "value"}}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1105 {"when": False, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1106 "then": {"new-key2": "value2"}}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1107 {"when": True, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1108 "then": {"new-key3": "value3"}}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1109 {"when": False, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1110 "then": {"new-key4": "value4"}} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1111 ]}) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1112 r = data_schema.process_schema_conditionals(schema, self._ctx) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1113 self.assertEqual("value", r["new-key"]) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1114 self.assertFalse("new-key2" in r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1115 self.assertEqual("value3", r["new-key3"]) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1116 self.assertFalse("new-key4" in r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1117 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1118 def test_match_some_merge(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1119 schema = data_schema._Schema( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1120 None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1121 True, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1122 {"match": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1123 {"when": True, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1124 "then": {"new-key": [1, 2]}}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1125 {"when": False, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1126 "then": {"new-key2": "value2"}}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1127 {"when": True, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1128 "then-merge": {"new-key": ["value3"]}}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1129 {"when": False, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1130 "then": {"new-key3": "value3"}} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1131 ]}) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1132 r = data_schema.process_schema_conditionals(schema, self._ctx) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1133 self.assertEqual([1, 2, "value3"], r["new-key"]) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1134 self.assertFalse("new-key2" in r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1135 self.assertFalse("new-key3" in r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1136 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1137 def test_match_some_replace(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1138 schema = data_schema._Schema( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1139 None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1140 True, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1141 {"match": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1142 {"when": True, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1143 "then": {"new-key": [1, 2]}}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1144 {"when": False, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1145 "then": {"new-key2": "value2"}}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1146 {"when": True, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1147 "then-replace": {"new-key": ["value3"]}}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1148 {"when": True, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1149 "then": {"new-key3": "value3"}} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1150 ]}) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1151 r = data_schema.process_schema_conditionals(schema, self._ctx) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1152 self.assertEqual(["value3"], r["new-key"]) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1153 self.assertFalse("new-key2" in r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1154 self.assertEqual("value3", r["new-key3"]) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1155 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1156 def test_match_some_merge_existing(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1157 # the typical case within vlobby: just extend "required" |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1158 schema = data_schema._Schema( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1159 None, True, {"required": [1, 2], |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1160 "match": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1161 {"when": True, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1162 "then": {"required": [3, 4]}}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1163 {"when": False, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1164 "then": {"required": [0]}}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1165 {"when": True, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1166 "then-merge": {"required": [5, 6, 7]}}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1167 {"when": True, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1168 "then-merge": {"required": [4, 8]}} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1169 ]}) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1170 r = data_schema.process_schema_conditionals(schema, self._ctx) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1171 self.assertEqual([3, 4, 5, 6, 7, 4, 8], r["required"]) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1172 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1173 def test_equal_ref_and_value(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1174 schema = data_schema._Schema( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1175 None, True, {"foos": "bar", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1176 "match": [{ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1177 "when": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1178 "equals": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1179 {"ref": "object:#foo"}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1180 {"value": "bar"}]}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1181 "then-replace": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1182 "foos": "new-bar"}}] |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1183 }) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1184 r = data_schema.process_schema_conditionals(schema, self._ctx) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1185 self.assertEqual("new-bar", r["foos"]) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1186 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1187 def test_equal_val_and_ref(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1188 schema = data_schema._Schema( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1189 None, True, {"foos": "bar", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1190 "cond": [{ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1191 "when": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1192 "equals": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1193 {"val": "bar"}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1194 {"ref": "object:#foo"}]}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1195 "then-replace": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1196 "foos": "new-bar"}}] |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1197 }) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1198 r = data_schema.process_schema_conditionals(schema, self._ctx) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1199 self.assertEqual("new-bar", r["foos"]) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1200 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1201 def test_equal_no_list(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1202 schema = data_schema._Schema( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1203 None, True, {"foos": "bar", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1204 "match": [{ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1205 "when": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1206 "equals": {"type": None}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1207 "then-replace": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1208 "foos": "new-bar"}}}] |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1209 }) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1210 self.assertRaises( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1211 data_schema.SchemaError, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1212 data_schema.process_schema_conditionals, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1213 schema, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1214 self._ctx) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1215 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1216 def test_equal_list_length_mismatch_1(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1217 schema = data_schema._Schema( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1218 None, True, {"foo": "bar", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1219 "match": [{ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1220 "when": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1221 "equals": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1222 {"ref": "object:#foo"}]}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1223 "then-replace": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1224 "foo": "new-bar"}}] |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1225 }) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1226 self.assertRaises( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1227 data_schema.SchemaError, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1228 data_schema.process_schema_conditionals, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1229 schema, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1230 self._ctx) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1231 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1232 def test_equal_list_length_mismatch_3(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1233 schema = data_schema._Schema( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1234 None, True, {"foo": "bar", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1235 "match": [{ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1236 "when": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1237 "equals": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1238 {"ref": "object:#foo"}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1239 {"ref": "object:#foo"}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1240 {"ref": "object:#foo"}]}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1241 "then-replace": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1242 "foo": "new-bar"}}] |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1243 }) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1244 self.assertRaises( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1245 data_schema.SchemaError, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1246 data_schema.process_schema_conditionals, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1247 schema, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1248 self._ctx) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1249 |
|
28
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
1250 def test_raise_no_schema_loader_available(self): |
|
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
1251 settings = data_schema.ValidationSettings( |
|
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
1252 skip_keys=[], break_on_keynames_problems=True, |
|
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
1253 schema_loader=None) |
|
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
1254 schema = data_schema._Schema( |
|
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
1255 None, True, {"$ref": "schema:file:/tmp/xxx#/"}) |
|
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
1256 ctx = data_schema.Context( |
|
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
1257 None, root_schema=schema, settings=settings) |
|
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
1258 self.assertRaises( |
|
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
1259 data_schema.SchemaError, |
|
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
1260 data_schema.process_schema_references, |
|
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
1261 schema, |
|
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
1262 ctx) |
|
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
1263 |
|
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
1264 def test_raise_schema_loader_available_but_invalid_basedir(self): |
|
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
1265 settings = data_schema.ValidationSettings( |
|
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
1266 skip_keys=[], break_on_keynames_problems=True, |
|
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
1267 schema_loader=data_schema.default_schema_loader) |
|
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
1268 schema = data_schema._Schema( |
|
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
1269 None, True, {"$ref": "schema:file:/tmp/xxx#/"}) |
|
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
1270 ctx = data_schema.Context( |
|
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
1271 None, root_schema=schema, settings=settings) |
|
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
1272 self.assertRaises( |
|
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
1273 TypeError, # no basedir given |
|
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
1274 data_schema.process_schema_references, |
|
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
1275 schema, |
|
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
1276 ctx) |
|
db3491e1b590
Allow to customize the loading of the schema dict
Franz Glasner <fzglas.hg@dom66.de>
parents:
19
diff
changeset
|
1277 |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1278 def test_raise_if_scheme_ref_is_not_the_single_key(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1279 schema = data_schema._Schema( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1280 None, True, {"$ref": "schema:#/", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1281 "type": None |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1282 }) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1283 ctx = data_schema.Context( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1284 None, root_schema=schema, settings=None) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1285 self.assertRaises( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1286 data_schema.SchemaError, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1287 data_schema.process_schema_references, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1288 schema, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1289 ctx) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1290 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1291 def test_raise_if_scheme_ref_is_not_the_single_key_root(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1292 schema = data_schema._Schema( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1293 None, True, {"$ref": "schema:#/subschema", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1294 "subschema": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1295 "type": None |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1296 } |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1297 }) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1298 ctx = data_schema.Context( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1299 None, root_schema=schema, settings=None) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1300 r = data_schema.process_schema_references( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1301 schema, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1302 ctx, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1303 check_single_ref_key=False) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1304 self.assertEqual({"type": None}, r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1305 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1306 def test_recursive_schema_scheme(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1307 barschema = { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1308 "type": "null" |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1309 } |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1310 fooschema = { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1311 "$ref": "schema:#/bar" |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1312 } |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1313 schema = data_schema._Schema( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1314 None, True, {"foo": fooschema, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1315 "bar": barschema, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1316 "$ref": "schema:#/foo" |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1317 }) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1318 ctx = data_schema.Context( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1319 None, root_schema=schema, settings=None) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1320 r = data_schema.process_schema_references( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1321 schema, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1322 ctx, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1323 check_single_ref_key=False) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1324 self.assertEqual({"type": "null"}, r) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1325 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1326 def test_recursive_schema_scheme_raises_if_non_root_is_not_single_key(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1327 barschema = { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1328 "type": "null" |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1329 } |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1330 fooschema = { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1331 "$ref": "schema:#/bar", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1332 "type": "dict", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1333 } |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1334 schema = data_schema._Schema( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1335 None, True, { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1336 "foo": fooschema, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1337 "bar": barschema, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1338 "$ref": "schema:#/foo" |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1339 }) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1340 ctx = data_schema.Context( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1341 None, root_schema=schema, settings=None) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1342 self.assertRaises( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1343 data_schema.SchemaError, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1344 data_schema.process_schema_references, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1345 schema, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1346 ctx, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1347 check_single_ref_key=False) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1348 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1349 def test_recursive_schema_scheme_ref_to_non_existing_schema_raises(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1350 barschema = { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1351 "type": "null" |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1352 } |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1353 fooschema = { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1354 "$ref": "schema:#/non-bar", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1355 } |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1356 schema = data_schema._Schema( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1357 None, True, { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1358 "foo": fooschema, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1359 "bar": barschema, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1360 "$ref": "schema:#/foo" |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1361 }) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1362 ctx = data_schema.Context( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1363 None, root_schema=schema, settings=None) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1364 self.assertRaises( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1365 data_schema.SchemaError, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1366 data_schema.process_schema_references, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1367 schema, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1368 ctx, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1369 check_single_ref_key=False) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1370 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1371 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1372 class BasicValidation(unittest.TestCase): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1373 |
|
15
696b83f29363
Use enum props when printing validation problems
Franz Glasner <fzglas.hg@dom66.de>
parents:
13
diff
changeset
|
1374 def test_enum_name(self): |
|
696b83f29363
Use enum props when printing validation problems
Franz Glasner <fzglas.hg@dom66.de>
parents:
13
diff
changeset
|
1375 code = ERRORS.E10001 |
|
696b83f29363
Use enum props when printing validation problems
Franz Glasner <fzglas.hg@dom66.de>
parents:
13
diff
changeset
|
1376 self.assertEqual("ERRORS.E10001", str(code)) |
|
696b83f29363
Use enum props when printing validation problems
Franz Glasner <fzglas.hg@dom66.de>
parents:
13
diff
changeset
|
1377 self.assertEqual("E10001", code.name) |
|
16
2a9e7c4b717e
Problem severity now is also an enum
Franz Glasner <fzglas.hg@dom66.de>
parents:
15
diff
changeset
|
1378 self.assertTrue(isinstance(code, ERRORS)) |
|
15
696b83f29363
Use enum props when printing validation problems
Franz Glasner <fzglas.hg@dom66.de>
parents:
13
diff
changeset
|
1379 |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1380 def test_schema_must_be_a_dict_alike(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1381 try: |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1382 pr = list(data_schema.validate(None, None)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1383 except data_schema.SchemaError: |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1384 pass |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1385 else: |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1386 self.assertFalse( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1387 "no SchemaError raised when a non-dict given as schema") |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1388 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1389 def test_problem_ctor_no_code(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1390 self.assertRaises(TypeError, data_schema.ValidationProblem, code=None) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1391 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1392 def test_error_ctor(self): |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1393 v = data_schema.ValidationProblem(code=ERRORS.E10000) |
|
16
2a9e7c4b717e
Problem severity now is also an enum
Franz Glasner <fzglas.hg@dom66.de>
parents:
15
diff
changeset
|
1394 self.assertEqual(SEVERITY.ERROR, v.severity) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1395 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1396 def test_warning_ctor(self): |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1397 v = data_schema.ValidationProblem(code=WARNINGS.W80000) |
|
16
2a9e7c4b717e
Problem severity now is also an enum
Franz Glasner <fzglas.hg@dom66.de>
parents:
15
diff
changeset
|
1398 self.assertEqual(SEVERITY.WARNING, v.severity) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1399 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1400 def test_d1(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1401 x = list(data_schema.validate({}, {"type": "dict"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1402 self.assertEqual(0, len(x)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1403 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1404 def test_d1_not_nullable(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1405 x = list(data_schema.validate(None, {"type": "dict"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1406 self.assertEqual(1, len(x)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1407 self.assertEqual(ERRORS.E10000, x[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1408 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1409 def test_d1_nullable(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1410 x = list(data_schema.validate(None, {"type": "dict", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1411 "nullable": True})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1412 self.assertEqual(0, len(x)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1413 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1414 def test_d2(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1415 x = list(data_schema.validate([], {"type": "map"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1416 self.assertEqual(1, len(x)) |
|
16
2a9e7c4b717e
Problem severity now is also an enum
Franz Glasner <fzglas.hg@dom66.de>
parents:
15
diff
changeset
|
1417 self.assertEqual(SEVERITY.ERROR, x[0].severity) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1418 self.assertEqual(ERRORS.E10000, x[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1419 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1420 def test_d3(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1421 x = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1422 {"key": "value"}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1423 {"type": "dict", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1424 "required": ["key2"]})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1425 self.assertEqual(2, len(x)) |
|
16
2a9e7c4b717e
Problem severity now is also an enum
Franz Glasner <fzglas.hg@dom66.de>
parents:
15
diff
changeset
|
1426 self.assertEqual(SEVERITY.ERROR, x[0].severity) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1427 self.assertEqual(ERRORS.E10004, x[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1428 self.assertEqual("key", x[0].hint) |
|
16
2a9e7c4b717e
Problem severity now is also an enum
Franz Glasner <fzglas.hg@dom66.de>
parents:
15
diff
changeset
|
1429 self.assertEqual(SEVERITY.ERROR, x[1].severity) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1430 self.assertEqual(ERRORS.E10005, x[1].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1431 self.assertEqual(["key2"], x[1].hint) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1432 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1433 def test_d4(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1434 x = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1435 {"key": "value"}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1436 {"type": "dict", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1437 "keys": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1438 "key": {"type": "string"}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1439 }, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1440 "required": ["key"]})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1441 self.assertEqual(0, len(x)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1442 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1443 def test_d5(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1444 x = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1445 {"key": "value"}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1446 {"type": "dict", |
|
19
c3a0fe8d4587
Consistent casing of schema items: all lowercase with dash as separator
Franz Glasner <fzglas.hg@dom66.de>
parents:
16
diff
changeset
|
1447 "additional-keys": False})) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1448 self.assertEqual(1, len(x)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1449 self.assertEqual(ERRORS.E10004, x[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1450 self.assertEqual("key", x[0].hint) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1451 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1452 def test_d5_2(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1453 x = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1454 {"key": "value"}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1455 {"type": "dict", |
|
19
c3a0fe8d4587
Consistent casing of schema items: all lowercase with dash as separator
Franz Glasner <fzglas.hg@dom66.de>
parents:
16
diff
changeset
|
1456 "additional-keys": False}, |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1457 skip_keys=["key"])) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1458 self.assertEqual(0, len(x)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1459 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1460 def test_d5_3(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1461 x = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1462 {"key": "value", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1463 "key2": "value"}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1464 {"type": "dict", |
|
19
c3a0fe8d4587
Consistent casing of schema items: all lowercase with dash as separator
Franz Glasner <fzglas.hg@dom66.de>
parents:
16
diff
changeset
|
1465 "additional-keys": False}, |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1466 skip_keys=[re.compile(r"\Akey\d*\Z")])) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1467 self.assertEqual(0, len(x)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1468 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1469 def test_d5_4(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1470 x = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1471 {"key": "value", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1472 "key2": "value"}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1473 {"type": "dict", |
|
19
c3a0fe8d4587
Consistent casing of schema items: all lowercase with dash as separator
Franz Glasner <fzglas.hg@dom66.de>
parents:
16
diff
changeset
|
1474 "additional-keys": False}, |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1475 skip_keys=[re.compile(r"\A__.+"), re.compile(r"\Akey\d+\Z")])) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1476 self.assertEqual(1, len(x)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1477 self.assertEqual(ERRORS.E10004, x[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1478 self.assertEqual("key", x[0].hint) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1479 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1480 def test_d6(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1481 x = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1482 {"key": "value"}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1483 {"type": "dict", |
|
19
c3a0fe8d4587
Consistent casing of schema items: all lowercase with dash as separator
Franz Glasner <fzglas.hg@dom66.de>
parents:
16
diff
changeset
|
1484 "additional-keys": True})) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1485 self.assertEqual(0, len(x)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1486 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1487 def test_d7(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1488 x = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1489 {"key": "value"}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1490 {"type": "dict", |
|
19
c3a0fe8d4587
Consistent casing of schema items: all lowercase with dash as separator
Franz Glasner <fzglas.hg@dom66.de>
parents:
16
diff
changeset
|
1491 "additional-keys": { |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1492 "type": "string"}})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1493 self.assertEqual(0, len(x)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1494 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1495 def test_d8(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1496 x = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1497 {"key": 1234}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1498 {"type": "dict", |
|
19
c3a0fe8d4587
Consistent casing of schema items: all lowercase with dash as separator
Franz Glasner <fzglas.hg@dom66.de>
parents:
16
diff
changeset
|
1499 "additional-keys": { |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1500 "type": "string"}})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1501 self.assertEqual(1, len(x)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1502 self.assertEqual(ERRORS.E10002, x[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1503 self.assertEqual(1234, x[0].hint) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1504 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1505 def test_d8_2(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1506 x = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1507 {"key": 1234}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1508 {"type": "dict", |
|
19
c3a0fe8d4587
Consistent casing of schema items: all lowercase with dash as separator
Franz Glasner <fzglas.hg@dom66.de>
parents:
16
diff
changeset
|
1509 "additional-keys": { |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1510 "type": "string"}}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1511 skip_keys=["key"])) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1512 self.assertEqual(0, len(x)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1513 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1514 def test_d9_non_string_keys(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1515 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1516 {0: "value"}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1517 {"type": "dict", |
|
19
c3a0fe8d4587
Consistent casing of schema items: all lowercase with dash as separator
Franz Glasner <fzglas.hg@dom66.de>
parents:
16
diff
changeset
|
1518 "additional-keys": True})) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1519 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1520 self.assertEqual(ERRORS.E10003, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1521 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1522 def test_d10_int_dict_keys(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1523 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1524 {1: "value", 2: "value2"}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1525 {"type": "dict", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1526 "keys": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1527 1: {"type": "string"}}, |
|
19
c3a0fe8d4587
Consistent casing of schema items: all lowercase with dash as separator
Franz Glasner <fzglas.hg@dom66.de>
parents:
16
diff
changeset
|
1528 "additional-keys": True, |
|
c3a0fe8d4587
Consistent casing of schema items: all lowercase with dash as separator
Franz Glasner <fzglas.hg@dom66.de>
parents:
16
diff
changeset
|
1529 "key-names": {"type": "int"}})) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1530 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1531 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1532 def test_error_message(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1533 self.assertEqual("dict expected", |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1534 data_schema.problem_message(ERRORS.E10000)) |
|
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1535 pr = data_schema.ValidationProblem(code=ERRORS.E10000) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1536 self.assertEqual("dict expected", data_schema.problem_message(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1537 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1538 self.assertEqual("duplicate dict key", |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1539 data_schema.problem_message(WARNINGS.W80000)) |
|
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1540 pr = data_schema.ValidationProblem(code=WARNINGS.W80000) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1541 self.assertEqual("duplicate dict key", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1542 data_schema.problem_message(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1543 |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1544 self.assertRaises(KeyError, data_schema.problem_message, 12345) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1545 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1546 def test_str_enum(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1547 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1548 "e1", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1549 {"type": "string", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1550 "enum": ["e1", "e2"]})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1551 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1552 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1553 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1554 "e2", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1555 {"type": "string", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1556 "enum": ["e1", "e2"]})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1557 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1558 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1559 def test_str_not_in_enum(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1560 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1561 "e3", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1562 {"type": "string", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1563 "enum": ["e1", "e2"]})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1564 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1565 self.assertEqual(ERRORS.E10043, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1566 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1567 def test_str_minlen(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1568 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1569 "", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1570 {"type": "string", |
|
19
c3a0fe8d4587
Consistent casing of schema items: all lowercase with dash as separator
Franz Glasner <fzglas.hg@dom66.de>
parents:
16
diff
changeset
|
1571 "min-length": 0})) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1572 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1573 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1574 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1575 "", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1576 {"type": "string", |
|
19
c3a0fe8d4587
Consistent casing of schema items: all lowercase with dash as separator
Franz Glasner <fzglas.hg@dom66.de>
parents:
16
diff
changeset
|
1577 "min-length": 1})) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1578 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1579 self.assertEqual(ERRORS.E10006, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1580 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1581 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1582 "x", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1583 {"type": "string", |
|
19
c3a0fe8d4587
Consistent casing of schema items: all lowercase with dash as separator
Franz Glasner <fzglas.hg@dom66.de>
parents:
16
diff
changeset
|
1584 "min-length": 1})) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1585 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1586 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1587 def test_str_maxlen(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1588 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1589 "", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1590 {"type": "string", |
|
19
c3a0fe8d4587
Consistent casing of schema items: all lowercase with dash as separator
Franz Glasner <fzglas.hg@dom66.de>
parents:
16
diff
changeset
|
1591 "max-length": 0})) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1592 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1593 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1594 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1595 "x", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1596 {"type": "string", |
|
19
c3a0fe8d4587
Consistent casing of schema items: all lowercase with dash as separator
Franz Glasner <fzglas.hg@dom66.de>
parents:
16
diff
changeset
|
1597 "max-length": 0})) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1598 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1599 self.assertEqual(ERRORS.E10007, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1600 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1601 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1602 "x", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1603 {"type": "string", |
|
19
c3a0fe8d4587
Consistent casing of schema items: all lowercase with dash as separator
Franz Glasner <fzglas.hg@dom66.de>
parents:
16
diff
changeset
|
1604 "max-length": 1})) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1605 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1606 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1607 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1608 b"x", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1609 {"type": "string", |
|
19
c3a0fe8d4587
Consistent casing of schema items: all lowercase with dash as separator
Franz Glasner <fzglas.hg@dom66.de>
parents:
16
diff
changeset
|
1610 "max-length": 1})) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1611 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1612 self.assertEqual(ERRORS.E10002, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1613 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1614 @staticmethod |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1615 def _pattern_check_function(obj, schema, context=None): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1616 if obj == " 5 ": |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1617 yield data_schema.ValidationProblem(code=ERRORS.E10009) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1618 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1619 def test_str_re(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1620 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1621 "abc", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1622 {"type": "string", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1623 "pattern": r'\A[0-9]+\Z'})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1624 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1625 self.assertEqual(ERRORS.E10008, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1626 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1627 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1628 "123", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1629 {"type": "string", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1630 "pattern": re.compile(r'\A[a-z]+\Z')})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1631 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1632 self.assertEqual(ERRORS.E10008, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1633 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1634 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1635 "123", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1636 {"type": "string", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1637 "pattern": self._pattern_check_function})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1638 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1639 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1640 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1641 " 5 ", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1642 {"type": "string", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1643 "pattern": self._pattern_check_function})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1644 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1645 self.assertEqual(ERRORS.E10009, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1646 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1647 def test_binary_basic(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1648 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1649 b"", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1650 {"type": "binary"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1651 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1652 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1653 def test_str_is_not_binary(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1654 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1655 "", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1656 {"type": "binary"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1657 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1658 self.assertEqual(ERRORS.E10035, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1659 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1660 @staticmethod |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1661 def _binary_pattern_check_function(obj, schema, context=None): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1662 if obj != b"\x00": |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1663 yield data_schema.ValidationProblem(code=ERRORS.E10009) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1664 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1665 def test_binary_pattern_check(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1666 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1667 b"\x00", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1668 {"type": "binary", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1669 "pattern": self._binary_pattern_check_function})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1670 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1671 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1672 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1673 b"\x01", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1674 {"type": "binary", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1675 "pattern": self._binary_pattern_check_function})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1676 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1677 self.assertEqual(ERRORS.E10009, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1678 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1679 def test_binary_re_str_match(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1680 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1681 b"\x00\x00\x00", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1682 {"type": "binary", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1683 "pattern": u"\\x00+"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1684 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1685 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1686 def test_binary_re_bytes_match(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1687 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1688 b"\x00\x00\x00", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1689 {"type": "binary", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1690 "pattern": b"\x00+"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1691 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1692 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1693 def test_binary_re_str_mismatch(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1694 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1695 b"\x00\x00\x00", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1696 {"type": "binary", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1697 "pattern": u"\\x01+"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1698 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1699 self.assertEqual(ERRORS.E10047, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1700 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1701 def test_binary_re_bytes_mismatch(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1702 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1703 b"\x00\x00\x00", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1704 {"type": "binary", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1705 "pattern": b"\x01+"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1706 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1707 self.assertEqual(ERRORS.E10047, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1708 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1709 def test_binary_length(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1710 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1711 b"", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1712 {"type": "binary", |
|
19
c3a0fe8d4587
Consistent casing of schema items: all lowercase with dash as separator
Franz Glasner <fzglas.hg@dom66.de>
parents:
16
diff
changeset
|
1713 "min-length": 1})) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1714 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1715 self.assertEqual(ERRORS.E10036, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1716 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1717 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1718 b"1", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1719 {"type": "binary", |
|
19
c3a0fe8d4587
Consistent casing of schema items: all lowercase with dash as separator
Franz Glasner <fzglas.hg@dom66.de>
parents:
16
diff
changeset
|
1720 "max-length": 0})) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1721 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1722 self.assertEqual(ERRORS.E10037, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1723 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1724 def test_deny(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1725 pr = list(data_schema.validate("abc", {"type": "deny"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1726 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1727 self.assertEqual(ERRORS.E10010, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1728 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1729 def test_accept(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1730 pr = list(data_schema.validate("abc", {"type": "accept"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1731 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1732 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1733 pr = list(data_schema.validate(None, {"type": "accept"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1734 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1735 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1736 def test_null(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1737 pr = list(data_schema.validate(None, {"type": "none"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1738 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1739 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1740 pr = list(data_schema.validate(None, {"type": "null"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1741 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1742 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1743 pr = list(data_schema.validate(None, {"type": "nil"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1744 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1745 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1746 pr = list(data_schema.validate(None, {"type": None})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1747 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1748 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1749 pr = list(data_schema.validate({}, {"type": None})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1750 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1751 self.assertEqual(ERRORS.E10011, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1752 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1753 def test_l1(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1754 pr = list(data_schema.validate([], {"type": "list"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1755 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1756 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1757 pr = list(data_schema.validate(tuple(), {"type": "list"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1758 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1759 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1760 def test_l1_not_nullable(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1761 pr = list(data_schema.validate(None, {"type": "list"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1762 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1763 self.assertEqual(ERRORS.E10001, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1764 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1765 def test_l1_nullable(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1766 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1767 None, {"type": "list", "nullable": True})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1768 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1769 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1770 def test_l2_default_schema_for_items_is_deny(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1771 pr = list(data_schema.validate(["a", "b", "c"], {"type": "list"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1772 self.assertEqual(3, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1773 for i in range(0, 3): |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1774 self.assertEqual(ERRORS.E10010, pr[i].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1775 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1776 def test_l3_schema_for_items(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1777 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1778 ["a", "b", "c"], |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1779 {"type": "array", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1780 "items": {"type": "string"}})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1781 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1782 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1783 def test_t1(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1784 pr = list(data_schema.validate([], {"type": "tuple"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1785 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1786 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1787 pr = list(data_schema.validate(tuple(), {"type": "tuple"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1788 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1789 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1790 def test_t1_not_nullable(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1791 pr = list(data_schema.validate(None, {"type": "tuple"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1792 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1793 self.assertEqual(ERRORS.E10014, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1794 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1795 def test_t1_nullable(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1796 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1797 None, {"type": "tuple", "nullable": True})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1798 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1799 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1800 def test_t2(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1801 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1802 ["a", None, {"key": "value"}], |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1803 {"type": "tuple", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1804 "items": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1805 {"type": "string"}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1806 {"type": None}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1807 {"type": "accept"}]})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1808 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1809 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1810 def test_t3(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1811 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1812 ["a", None, {"key": "value"}], |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1813 {"type": "tuple", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1814 "items": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1815 {"type": "string"}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1816 {"type": None}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1817 {"type": "deny"}]})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1818 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1819 self.assertEqual(ERRORS.E10010, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1820 self.assertEqual(2, pr[0].context.index) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1821 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1822 def test_t4(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1823 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1824 ["a", None, {"key": "value"}], |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1825 {"type": "tuple", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1826 "items": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1827 {"type": "string"}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1828 {"type": None}]})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1829 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1830 self.assertEqual(ERRORS.E10017, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1831 self.assertEqual(2, pr[0].context.index) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1832 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1833 def test_t5(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1834 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1835 ["a", None, {"key": "value"}], |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1836 {"type": "tuple", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1837 "items": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1838 {"type": "string"}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1839 {"type": None}], |
|
19
c3a0fe8d4587
Consistent casing of schema items: all lowercase with dash as separator
Franz Glasner <fzglas.hg@dom66.de>
parents:
16
diff
changeset
|
1840 "additional-items": True})) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1841 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1842 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1843 def test_t6(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1844 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1845 ["a", None, {"key": "value"}, {"key": "value"}], |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1846 {"type": "tuple", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1847 "items": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1848 {"type": "string"}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1849 {"type": None}], |
|
19
c3a0fe8d4587
Consistent casing of schema items: all lowercase with dash as separator
Franz Glasner <fzglas.hg@dom66.de>
parents:
16
diff
changeset
|
1850 "additional-items": { |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1851 "type": "dict", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1852 "keys": {"key": {"type": "string"}} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1853 }})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1854 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1855 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1856 def test_t7(self): |
|
19
c3a0fe8d4587
Consistent casing of schema items: all lowercase with dash as separator
Franz Glasner <fzglas.hg@dom66.de>
parents:
16
diff
changeset
|
1857 # do not check anything that exceeds max-length |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1858 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1859 ["a", None, {"key": "value"}, {"key": "value"}, {"key2": "value"}], |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1860 {"type": "tuple", |
|
19
c3a0fe8d4587
Consistent casing of schema items: all lowercase with dash as separator
Franz Glasner <fzglas.hg@dom66.de>
parents:
16
diff
changeset
|
1861 "max-length": 4, |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1862 "items": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1863 {"type": "string"}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1864 {"type": None}], |
|
19
c3a0fe8d4587
Consistent casing of schema items: all lowercase with dash as separator
Franz Glasner <fzglas.hg@dom66.de>
parents:
16
diff
changeset
|
1865 "additional-items": { |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1866 "type": "dict", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1867 "keys": {"key": {"type": "string"}} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1868 }})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1869 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1870 self.assertEqual(ERRORS.E10016, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1871 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1872 def test_t8(self): |
|
19
c3a0fe8d4587
Consistent casing of schema items: all lowercase with dash as separator
Franz Glasner <fzglas.hg@dom66.de>
parents:
16
diff
changeset
|
1873 # do not check anything that exceeds max-length |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1874 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1875 ["a", None, {"key": "value"}, {"key": "value"}, {"key2": "value"}], |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1876 {"type": "tuple", |
|
19
c3a0fe8d4587
Consistent casing of schema items: all lowercase with dash as separator
Franz Glasner <fzglas.hg@dom66.de>
parents:
16
diff
changeset
|
1877 "min-length": 6, |
|
c3a0fe8d4587
Consistent casing of schema items: all lowercase with dash as separator
Franz Glasner <fzglas.hg@dom66.de>
parents:
16
diff
changeset
|
1878 "max-length": 4, |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1879 "items": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1880 {"type": "string"}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1881 {"type": None}], |
|
19
c3a0fe8d4587
Consistent casing of schema items: all lowercase with dash as separator
Franz Glasner <fzglas.hg@dom66.de>
parents:
16
diff
changeset
|
1882 "additional-items": { |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1883 "type": "dict", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1884 "keys": {"key": {"type": "string"}} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1885 }})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1886 self.assertEqual(2, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1887 self.assertEqual(ERRORS.E10015, pr[0].code) |
|
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1888 self.assertEqual(ERRORS.E10016, pr[1].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1889 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1890 def test_set1(self): |
|
19
c3a0fe8d4587
Consistent casing of schema items: all lowercase with dash as separator
Franz Glasner <fzglas.hg@dom66.de>
parents:
16
diff
changeset
|
1891 # do not check anything that exceeds max-length |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1892 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1893 set(["a", None, "b"]), |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1894 {"type": "set", |
|
19
c3a0fe8d4587
Consistent casing of schema items: all lowercase with dash as separator
Franz Glasner <fzglas.hg@dom66.de>
parents:
16
diff
changeset
|
1895 "min-length": 3, |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1896 "items": {"any-of": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1897 {"type": "string"}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1898 {"type": None}]}} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1899 )) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1900 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1901 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1902 def test_set1_not_nullable(self): |
|
19
c3a0fe8d4587
Consistent casing of schema items: all lowercase with dash as separator
Franz Glasner <fzglas.hg@dom66.de>
parents:
16
diff
changeset
|
1903 # do not check anything that exceeds max-length |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1904 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1905 None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1906 {"type": "set"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1907 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1908 self.assertEqual(ERRORS.E10038, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1909 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1910 def test_set1_nullable(self): |
|
19
c3a0fe8d4587
Consistent casing of schema items: all lowercase with dash as separator
Franz Glasner <fzglas.hg@dom66.de>
parents:
16
diff
changeset
|
1911 # do not check anything that exceeds max-length |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1912 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1913 None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1914 {"type": "set", "nullable": True})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1915 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1916 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1917 def test_set2(self): |
|
19
c3a0fe8d4587
Consistent casing of schema items: all lowercase with dash as separator
Franz Glasner <fzglas.hg@dom66.de>
parents:
16
diff
changeset
|
1918 # do not check anything that exceeds max-length |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1919 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1920 set(["a", None, "b"]), |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1921 {"type": "set", |
|
19
c3a0fe8d4587
Consistent casing of schema items: all lowercase with dash as separator
Franz Glasner <fzglas.hg@dom66.de>
parents:
16
diff
changeset
|
1922 "min-length": 4, |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1923 "items": {"any-of": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1924 {"type": "string"}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1925 {"type": None}]}} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1926 )) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1927 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1928 self.assertEqual(ERRORS.E10039, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1929 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1930 def test_set3(self): |
|
19
c3a0fe8d4587
Consistent casing of schema items: all lowercase with dash as separator
Franz Glasner <fzglas.hg@dom66.de>
parents:
16
diff
changeset
|
1931 # do not check anything that exceeds max-length |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1932 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1933 set(["a", None, "b"]), |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1934 {"type": "set", |
|
19
c3a0fe8d4587
Consistent casing of schema items: all lowercase with dash as separator
Franz Glasner <fzglas.hg@dom66.de>
parents:
16
diff
changeset
|
1935 "max-length": 2, |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1936 "items": {"any-of": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1937 {"type": "string"}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1938 {"type": None}]}} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1939 )) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1940 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1941 self.assertEqual(ERRORS.E10040, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1942 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1943 def test_set4_itemschema(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1944 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1945 set(["a", None, "b"]), |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1946 {"type": "set", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1947 "items": {"any-of": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1948 {"type": "string"}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1949 {"type": "int"}]}} |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1950 )) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1951 codes = set([p.code for p in pr]) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1952 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1953 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1954 self.assertEqual(ERRORS.E10055, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1955 self.assertEqual(2, len(pr[0].cause)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1956 self.assertEqual(ERRORS.E10056, pr[0].cause[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1957 self.assertEqual(1, len(pr[0].cause[0].cause)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1958 self.assertEqual(ERRORS.E10002, pr[0].cause[0].cause[0].code) |
|
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1959 self.assertEqual(ERRORS.E10056, pr[0].cause[1].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1960 self.assertEqual(1, len(pr[0].cause[1].cause)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1961 self.assertEqual(ERRORS.E10020, pr[0].cause[1].cause[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1962 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1963 def test_empty(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1964 pr = list(data_schema.validate(None, {"type": "empty"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1965 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1966 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1967 pr = list(data_schema.validate([], {"type": "empty"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1968 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1969 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1970 pr = list(data_schema.validate(["a"], {"type": "empty"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1971 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1972 self.assertEqual(ERRORS.E10018, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1973 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1974 pr = list(data_schema.validate(tuple(), {"type": "empty"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1975 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1976 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1977 pr = list(data_schema.validate(set(), {"type": "empty"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1978 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1979 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1980 pr = list(data_schema.validate(frozenset(), {"type": "empty"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1981 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1982 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1983 pr = list(data_schema.validate(tuple(["a"]), {"type": "empty"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1984 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1985 self.assertEqual(ERRORS.E10018, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1986 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1987 pr = list(data_schema.validate({}, {"type": "empty"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1988 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1989 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1990 pr = list(data_schema.validate({"key": "value"}, {"type": "empty"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1991 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1992 self.assertEqual(ERRORS.E10018, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1993 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1994 pr = list(data_schema.validate("", {"type": "empty"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1995 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
1996 self.assertEqual(ERRORS.E10018, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1997 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1998 def test_allOf(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
1999 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2000 None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2001 {"type": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2002 "all-of": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2003 {"type": None}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2004 {"type": "accept"}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2005 ] |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2006 }})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2007 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2008 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2009 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2010 None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2011 {"type": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2012 "all-of": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2013 {"type": None}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2014 {"type": "accept"}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2015 {"type": "deny"}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2016 ] |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2017 }})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2018 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
2019 self.assertEqual(ERRORS.E10057, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2020 self.assertEqual(1, len(pr[0].cause)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
2021 self.assertEqual(ERRORS.E10058, pr[0].cause[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2022 self.assertEqual(1, len(pr[0].cause[0].cause)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
2023 self.assertEqual(ERRORS.E10010, pr[0].cause[0].cause[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2024 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2025 def test_anyOf(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2026 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2027 None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2028 {"type": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2029 "any-of": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2030 {"type": "deny"}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2031 {"type": None}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2032 ] |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2033 }})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2034 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2035 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2036 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2037 None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2038 {"type": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2039 "any-of": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2040 {"type": "string"}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2041 {"type": "deny"}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2042 ] |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2043 }})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2044 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
2045 self.assertEqual(ERRORS.E10055, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2046 self.assertEqual(2, len(pr[0].cause)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
2047 self.assertEqual(ERRORS.E10056, pr[0].cause[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2048 self.assertEqual(1, len(pr[0].cause[0].cause)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
2049 self.assertEqual(ERRORS.E10002, pr[0].cause[0].cause[0].code) |
|
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
2050 self.assertEqual(ERRORS.E10056, pr[0].cause[1].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2051 self.assertEqual(1, len(pr[0].cause[1].cause)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
2052 self.assertEqual(ERRORS.E10010, pr[0].cause[1].cause[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2053 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2054 def test_anyOf_with_list(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2055 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2056 None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2057 {"type": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2058 {"type": "deny"}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2059 {"type": None}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2060 ]})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2061 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2062 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2063 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2064 None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2065 {"type": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2066 {"type": "string"}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2067 {"type": "deny"}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2068 ]})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2069 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
2070 self.assertEqual(ERRORS.E10055, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2071 self.assertEqual(2, len(pr[0].cause)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
2072 self.assertEqual(ERRORS.E10056, pr[0].cause[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2073 self.assertEqual(1, len(pr[0].cause[0].cause)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
2074 self.assertEqual(ERRORS.E10002, pr[0].cause[0].cause[0].code) |
|
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
2075 self.assertEqual(ERRORS.E10056, pr[0].cause[1].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2076 self.assertEqual(1, len(pr[0].cause[1].cause)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
2077 self.assertEqual(ERRORS.E10010, pr[0].cause[1].cause[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2078 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2079 def test_oneOf(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2080 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2081 None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2082 {"type": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2083 "one-of": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2084 {"type": "deny"}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2085 {"type": None}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2086 ] |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2087 }})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2088 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2089 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2090 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2091 None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2092 {"type": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2093 "one-of": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2094 {"type": "string"}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2095 {"type": "deny"}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2096 ] |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2097 }})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2098 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2099 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
2100 self.assertEqual(ERRORS.E10053, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2101 self.assertEqual(2, len(pr[0].cause)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
2102 self.assertEqual(ERRORS.E10054, pr[0].cause[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2103 self.assertEqual(1, len(pr[0].cause[0].cause)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
2104 self.assertEqual(ERRORS.E10002, pr[0].cause[0].cause[0].code) |
|
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
2105 self.assertEqual(ERRORS.E10054, pr[0].cause[1].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2106 self.assertEqual(1, len(pr[0].cause[1].cause)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
2107 self.assertEqual(ERRORS.E10010, pr[0].cause[1].cause[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2108 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2109 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2110 None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2111 {"type": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2112 "one-of": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2113 {"type": "string"}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2114 {"type": "deny"}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2115 {"type": "empty"}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2116 {"type": None}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2117 ] |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2118 }})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2119 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
2120 self.assertEqual(ERRORS.E10019, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2121 self.assertEqual("2,3", pr[0].hint) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2122 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2123 def test_not(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2124 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2125 None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2126 {"type": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2127 "not": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2128 "type": "empty"}}})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2129 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
2130 self.assertEqual(ERRORS.E10029, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2131 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2132 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2133 None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2134 {"type": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2135 "not": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2136 "type": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2137 "not": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2138 "type": "empty"}}}}})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2139 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2140 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2141 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2142 2, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2143 {"type": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2144 "not": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2145 "type": "int"}}})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2146 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
2147 self.assertEqual(ERRORS.E10029, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2148 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2149 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2150 1, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2151 {"type": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2152 "not": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2153 "type": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2154 "not": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2155 "type": "int"}}}}})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2156 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2157 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2158 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2159 2.0, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2160 {"type": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2161 "not": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2162 "type": "int"}}})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2163 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2164 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2165 def test_not_shortcut(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2166 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2167 None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2168 {"not": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2169 "type": "empty"}})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2170 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
2171 self.assertEqual(ERRORS.E10029, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2172 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2173 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2174 None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2175 {"not": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2176 "not": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2177 "type": "empty"}}})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2178 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2179 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2180 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2181 2, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2182 {"not": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2183 "type": "int"}})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2184 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
2185 self.assertEqual(ERRORS.E10029, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2186 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2187 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2188 1, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2189 {"not": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2190 "not": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2191 "type": "int"}}})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2192 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2193 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2194 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2195 2.0, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2196 {"not": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2197 "type": "int"}})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2198 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2199 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2200 def test_integer(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2201 pr = list(data_schema.validate(1, {"type": "integer"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2202 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2203 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2204 pr = list(data_schema.validate(1, {"type": "float"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2205 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
2206 self.assertEqual(ERRORS.E10023, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2207 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2208 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2209 2, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2210 {"type": "int", |
|
19
c3a0fe8d4587
Consistent casing of schema items: all lowercase with dash as separator
Franz Glasner <fzglas.hg@dom66.de>
parents:
16
diff
changeset
|
2211 "min-value": 3, |
|
c3a0fe8d4587
Consistent casing of schema items: all lowercase with dash as separator
Franz Glasner <fzglas.hg@dom66.de>
parents:
16
diff
changeset
|
2212 "max-value": 1})) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2213 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2214 self.assertEqual(2, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
2215 self.assertEqual(ERRORS.E10021, pr[0].code) |
|
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
2216 self.assertEqual(ERRORS.E10022, pr[1].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2217 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2218 def test_float(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2219 pr = list(data_schema.validate(1.8, {"type": "float"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2220 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2221 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2222 pr = list(data_schema.validate(1, {"type": "float"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2223 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
2224 self.assertEqual(ERRORS.E10023, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2225 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2226 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2227 2.0, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2228 {"type": "real", |
|
19
c3a0fe8d4587
Consistent casing of schema items: all lowercase with dash as separator
Franz Glasner <fzglas.hg@dom66.de>
parents:
16
diff
changeset
|
2229 "min-value": 2.1, |
|
c3a0fe8d4587
Consistent casing of schema items: all lowercase with dash as separator
Franz Glasner <fzglas.hg@dom66.de>
parents:
16
diff
changeset
|
2230 "max-value": 1.9})) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2231 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2232 self.assertEqual(2, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
2233 self.assertEqual(ERRORS.E10024, pr[0].code) |
|
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
2234 self.assertEqual(ERRORS.E10025, pr[1].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2235 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2236 def test_number(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2237 pr = list(data_schema.validate(1.8, {"type": "number"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2238 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2239 pr = list(data_schema.validate(1, {"type": "num"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2240 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2241 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2242 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2243 2.0, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2244 {"type": "number", |
|
19
c3a0fe8d4587
Consistent casing of schema items: all lowercase with dash as separator
Franz Glasner <fzglas.hg@dom66.de>
parents:
16
diff
changeset
|
2245 "min-value": 3, |
|
c3a0fe8d4587
Consistent casing of schema items: all lowercase with dash as separator
Franz Glasner <fzglas.hg@dom66.de>
parents:
16
diff
changeset
|
2246 "max-value": 1.3})) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2247 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2248 self.assertEqual(2, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
2249 self.assertEqual(ERRORS.E10031, pr[0].code) |
|
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
2250 self.assertEqual(ERRORS.E10032, pr[1].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2251 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2252 pr = list(data_schema.validate({}, {"type": "number"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2253 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
2254 self.assertEqual(ERRORS.E10030, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2255 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2256 def test_bool(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2257 pr = list(data_schema.validate(True, {"type": "bool"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2258 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2259 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2260 pr = list(data_schema.validate(True, {"type": "boolean", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2261 "value": True})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2262 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2263 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2264 pr = list(data_schema.validate(True, {"type": "boolean", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2265 "value": False})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2266 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
2267 self.assertEqual(ERRORS.E10028, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2268 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2269 pr = list(data_schema.validate(False, {"type": "boolean"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2270 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2271 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2272 pr = list(data_schema.validate(False, {"type": "boolean", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2273 "value": False})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2274 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2275 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2276 pr = list(data_schema.validate(False, {"type": "boolean", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2277 "value": True})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2278 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
2279 self.assertEqual(ERRORS.E10027, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2280 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2281 def test_bool_real(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2282 pr = list(data_schema.validate([1, 2], {"type": "bool"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2283 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
2284 self.assertEqual(ERRORS.E10026, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2285 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2286 pr = list(data_schema.validate([], {"type": "bool"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2287 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
2288 self.assertEqual(ERRORS.E10026, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2289 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2290 pr = list(data_schema.validate(None, {"type": "bool"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2291 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
2292 self.assertEqual(ERRORS.E10026, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2293 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2294 @staticmethod |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2295 def _check_value_ts(obj, schema, context): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2296 if obj == datetime.datetime.fromtimestamp(0): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2297 yield data_schema.ValidationProblem( |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
2298 code=ERRORS.E10042, hint=obj, context=context) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2299 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2300 def test_timestamp(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2301 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2302 datetime.datetime.utcnow(), |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2303 {"type": "timestamp"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2304 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2305 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2306 datetime.datetime.fromtimestamp(180000), |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2307 {"type": "datetime", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2308 "value": self._check_value_ts})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2309 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2310 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2311 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2312 datetime.datetime.fromtimestamp(0), |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2313 {"type": "datetime", |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2314 "value": self._check_value_ts})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2315 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
2316 self.assertEqual(ERRORS.E10042, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2317 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2318 def test_scalar(self): |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2319 pr = list(data_schema.validate(1, {"type": "scalar"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2320 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2321 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2322 pr = list(data_schema.validate("", {"type": "scalar"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2323 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2324 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2325 pr = list(data_schema.validate(False, {"type": "scalar"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2326 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2327 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2328 pr = list(data_schema.validate(datetime.datetime.utcnow(), |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2329 {"type": "scalar"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2330 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2331 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2332 pr = list(data_schema.validate(None, {"type": "scalar"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2333 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
2334 self.assertEqual(ERRORS.E10033, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2335 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2336 pr = list(data_schema.validate({}, {"type": "scalar"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2337 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
2338 self.assertEqual(ERRORS.E10033, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2339 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2340 pr = list(data_schema.validate([], {"type": "scalar"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2341 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
2342 self.assertEqual(ERRORS.E10033, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2343 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2344 pr = list(data_schema.validate(tuple(), {"type": "scalar"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2345 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
2346 self.assertEqual(ERRORS.E10033, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2347 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2348 pr = list(data_schema.validate(set(), {"type": "scalar"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2349 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
2350 self.assertEqual(ERRORS.E10033, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2351 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2352 pr = list(data_schema.validate(frozenset(), {"type": "scalar"})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2353 self.assertEqual(1, len(pr)) |
|
13
940676a0de84
ERRORS and WARNINGS are now enums
Franz Glasner <fzglas.hg@dom66.de>
parents:
5
diff
changeset
|
2354 self.assertEqual(ERRORS.E10033, pr[0].code) |
|
5
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2355 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2356 pr = list(data_schema.validate( |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2357 None, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2358 {"type": { |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2359 "one-of": [ |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2360 {"type": "scalar"}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2361 {"type": None}, |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2362 ]}})) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2363 self.assertEqual(0, len(pr)) |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2364 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2365 |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2366 if __name__ == "__main__": |
|
84dfd1a94926
Add the existing implementation.
Franz Glasner <fzglas.hg@dom66.de>
parents:
diff
changeset
|
2367 unittest.main() |
