diff --git a/tildes/tests/test_group.py b/tildes/tests/test_group.py index 0494d62..b005b10 100644 --- a/tildes/tests/test_group.py +++ b/tildes/tests/test_group.py @@ -39,10 +39,9 @@ def test_middle_element_end_with_underscore(): assert not is_valid_group_path("x.y_.z") -def test_uppercase_letters_invalid(): - """Ensure a group path can't contain uppercase chars.""" - assert is_valid_group_path("comp.lang.c") - assert not is_valid_group_path("comp.lang.C") +def test_uppercase_letters_fixed(): + """Ensure a group path gets uppercase letters converted to lowercase.""" + assert Group("Comp.Lang.C").path == "comp.lang.c" def test_paths_with_invalid_characters(): diff --git a/tildes/tildes/models/group/group.py b/tildes/tildes/models/group/group.py index aa35438..e43d092 100644 --- a/tildes/tildes/models/group/group.py +++ b/tildes/tildes/models/group/group.py @@ -67,7 +67,7 @@ class Group(DatabaseModel): def __init__(self, path: str, short_desc: Optional[str] = None) -> None: """Create a new group.""" - self.path = Ltree(path) + self.path = path self.short_description = short_desc def __acl__(self) -> Sequence[Tuple[str, Any, str]]: diff --git a/tildes/tildes/schemas/fields.py b/tildes/tildes/schemas/fields.py index c1c0a48..3a25a90 100644 --- a/tildes/tildes/schemas/fields.py +++ b/tildes/tildes/schemas/fields.py @@ -147,6 +147,6 @@ class Ltree(Field): def _deserialize(self, value: str, attr: str, data: dict) -> sqlalchemy_utils.Ltree: """Deserialize a string path to an Ltree object.""" try: - return sqlalchemy_utils.Ltree(value) + return sqlalchemy_utils.Ltree(value.lower()) except (TypeError, ValueError): raise ValidationError("Invalid path") diff --git a/tildes/tildes/schemas/topic.py b/tildes/tildes/schemas/topic.py index b6843bc..8e6fc0b 100644 --- a/tildes/tildes/schemas/topic.py +++ b/tildes/tildes/schemas/topic.py @@ -80,7 +80,7 @@ class TopicSchema(Schema): group_schema = GroupSchema(partial=True) for tag in value: try: - group_schema.validate({"path": tag}) + group_schema.validate({"path": str(tag)}) except ValidationError: raise ValidationError("Tag %s is invalid" % tag)