From efa2dbf724a2283993b1145fa0e675293213d251 Mon Sep 17 00:00:00 2001 From: Jakob Scheid Date: Sun, 4 Oct 2026 16:47:33 +0200 Subject: [PATCH] test(python-namespaces): add test for namespace name validation --- .../test_validate_namespace_name.py | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 tests/unit/core/python/namespaces/test_validate_namespace_name.py diff --git a/tests/unit/core/python/namespaces/test_validate_namespace_name.py b/tests/unit/core/python/namespaces/test_validate_namespace_name.py new file mode 100644 index 0000000..a254eb4 --- /dev/null +++ b/tests/unit/core/python/namespaces/test_validate_namespace_name.py @@ -0,0 +1,52 @@ +# Copyright 2026 jCloud + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import pytest + +from src.jcloud_docsgen.core.python.namespaces import validate_namespace_name + + +@pytest.mark.parametrize( + 'name,expected', + [ + ('a', True), + ('namespace', True), + ('match', True), + ('case', True), + ('type', True), + ('_', True), + ('__', True), + ('___', True), + ('_a', True), + ('_a_', True), + ('_a.', False), + ('a.b', False), + ('a-b', False), + ('a.', False), + ('a-', False), + ('.a', False), + ('-a', False), + ('.a.', False), + ('-a-', False), + ('.', False), + ('a-.b', False), + ('"', False), + ('""', False), + ('def', False), + ('class', False), + ('import', False), + ], +) +def test_validate_namespace_name(name, expected): + assert validate_namespace_name(name) == expected