bot tests: Eliminate BotTestCaseBase.
We now just put `test_bot_usage` in StubBotTestCase and have BotTestCase inherit from that.
This commit is contained in:
parent
205f7c16c7
commit
fc251460fa
|
@ -98,7 +98,7 @@ def main():
|
||||||
for test in tests:
|
for test in tests:
|
||||||
if isinstance(test, TestCase):
|
if isinstance(test, TestCase):
|
||||||
# Exclude test base class from being tested.
|
# Exclude test base class from being tested.
|
||||||
if test.__class__.__name__ not in ['StubBotTestCase', 'BotTestCase', 'BotTestCaseBase']:
|
if test.__class__.__name__ not in ['StubBotTestCase', 'BotTestCase']:
|
||||||
filtered_tests.addTest(test)
|
filtered_tests.addTest(test)
|
||||||
else:
|
else:
|
||||||
filtered_tests.addTest(filter_tests(test))
|
filtered_tests.addTest(filter_tests(test))
|
||||||
|
|
|
@ -5,9 +5,9 @@ from __future__ import print_function
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from zulip_bots.test_lib import BotTestCaseBase
|
from zulip_bots.test_lib import BotTestCase
|
||||||
|
|
||||||
class TestGithubDetailBot(BotTestCaseBase):
|
class TestGithubDetailBot(BotTestCase):
|
||||||
bot_name = "github_detail"
|
bot_name = "github_detail"
|
||||||
mock_config = {'owner': 'zulip', 'repo': 'zulip'}
|
mock_config = {'owner': 'zulip', 'repo': 'zulip'}
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ class StubBotHandler:
|
||||||
class StubBotTestCase(TestCase):
|
class StubBotTestCase(TestCase):
|
||||||
'''
|
'''
|
||||||
The goal for this class is to eventually replace
|
The goal for this class is to eventually replace
|
||||||
BotTestCaseBase for places where we may want more
|
BotTestCase for places where we may want more
|
||||||
fine-grained control and less heavy setup.
|
fine-grained control and less heavy setup.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
@ -85,6 +85,11 @@ class StubBotTestCase(TestCase):
|
||||||
response = bot_handler.last_test_response()
|
response = bot_handler.last_test_response()
|
||||||
self.assertEqual(expected_response, response['content'])
|
self.assertEqual(expected_response, response['content'])
|
||||||
|
|
||||||
|
def test_bot_usage(self):
|
||||||
|
# type: () -> None
|
||||||
|
bot = get_bot_message_handler(self.bot_name)
|
||||||
|
self.assertNotEqual(bot.usage(), '')
|
||||||
|
|
||||||
def get_bot_message_handler(bot_name):
|
def get_bot_message_handler(bot_name):
|
||||||
# type: (str) -> Any
|
# type: (str) -> Any
|
||||||
# message_handler is of type 'Any', since it can contain any bot's
|
# message_handler is of type 'Any', since it can contain any bot's
|
||||||
|
@ -134,7 +139,7 @@ def mock_http_conversation(http_data):
|
||||||
else:
|
else:
|
||||||
mock_get.assert_called_with(http_request['api_url'])
|
mock_get.assert_called_with(http_request['api_url'])
|
||||||
|
|
||||||
class BotTestCaseBase(TestCase):
|
class BotTestCase(StubBotTestCase):
|
||||||
"""Test class for common Bot test helper methods"""
|
"""Test class for common Bot test helper methods"""
|
||||||
bot_name = '' # type: str
|
bot_name = '' # type: str
|
||||||
|
|
||||||
|
@ -253,10 +258,3 @@ class BotTestCaseBase(TestCase):
|
||||||
def assert_bot_responses(self, message, *response_list):
|
def assert_bot_responses(self, message, *response_list):
|
||||||
# type: (Dict[str, Any], *Tuple[Dict[str, Any], str]) -> None
|
# type: (Dict[str, Any], *Tuple[Dict[str, Any], str]) -> None
|
||||||
self.call_request(message, *response_list)
|
self.call_request(message, *response_list)
|
||||||
|
|
||||||
class BotTestCase(BotTestCaseBase):
|
|
||||||
"""Test class extending BotTestCaseBase to add common default tests
|
|
||||||
that should be run (by default) for all our bots"""
|
|
||||||
def test_bot_usage(self):
|
|
||||||
# type: () -> None
|
|
||||||
self.assertNotEqual(self.message_handler.usage(), '')
|
|
||||||
|
|
Loading…
Reference in a new issue