diff --git a/.pep8speaks.yml b/.pep8speaks.yml index be24d89..0b17ac3 100644 --- a/.pep8speaks.yml +++ b/.pep8speaks.yml @@ -5,3 +5,5 @@ pycodestyle: max-line-length: 120 ignore: - E402 + +no_blank_comment: True diff --git a/CHANGELOG.md b/CHANGELOG.md index 8681f0a..3a6d60f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## [unreleased] + +### Fixes +* Ensure tags are lower cased after collecting them from entity `raw_content`. + ## [0.10.0] - 2017-01-28 ### Added diff --git a/federation/entities/base.py b/federation/entities/base.py index 89dc55a..5d8261c 100644 --- a/federation/entities/base.py +++ b/federation/entities/base.py @@ -148,7 +148,7 @@ class RawContentMixin(BaseEntity): """Returns a `set` of unique tags contained in `raw_content`.""" if not self.raw_content: return set() - return set({word.strip("#") for word in self.raw_content.split() if word.startswith("#")}) + return {word.strip("#").lower() for word in self.raw_content.split() if word.startswith("#") and len(word) > 1} class OptionalRawContentMixin(RawContentMixin): diff --git a/federation/tests/entities/test_base.py b/federation/tests/entities/test_base.py index f4b769f..c0ec687 100644 --- a/federation/tests/entities/test_base.py +++ b/federation/tests/entities/test_base.py @@ -11,7 +11,7 @@ from federation.tests.factories.entities import TaggedPostFactory, PostFactory class TestPostEntityTags(object): def test_post_entity_returns_list_of_tags(self): post = TaggedPostFactory() - assert post.tags == {"tagone", "tagtwo", "tagthree"} + assert post.tags == {"tagone", "tagtwo", "tagthree", "upper", "snakecase"} def test_post_entity_without_raw_content_tags_returns_empty_set(self): post = PostFactory(raw_content=None) diff --git a/federation/tests/factories/entities.py b/federation/tests/factories/entities.py index bce2f49..7e9fdf0 100644 --- a/federation/tests/factories/entities.py +++ b/federation/tests/factories/entities.py @@ -29,7 +29,7 @@ class TaggedPostFactory(PostFactory): @factory.lazy_attribute def raw_content(self): parts = [] - for tag in ["tagone", "tagtwo", "tagthree", "tagthree"]: # Yes, three is twice for fun + for tag in ["tagone", "tagtwo", "tagthree", "tagthree", "SnakeCase", "UPPER", ""]: parts.append(fuzzy.FuzzyText(length=50).fuzz()) parts.append("#%s" % tag) shuffle(parts)