From 76611238adbc7ab7a5550c3fefe6839b24b0fe14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leon=20M=C3=B6ller?= Date: Thu, 5 Oct 2023 19:00:29 +0200 Subject: [PATCH] test: check constraint AASd-130 implementation --- test/model/test_string_constraints.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/model/test_string_constraints.py b/test/model/test_string_constraints.py index 33f7d6cf9..3b347ea2c 100644 --- a/test/model/test_string_constraints.py +++ b/test/model/test_string_constraints.py @@ -41,6 +41,25 @@ def test_version_type(self) -> None: version = "0" _string_constraints.check_version_type(version) + def test_aasd_130(self) -> None: + name: model.NameType = "\0" + with self.assertRaises(ValueError) as cm: + _string_constraints.check_name_type(name) + self.assertEqual(r"Every string must match the pattern '[\t\n\r -\ud7ff\ue000-\ufffd\U00010000-\U0010ffff]*'! " + r"(value: '\x00')", cm.exception.args[0]) + name = "\ud800" + with self.assertRaises(ValueError) as cm: + _string_constraints.check_name_type(name) + self.assertEqual(r"Every string must match the pattern '[\t\n\r -\ud7ff\ue000-\ufffd\U00010000-\U0010ffff]*'! " + r"(value: '\ud800')", cm.exception.args[0]) + name = "\ufffe" + with self.assertRaises(ValueError) as cm: + _string_constraints.check_name_type(name) + self.assertEqual(r"Every string must match the pattern '[\t\n\r -\ud7ff\ue000-\ufffd\U00010000-\U0010ffff]*'! " + r"(value: '\ufffe')", cm.exception.args[0]) + name = "this\ris\na\tvalid täst\uffdd\U0010ab12" + _string_constraints.check_name_type(name) + class StringConstraintsDecoratorTest(unittest.TestCase): @_string_constraints.constrain_path_type("some_attr")