Don't raise on Post.tags if Post.raw_content is None

Fixes #17
merge-requests/130/head
Jason Robinson 2016-05-09 21:34:18 +03:00
rodzic cddebf87cd
commit fde1e988da
3 zmienionych plików z 9 dodań i 0 usunięć

Wyświetl plik

@ -3,6 +3,9 @@
### Changed
- Test factories and other test files are now included in the package installation. Factories can be useful when creating project tests.
### Fixes
- Don't raise on Post.tags if Post.raw_content is None
## [0.3.1] - 2016-04-13
### Added

Wyświetl plik

@ -83,6 +83,8 @@ class RawContentMixin(BaseEntity):
@property
def tags(self):
"""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("#")})

Wyświetl plik

@ -12,6 +12,10 @@ class TestPostEntityTags(object):
post = TaggedPostFactory()
assert post.tags == {"tagone", "tagtwo", "tagthree"}
def test_post_entity_without_raw_content_tags_returns_empty_set(self):
post = PostFactory(raw_content=None)
assert post.tags == set()
class TestBaseEntityCallsValidateMethods(object):
def test_entity_calls_attribute_validate_method(self):