This involves both using the new `initialize`
method for calling `get_config_info`, and
refactoring the testing framework by adding a
way for mocking this method.
This commit decouples the http mock conversation
feature from assert_bot_response(), and moves it
to the context manager mock_http_conversation().
This allows a modular design with context managers
that could be added for assert_bot_response().
This commit integrates the mock_test function in
check_expected_responses and makes this function usable
for simple tests only by not allowing mock http conversations.
assert_bot_response() is now used for single message-response pairs,
resolving potential issues with multiple messages and a single http
request-response pair.
The giphy bot test file is updated accordingly.
Several of our bots haven't been converted to have mock responses for
third-party APIs yet, and we may want that code path for with-network
testing anyway.
Mock requests.get function for bots relying on external services
which may return different results. 'http_response' is mocked to
check if the bots run well and to make the tests determinitic. The
code first checks if the http request corresponding to the http response
is called or not.
This commit renders test files of bots using the internet
(third party) services to Fail. As requests.get() is replaced
by our mock function.
Since we have not provided mock http response for bots like xkcd,
wikipedia, define etc. Their requests.get() function returns empty
message.
Since few bots directly call 'send_message' function of
'BotHandlerApi' class instead of calling 'send_reply' function
first, add 'mock_test_send_message' to check for 'send_message'
function.
All test_<bot>.py files now need to specify which function the bot
will be sending the response to, for each particular message.
Make 'test_virtual_fs.py' and 'test_thesaurus.py' test files
consistent with other bots.