From 1000a56e0de74d91de1c5861d5d728e884e9966a Mon Sep 17 00:00:00 2001 From: Oleg Shlyazhko Date: Sun, 24 Jan 2016 18:32:12 +0300 Subject: [PATCH] more test vor botan module, increase coverage --- tests/test_botan.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tests/test_botan.py b/tests/test_botan.py index f99eb1b84..1206b8bab 100644 --- a/tests/test_botan.py +++ b/tests/test_botan.py @@ -10,12 +10,14 @@ sys.path.append('.') from telegram.utils.botan import Botan from tests.base import BaseTest + class MessageMock(object): chat_id = None def __init__(self, chat_id): self.chat_id = chat_id + class BotanTest(BaseTest, unittest.TestCase): """This object represents Tests for Botan analytics integration.""" @@ -29,7 +31,6 @@ class BotanTest(BaseTest, unittest.TestCase): result = botan.track(message, 'named event') self.assertTrue(result) - def test_track_fail(self): """Test fail when sending event to botan""" print('Test fail when sending event to botan') @@ -39,5 +40,23 @@ class BotanTest(BaseTest, unittest.TestCase): result = botan.track(message, 'named event') self.assertFalse(result) + def test_wrong_message(self): + """Test sending wrong message""" + print('Test sending wrong message') + botan = Botan(self.token) + message = MessageMock(self._chat_id) + message = delattr(message, 'chat_id') + result = botan.track(message, 'named event') + self.assertFalse(result) + + def test_wrong_endpoint(self): + """Test wrong endpoint""" + print('Test wrong endpoint') + botan = Botan(self.token) + botan.url_template = 'https://api.botaaaaan.io/traccc?token={token}&uid={uid}&name={name}' + message = MessageMock(self._chat_id) + result = botan.track(message, 'named event') + self.assertFalse(result) + if __name__ == '__main__': unittest.main()