-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#10 Created tests for _PresetMessageResponse
- Loading branch information
Showing
5 changed files
with
46 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import pytest | ||
from ...gramhopper.responses.preset_responses import _PresetTextResponse, \ | ||
_PresetDocumentResponse, _PresetMessageResponse, _PresetReplyResponse | ||
|
||
|
||
@pytest.mark.usefixtures('bot') | ||
@pytest.mark.usefixtures('chat_id') | ||
class TestPresetMessageResponse: | ||
|
||
SINGLE_PRESET_TEXT = 'one' | ||
MULTIPLE_PRESET_TEXTS = ['two', 'three'] | ||
|
||
@pytest.mark.usefixtures('generate_new_update') | ||
def test_single_preset_message(self, bot, chat_id, generate_new_update): | ||
response = _PresetMessageResponse(self.SINGLE_PRESET_TEXT) | ||
|
||
update = generate_new_update(chat_id=chat_id) | ||
possible_values_for_payload = [None, {}, {'key': 'value'}] | ||
|
||
for payload in possible_values_for_payload: | ||
message = response.respond(bot, update, payload) | ||
assert message | ||
assert message.text == self.SINGLE_PRESET_TEXT | ||
|
||
@pytest.mark.usefixtures('generate_new_update') | ||
def test_multiple_preset_messages(self, bot, chat_id, generate_new_update): | ||
response = _PresetMessageResponse(self.MULTIPLE_PRESET_TEXTS) | ||
|
||
update = generate_new_update(chat_id=chat_id) | ||
possible_values_for_payload = [None, {}, {'key': 'value'}] | ||
|
||
for payload in possible_values_for_payload: | ||
message = response.respond(bot, update, payload) | ||
assert message | ||
assert message.text in self.MULTIPLE_PRESET_TEXTS |