Skip to content

Commit

Permalink
#10 Added tests for HasExactWordTrigger
Browse files Browse the repository at this point in the history
  • Loading branch information
OrBin committed Mar 17, 2019
1 parent 7a301fe commit d1e9334
Showing 1 changed file with 41 additions and 3 deletions.
44 changes: 41 additions & 3 deletions tests/triggers/test_text_triggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,44 @@ def test_multiple_substrings_not_exact(self, update):

@pytest.mark.usefixtures('update')
class TestExactWordTrigger:
def test_exact_word_trigger(self, update):
# TODO Write test
pass
def test_single_substring_exact(self, update):
word = 'ello'
trigger = _HasExactWordTrigger(word=word)

update.message.text = 'ello'
result = trigger.check_trigger(update)
assert result.should_respond
assert 'match' in result.response_payload
match = result.response_payload['match']
assert len(match) == 1
assert match[0] == word

update.message.text = 'hello'
result = trigger.check_trigger(update)
assert not result.should_respond
assert result.response_payload == {}

def test_multiple_substrings_exact(self, update):
words = ['yellow', 'fellow']
trigger = _HasExactWordTrigger(word=words)

update.message.text = 'yellow'
result = trigger.check_trigger(update)
assert result.should_respond
assert 'match' in result.response_payload
match = result.response_payload['match']
assert len(match) == 1
assert match[0] in words

update.message.text = 'fellow'
result = trigger.check_trigger(update)
assert result.should_respond
assert 'match' in result.response_payload
match = result.response_payload['match']
assert len(match) == 1
assert match[0] in words

update.message.text = 'yellowstone'
result = trigger.check_trigger(update)
assert not result.should_respond
assert result.response_payload == {}

0 comments on commit d1e9334

Please sign in to comment.