Previously the test-bots script filtered out base-class tests from
BotTestCase. With this change, BotTestCase continues to inherit from
unittest.TestCase, but the default test_* methods previously in this
class are now in a new DefaultTests class, which does not. Instead, each
bot needs to inherit from BotTestCase and DefaultTests *explicitly*.
This avoids the need to filter out the base-class tests, which
simplifies the test-bots script, and may ease any migration to eg.
pytest.
The DefaultTests class does require some non-implemented methods which
BotTestCase provides.
We just moved the logic for installing bot dependencies from setup.py
to tools/provision. So bot dependencies are not automatically installed
anymore as a part of the base package. Now, if there is an import error
caused by missing dependency, we display a neat error message asking
the user to provision bot dependencies.
The bot provisioning code was breaking due to pip.main not being
a function anymore. Also, I don't think we should pass the --quiet
option here. I felt it was good to have some visual information
about what deps were being installed, just in case if something
went wrong and there was a conflict, the user should be able to
see it.
Remove unReachable `elif` branch from `dbx_command`
method with checking whether the command is equal
to `help` because this check is performed
at the beginning of the method.
A lot of these bot dependencies are pretty hefty and shouldn't be
installed as part of the zulip_bots package. So the installation of
these belongs in tools/provision, not in setup.py.
Previously, the responses set in bot test fixtures
where handled as JSON objects. This works fine for
most bot tests, because most of the APIs that bots
are calling return a JSON-formatted response object.
However, some, like Trello, do return raw data.
This hasn't been noticed so far, because the respective
Trello test needed internet access. Tests shouldn't
need internet access.
This commit makes that Trello test use a fixture. To
work properly, it also adds a way to make http_mock_config
parse the response object as raw data.
This can now be done by modifying the "is_raw_response"
property in a newly introduced "meta" object that can
be used to specify how a fixture should be handled.
Change checking auth_token in `initialize` method by calling
request to get user's information instead of calling POST request
which modifies progress of user's goal.
This improves the ability of a bot to specify how to mention it,
which varies at run-time depending upon the identity used to run it;
this is commonly used in many bot help commands.
The monkeytestit tests fail on Python3.4 because
one of their dependencies only works on Python3.5.
This is a hotfix to make builds pass again. We'll
want to find a proper way of Python version conditional
bot test execution.
We need to import the bot class inside the tests, so
we are able to temporarily resolve problems with the
bot class by simply skipping the test. It also makes
the code look nicer.
The pip documentation recommends calling pip using a subprocess, instead of
importing it and using it's internal API. The API of pip==10.0.0 is different
from that of older versions, and provisioning is broken with this version.
[pip docs]:
https://pip.pypa.io/en/stable/user_guide/#using-pip-from-your-programCloses#370
Currently, if a user does 'move 0', he moves to column 6(last column)
in connect_four which is unwanted behaviour and happening due to
list getting accessed through negative index (-1).
Added a check for that in controller.py file.
Fixes#343
This commit tests that we throw a BadMoveException if you
try to move into a "full" column in connect four. This gets
the controller up to 100% coverage.
Allow a game to start even if `max_players` is not reached.
Adding a new command `play game` to start a game if the
number of players is between max and min no. of players.
Make tests pass with the new change.
This method allows bots to validate their config info
in a standardized way. Adding the method to a bot is
optional, but recommended for bots with config options
that can be invalid, like api keys. The giphy bot serves
as an example.
The primary reason behind this is to allow the zulip
backend to validate config data for embedded bots. The
backend does not have a permanent bot class instance, so
validate_config() must be a static method.