Mercurial > hgrepos > Python > libs > data-schema
diff tests/test_schema.py @ 19:c3a0fe8d4587
Consistent casing of schema items: all lowercase with dash as separator
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Sat, 08 Jul 2023 10:05:48 +0200 |
| parents | 2a9e7c4b717e |
| children | db3491e1b590 |
line wrap: on
line diff
--- a/tests/test_schema.py Fri Jul 07 09:27:51 2023 +0200 +++ b/tests/test_schema.py Sat Jul 08 10:05:48 2023 +0200 @@ -1403,7 +1403,7 @@ x = list(data_schema.validate( {"key": "value"}, {"type": "dict", - "additionalKeys": False})) + "additional-keys": False})) self.assertEqual(1, len(x)) self.assertEqual(ERRORS.E10004, x[0].code) self.assertEqual("key", x[0].hint) @@ -1412,7 +1412,7 @@ x = list(data_schema.validate( {"key": "value"}, {"type": "dict", - "additionalKeys": False}, + "additional-keys": False}, skip_keys=["key"])) self.assertEqual(0, len(x)) @@ -1421,7 +1421,7 @@ {"key": "value", "key2": "value"}, {"type": "dict", - "additionalKeys": False}, + "additional-keys": False}, skip_keys=[re.compile(r"\Akey\d*\Z")])) self.assertEqual(0, len(x)) @@ -1430,7 +1430,7 @@ {"key": "value", "key2": "value"}, {"type": "dict", - "additionalKeys": False}, + "additional-keys": False}, skip_keys=[re.compile(r"\A__.+"), re.compile(r"\Akey\d+\Z")])) self.assertEqual(1, len(x)) self.assertEqual(ERRORS.E10004, x[0].code) @@ -1440,14 +1440,14 @@ x = list(data_schema.validate( {"key": "value"}, {"type": "dict", - "additionalKeys": True})) + "additional-keys": True})) self.assertEqual(0, len(x)) def test_d7(self): x = list(data_schema.validate( {"key": "value"}, {"type": "dict", - "additionalKeys": { + "additional-keys": { "type": "string"}})) self.assertEqual(0, len(x)) @@ -1455,7 +1455,7 @@ x = list(data_schema.validate( {"key": 1234}, {"type": "dict", - "additionalKeys": { + "additional-keys": { "type": "string"}})) self.assertEqual(1, len(x)) self.assertEqual(ERRORS.E10002, x[0].code) @@ -1465,7 +1465,7 @@ x = list(data_schema.validate( {"key": 1234}, {"type": "dict", - "additionalKeys": { + "additional-keys": { "type": "string"}}, skip_keys=["key"])) self.assertEqual(0, len(x)) @@ -1474,7 +1474,7 @@ pr = list(data_schema.validate( {0: "value"}, {"type": "dict", - "additionalKeys": True})) + "additional-keys": True})) self.assertEqual(1, len(pr)) self.assertEqual(ERRORS.E10003, pr[0].code) @@ -1484,8 +1484,8 @@ {"type": "dict", "keys": { 1: {"type": "string"}}, - "additionalKeys": True, - "keyNames": {"type": "int"}})) + "additional-keys": True, + "key-names": {"type": "int"}})) self.assertEqual(0, len(pr)) def test_error_message(self): @@ -1527,46 +1527,46 @@ pr = list(data_schema.validate( "", {"type": "string", - "minLength": 0})) + "min-length": 0})) self.assertEqual(0, len(pr)) pr = list(data_schema.validate( "", {"type": "string", - "minLength": 1})) + "min-length": 1})) self.assertEqual(1, len(pr)) self.assertEqual(ERRORS.E10006, pr[0].code) pr = list(data_schema.validate( "x", {"type": "string", - "minLength": 1})) + "min-length": 1})) self.assertEqual(0, len(pr)) def test_str_maxlen(self): pr = list(data_schema.validate( "", {"type": "string", - "maxLength": 0})) + "max-length": 0})) self.assertEqual(0, len(pr)) pr = list(data_schema.validate( "x", {"type": "string", - "maxLength": 0})) + "max-length": 0})) self.assertEqual(1, len(pr)) self.assertEqual(ERRORS.E10007, pr[0].code) pr = list(data_schema.validate( "x", {"type": "string", - "maxLength": 1})) + "max-length": 1})) self.assertEqual(0, len(pr)) pr = list(data_schema.validate( b"x", {"type": "string", - "maxLength": 1})) + "max-length": 1})) self.assertEqual(1, len(pr)) self.assertEqual(ERRORS.E10002, pr[0].code) @@ -1669,14 +1669,14 @@ pr = list(data_schema.validate( b"", {"type": "binary", - "minLength": 1})) + "min-length": 1})) self.assertEqual(1, len(pr)) self.assertEqual(ERRORS.E10036, pr[0].code) pr = list(data_schema.validate( b"1", {"type": "binary", - "maxLength": 0})) + "max-length": 0})) self.assertEqual(1, len(pr)) self.assertEqual(ERRORS.E10037, pr[0].code) @@ -1796,7 +1796,7 @@ "items": [ {"type": "string"}, {"type": None}], - "additionalItems": True})) + "additional-items": True})) self.assertEqual(0, len(pr)) def test_t6(self): @@ -1806,22 +1806,22 @@ "items": [ {"type": "string"}, {"type": None}], - "additionalItems": { + "additional-items": { "type": "dict", "keys": {"key": {"type": "string"}} }})) self.assertEqual(0, len(pr)) def test_t7(self): - # do not check anything that exceeds maxLength + # do not check anything that exceeds max-length pr = list(data_schema.validate( ["a", None, {"key": "value"}, {"key": "value"}, {"key2": "value"}], {"type": "tuple", - "maxLength": 4, + "max-length": 4, "items": [ {"type": "string"}, {"type": None}], - "additionalItems": { + "additional-items": { "type": "dict", "keys": {"key": {"type": "string"}} }})) @@ -1829,16 +1829,16 @@ self.assertEqual(ERRORS.E10016, pr[0].code) def test_t8(self): - # do not check anything that exceeds maxLength + # do not check anything that exceeds max-length pr = list(data_schema.validate( ["a", None, {"key": "value"}, {"key": "value"}, {"key2": "value"}], {"type": "tuple", - "minLength": 6, - "maxLength": 4, + "min-length": 6, + "max-length": 4, "items": [ {"type": "string"}, {"type": None}], - "additionalItems": { + "additional-items": { "type": "dict", "keys": {"key": {"type": "string"}} }})) @@ -1847,11 +1847,11 @@ self.assertEqual(ERRORS.E10016, pr[1].code) def test_set1(self): - # do not check anything that exceeds maxLength + # do not check anything that exceeds max-length pr = list(data_schema.validate( set(["a", None, "b"]), {"type": "set", - "minLength": 3, + "min-length": 3, "items": {"any-of": [ {"type": "string"}, {"type": None}]}} @@ -1859,7 +1859,7 @@ self.assertEqual(0, len(pr)) def test_set1_not_nullable(self): - # do not check anything that exceeds maxLength + # do not check anything that exceeds max-length pr = list(data_schema.validate( None, {"type": "set"})) @@ -1867,18 +1867,18 @@ self.assertEqual(ERRORS.E10038, pr[0].code) def test_set1_nullable(self): - # do not check anything that exceeds maxLength + # do not check anything that exceeds max-length pr = list(data_schema.validate( None, {"type": "set", "nullable": True})) self.assertEqual(0, len(pr)) def test_set2(self): - # do not check anything that exceeds maxLength + # do not check anything that exceeds max-length pr = list(data_schema.validate( set(["a", None, "b"]), {"type": "set", - "minLength": 4, + "min-length": 4, "items": {"any-of": [ {"type": "string"}, {"type": None}]}} @@ -1887,11 +1887,11 @@ self.assertEqual(ERRORS.E10039, pr[0].code) def test_set3(self): - # do not check anything that exceeds maxLength + # do not check anything that exceeds max-length pr = list(data_schema.validate( set(["a", None, "b"]), {"type": "set", - "maxLength": 2, + "max-length": 2, "items": {"any-of": [ {"type": "string"}, {"type": None}]}} @@ -2167,8 +2167,8 @@ pr = list(data_schema.validate( 2, {"type": "int", - "minValue": 3, - "maxValue": 1})) + "min-value": 3, + "max-value": 1})) self.assertEqual(2, len(pr)) self.assertEqual(ERRORS.E10021, pr[0].code) @@ -2185,8 +2185,8 @@ pr = list(data_schema.validate( 2.0, {"type": "real", - "minValue": 2.1, - "maxValue": 1.9})) + "min-value": 2.1, + "max-value": 1.9})) self.assertEqual(2, len(pr)) self.assertEqual(ERRORS.E10024, pr[0].code) @@ -2201,8 +2201,8 @@ pr = list(data_schema.validate( 2.0, {"type": "number", - "minValue": 3, - "maxValue": 1.3})) + "min-value": 3, + "max-value": 1.3})) self.assertEqual(2, len(pr)) self.assertEqual(ERRORS.E10031, pr[0].code)
