Skip to content

Commit

Permalink
Add a test for validate_brackets
Browse files Browse the repository at this point in the history
  • Loading branch information
insolor committed Oct 1, 2023
1 parent f66b7d5 commit 33ea7d5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion df_translation_toolkit/validation/validate_objects.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down
16 changes: 16 additions & 0 deletions tests/test_validate_objects.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 33ea7d5

Please sign in to comment.