Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added tests for all sync methods on telegram #85

Merged
merged 1 commit into from
Oct 12, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions tests/test_telegram.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,42 @@ def test_build_message_with_non_message_data():
message = engine.build_message(data)

assert message is None


def test_telegram_engine_tasks():
engine = TelegramEngine(token='')
engine.polling = 'something'
assert engine.tasks() == ['something']


@mock.patch('bottery.platform.telegram.logger.debug')
def test_telegram_engine_configure(mocked_debug):
'''Make sure logger.debug is called if the response from webhook
is positive.'''

def mocked_json(): return {'ok': True}

def mocked_delete_webhook(): return type('response', (),
{'json': mocked_json})
engine = TelegramEngine(token='')
engine.api.delete_webhook = mocked_delete_webhook
engine.session = ''
engine.configure()
assert mocked_debug.called


@mock.patch('bottery.platform.telegram.logger.debug')
def test_telegram_engine_configure_not_ok(mocked_debug):
'''Make sure logger.debug is not called if the response from webhook
is negative.'''

engine = TelegramEngine(token='')
engine.session = ''
engine.configure()
assert not mocked_debug.called


def test_telegram_engine_define_new_mode():
'''Make sure TelegramEngine supports new modes.'''
engine = TelegramEngine(token='', mode='else')
assert engine.mode == 'else'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, what should be tested is if no mode is passed to TelegramEngine, its default mode will be polling, right?