diff --git a/df_translation_toolkit/validation/validate_objects.py b/df_translation_toolkit/validation/validate_objects.py index 04440b2..afc9e3c 100644 --- a/df_translation_toolkit/validation/validate_objects.py +++ b/df_translation_toolkit/validation/validate_objects.py @@ -1,7 +1,7 @@ from df_translation_toolkit.parse.parse_raws import all_caps, split_tag -def validate_brackets(tag: str): +def validate_brackets(tag: str) -> bool: return tag.startswith("[") and tag.endswith("]") and tag.count("[") == 1 and tag.count("]") == 1 diff --git a/tests/test_validate_objects.py b/tests/test_validate_objects.py new file mode 100644 index 0000000..b8d0570 --- /dev/null +++ b/tests/test_validate_objects.py @@ -0,0 +1,16 @@ +import pytest + +from df_translation_toolkit.validation.validate_objects import validate_brackets + + +@pytest.mark.parametrize( + "text, expected", + [ + ("[text]", True), + ("[text", False), + ("text]", False), + ("[text[]", False), + ] +) +def test_validate_brackets(text, expected): + assert validate_brackets(text) == expected