kopia lustrzana https://gitlab.com/jaywink/federation
Merge pull request #69 from jaywink/fix-entity-tags
Ensure tags are lower cased after collecting them from raw_contentmerge-requests/130/head
commit
f5e4379ff3
|
@ -5,3 +5,5 @@ pycodestyle:
|
|||
max-line-length: 120
|
||||
ignore:
|
||||
- E402
|
||||
|
||||
no_blank_comment: True
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Ładowanie…
Reference in New Issue