Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
gforcada committed Mar 10, 2016
1 parent 964effb commit bc21329
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/collective/contentalerts/tests/test_contentrules.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ def _add_comment(self, text):
conversation.addComment(comment)
return comment

def _set_record_value(self, value):
def _set_record_value(self, value, record='inadequate_words'):
api.portal.set_registry_record(
name='inadequate_words',
name=record,
interface=IStopWords,
value=value
)
Expand Down
46 changes: 44 additions & 2 deletions src/collective/contentalerts/tests/test_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ def setUp(self):
self.registry = getUtility(IRegistry)
self.utility = getUtility(IAlert)

def _set_record_value(self, value):
def _set_record_value(self, value, record='inadequate_words'):
api.portal.set_registry_record(
name='inadequate_words',
name=record,
interface=IStopWords,
value=value
)
Expand Down Expand Up @@ -121,6 +121,48 @@ def test_no_has_words_from_registry(self):
self.utility.has_stop_words(u'some specific text')
)

def test_no_has_forbidden_words(self):
"""Check that has_forbidden_words returns False if the text
does not have words from the forbidden_words registry
"""
self._set_record_value(
u'random\nalert me\nlala',
record='forbidden_words'
)
self.assertFalse(
self.utility.has_forbidden_words(u'some specific text')
)

def test_has_forbidden_words(self):
"""Check that has_forbidden_words returns True if the text has words
from the forbidden_words registry
"""
self._set_record_value(
u'random\nalert me\nlala',
record='forbidden_words'
)
self.assertFalse(
self.utility.has_forbidden_words(u'some specific text')
)

def test_no_has_inadequate_words(self):
"""Check that has_inadequate_words returns False if the text
does not have words from the inadequate_words registry
"""
self._set_record_value(u'random\nalert me\nlala')
self.assertFalse(
self.utility.has_forbidden_words(u'some specific text')
)

def test_has_inadequate_words(self):
"""Check that has_inadequate_words returns True if the text has words
from the inadequate_words registry
"""
self._set_record_value(u'random\nalert me\nlala')
self.assertFalse(
self.utility.has_forbidden_words(u'some specific text')
)

def test_get_snippets_from_registry(self):
"""Check that get_snippets works with the registry."""
self._set_record_value(u'random\nalert me\nlala')
Expand Down

0 comments on commit bc21329

Please sign in to comment.