Skip to content

Commit

Permalink
#10 Added tests for _PresetDocumentResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
OrBin committed Apr 11, 2019
1 parent 3783f33 commit 7198760
Showing 1 changed file with 30 additions and 6 deletions.
36 changes: 30 additions & 6 deletions tests/responses/test_preset_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ def test_single_preset_message_with_some_payload(self, bot, bot_chat_id, generat
self._test_single_preset_message(bot, bot_chat_id, generate_new_update, {'key': 'value'})

def test_multiple_preset_messages_with_none_payload(self, bot, bot_chat_id, generate_new_update):
self._test_single_preset_message(bot, bot_chat_id, generate_new_update, None)
self._test_multiple_preset_messages(bot, bot_chat_id, generate_new_update, None)

def test_multiple_preset_messages_with_empty_payload(self, bot, bot_chat_id, generate_new_update):
self._test_single_preset_message(bot, bot_chat_id, generate_new_update, {})
self._test_multiple_preset_messages(bot, bot_chat_id, generate_new_update, {})

def test_multiple_preset_messages_with_some_payload(self, bot, bot_chat_id, generate_new_update):
self._test_single_preset_message(bot, bot_chat_id, generate_new_update, {'key': 'value'})
self._test_multiple_preset_messages(bot, bot_chat_id, generate_new_update, {'key': 'value'})


@flaky(max_runs=FLAKY_MAX_RUNS, min_passes=FLAKY_MIN_PASSES, rerun_filter=delay_rerun)
Expand Down Expand Up @@ -93,10 +93,34 @@ def test_single_preset_reply_with_some_payload(self, bot, bot_chat_id, generate_
self._test_single_preset_reply(bot, bot_chat_id, generate_new_update, {'key': 'value'})

def test_multiple_preset_replies_with_none_payload(self, bot, bot_chat_id, generate_new_update):
self._test_single_preset_reply(bot, bot_chat_id, generate_new_update, None)
self._test_multiple_preset_replies(bot, bot_chat_id, generate_new_update, None)

def test_multiple_preset_replies_with_empty_payload(self, bot, bot_chat_id, generate_new_update):
self._test_single_preset_reply(bot, bot_chat_id, generate_new_update, {})
self._test_multiple_preset_replies(bot, bot_chat_id, generate_new_update, {})

def test_multiple_preset_replies_with_some_payload(self, bot, bot_chat_id, generate_new_update):
self._test_single_preset_reply(bot, bot_chat_id, generate_new_update, {'key': 'value'})
self._test_multiple_preset_replies(bot, bot_chat_id, generate_new_update, {'key': 'value'})


@flaky(max_runs=FLAKY_MAX_RUNS, min_passes=FLAKY_MIN_PASSES, rerun_filter=delay_rerun)
@pytest.mark.usefixtures('bot', 'bot_chat_id', 'generate_new_update')
class TestPresetDocumentResponse:

DOCUMENT_URL = 'https://media.giphy.com/media/JIX9t2j0ZTN9S/giphy.gif'

def _test_preset_document_url(self, bot, bot_chat_id, generate_new_update, payload):
response = _PresetDocumentResponse(self.DOCUMENT_URL)
update = generate_new_update(chat_id=bot_chat_id)

message = response.respond(bot, update, payload)
assert message
assert message.document

def test_single_preset_reply_with_none_payload(self, bot, bot_chat_id, generate_new_update):
self._test_preset_document_url(bot, bot_chat_id, generate_new_update, None)

def test_single_preset_reply_with_empty_payload(self, bot, bot_chat_id, generate_new_update):
self._test_preset_document_url(bot, bot_chat_id, generate_new_update, {})

def test_single_preset_reply_with_some_payload(self, bot, bot_chat_id, generate_new_update):
self._test_preset_document_url(bot, bot_chat_id, generate_new_update, {'key': 'value'})

0 comments on commit 7198760

Please sign in to comment.