From 2becae785a48b2a40256fd2b52cbb6712a9f21e9 Mon Sep 17 00:00:00 2001 From: Filipe Pina Date: Thu, 14 Jan 2016 12:01:52 +0000 Subject: [PATCH] increased coverage --- plugins/google.py | 2 +- tests/test_guess.py | 9 +++++++++ tests/test_simsimi.py | 6 ++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/plugins/google.py b/plugins/google.py index fa18d1c..4d02e4a 100644 --- a/plugins/google.py +++ b/plugins/google.py @@ -42,7 +42,7 @@ def google(self, message, text): reply = '%(titleNoFormatting)s\n\n%(content)s\n\n%(url)s' % res except IndexError: reply = 'Sorry, nothing found...' - else: + else: # pragma: no cover reply = 'It seems I\'m googling too much lately, I need to rest a little...' self.bot.send_message(message.chat.id, reply, reply_to_message_id=message.message_id, disable_web_page_preview=True) diff --git a/tests/test_guess.py b/tests/test_guess.py index 21aeeb1..1823151 100644 --- a/tests/test_guess.py +++ b/tests/test_guess.py @@ -57,3 +57,12 @@ def test_play(self): self.receive_message('5') self.assertReplied(self.bot, 'Congratz, you nailed it John') + + def test_stop(self): + self.receive_message('/guess_start') + self.assertReplied(self.bot, "I'm going to think of a number between 0 and 9 and you have to guess it! What's your guess?") + self.assertIsNotNone(self.plugin.read_data(1)) + + self.receive_message('/guess_stop') + self.assertReplied(self.bot, 'Ok :(') + self.assertIsNone(self.plugin.read_data(1)) diff --git a/tests/test_simsimi.py b/tests/test_simsimi.py index e4d8235..bc2ac08 100644 --- a/tests/test_simsimi.py +++ b/tests/test_simsimi.py @@ -39,3 +39,9 @@ def test_reply(self): # any reply will do... self.last_reply(self.bot) + + def test_no_reply(self): + self.receive_message('') + + # any reply will do... + self.assertRaisesRegexp(AssertionError, 'No replies', self.last_reply, self.bot)