Commit graph

1648 commits

Author SHA1 Message Date
Robert Hönig 192e9e101d bots: Add magic method validate_config().
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.
2018-02-13 11:02:17 -08:00
Robert Hönig 7dcec207eb lib_tests.py: Set realistic spec for BotHandler mock. 2018-02-13 11:02:17 -08:00
Eeshan Garg f74c94ba04 pypi_packaging: Release version 0.4.1. 2018-02-07 01:03:49 -03:30
Robert Hönig bda4b74c50 mention bot: Add fixture for invalid api key test.
This makes the mention bot tests no longer rely on an
internet connection to succeed.
2018-02-06 15:27:45 +01:00
Robert Hönig 4ed31eb6fd baremetrics bot: Add fixture for invalid api key test.
This makes the baremetrics bot tests no longer rely on an
internet connection to succeed.
2018-02-06 15:27:45 +01:00
AmAnAgr acf45ea4ef converter: Get test coverage to 100%
Fixes #122
2018-02-01 16:13:54 -05:00
Viraat Chandra d9fca54998 bots: Fix test failure for Baremetrics bot. 2018-01-24 11:19:44 +01:00
fredfishgames 3cbb16722d zulip_bots: Migrate tictactoe bot to new game_handler. 2018-01-22 11:30:31 -05:00
fredfishgames 3a438cafa9 zulip_bots: Migrate connect_four bot to new game_handler. 2018-01-22 11:30:31 -05:00
fredfishgames ec5be8fc7e zulip_bots: Consolidate game-playing bots. 2018-01-22 11:30:31 -05:00
Steve Howell 25820c9bb2 provision: Do not even suggest the --force option.
Suggesting to users that they use '--force' during provision
is just asking for trouble.  We will probably want to deprecate
that altogether soon.
2018-01-19 07:50:40 -05:00
Viraat Chandra 2f429fcb86 zulip_bots: Add test for create-plan command of Baremetrics bot. 2018-01-16 12:24:26 -05:00
Viraat Chandra 94f82dfe4c zulip_bots: Add feature create-plan to Baremetrics bot. 2018-01-16 12:24:26 -05:00
XavierCooney 68ec3a5ef0 zephyr_mirror_backend.py: Remove duplicate import. 2018-01-16 08:07:09 -05:00
Viraat Chandra e32336eb6e Improve test coverage for Yoda bot. 2018-01-12 07:35:38 -05:00
Viraat Chandra fd97ffce77 Improve test coverage for Mention bot. 2018-01-12 07:35:38 -05:00
Viraat Chandra bffb8d0e16 Improve test coverage for Baremetrics bot. 2018-01-12 07:35:38 -05:00
Eeshan Garg 67cdb6f8f0 zulip: Make a DELETE request in remove_subscriptions.
Previously, remove_subscriptions called the
PATCH /api/v1/users/me/subscriptions endpoint, which is more like
an ad-hoc endpoint for bulk adding/removing subscriptions for the
user that makes the request. However, making a DELETE request
allows an admin to pass in the `principals` argument to unsubscribe
other users from streams as well, which is more consistent with how
add_subscriptions works.
2018-01-12 07:29:06 -05:00
rht da4b830571 bots: Init interrealm bridge bot. 2018-01-12 07:15:23 -05:00
Steve Howell 480c953b98 virtual_fs: Add test_sample_conversation(). 2018-01-10 16:54:05 -05:00
Steve Howell 5be72288db virtual_fs: Make sample_conversation() a list of tuples.
It's nice to see the requests and replies as separate strings
when you're reading the code.
2018-01-10 16:54:05 -05:00
Steve Howell f8d51fc9d1 virtual_fs: Remove help commands from the sample conversation. 2018-01-10 16:54:05 -05:00
Steve Howell 820e949faf virtual_fs: Remove fs_sample_conversation().
We already have "help" for specific commands, so the
fs_sample_conversation() feature was mostly redundant.
2018-01-10 16:54:05 -05:00
Steve Howell 4b9e3d655f virtuals_fs: Add test for sample_conversation. 2018-01-10 16:54:05 -05:00
Steve Howell 917bd82019 bot tests: Extract get_reply_dict() test helper. 2018-01-10 16:54:05 -05:00
Eeshan Garg 4458276801 requirements: Remove runtime dependency on mock.
The zulip and zulip_botserver packages specify mock as a runtime
dependency, which is only needed for testing during development.
So, it made more sense to move it to requirements.txt so that
it can be installed by ./tools/provision during development.
2018-01-09 17:01:16 -03:30
Steve Howell 88f6ddefb2 virtual_fs: Fix bug with "rmdir" command.
In python3, if you removed a directory that files within it,
you would get an error saying "dictionary changed size
during iteration."

The fix is to list-ify the keys before iterating over them (and
popping keys from the dictionary).
2018-01-09 09:21:30 -05:00
Eeshan Garg e528577f11 tools/release-packages: Generate Python3 dist for zulip_bots.
Now that zulip_bots is fully Python3, it makes sense to only
generate a Python3 wheel dist for it. zulip and zulip_botserver
are still distributed as a py2/py3 universal wheel.
2018-01-08 21:17:28 -03:30
Eeshan Garg 072d43b7c3 tools/release_packages: Stop generating sdists.
Now that we do not use MANIFEST.in for zulip_bots, it doesn't
make sense to distribute sdists, because sdists don't pick up
data files specified in the package_data argument to setup().

Also, it isn't a huge deal if we don't distribute sdists for our
packages. Most PyPI projects only release wheels and pip will also
use wheels if available. So, this made sense!
2018-01-08 21:17:28 -03:30
Eeshan Garg e20b754498 zulip_bots: Use package_data instead of MANIFEST.in.
This commit removes generate_manifest.py and package data files
are now included using the package_data kwarg to setup().

This is because, in certain situations, MANIFEST.in is a bit
finicky. For instance installing a package using:

python setup.py install

doesn't include files specified in MANIFEST.in, while using

pip install ./zulip_bots

does. package_data doesn't pose this problem, ergo it's better
for us.
2018-01-08 18:28:50 -03:30
neiljp (Neil Pilgrim) 2366b22405 Tools: Update tools/run-mypy to default to strict-optional. 2018-01-08 15:39:03 -05:00
neiljp (Neil Pilgrim) d3220eefe7 Jabber: Report where Zulip config not found, clarifying typing. 2018-01-08 15:39:03 -05:00
neiljp (Neil Pilgrim) b5c3442b57 mypy: Remove explicit typing & add assertions in jabber backend.
Usage indicates set_jabber_client must be called before using
JabberToZulipBot, so assertions express intent & satisfy mypy.
2018-01-08 15:39:03 -05:00
neiljp (Neil Pilgrim) afee6d706f mypy: Assert Zulip.[api_key|email] are not None, satisfying use in Zephyr. 2018-01-08 15:39:03 -05:00
neiljp (Neil Pilgrim) aa718da3e1 Zephyr: For correctness & mypy, res.get('result') -> res['result'].
Also correct nearby error message (subscribing to -> receiving).
2018-01-08 15:39:03 -05:00
neiljp (Neil Pilgrim) 02d9ba8edd mypy: Add cast for zephyr_mirror_backend logger variable. 2018-01-08 15:39:03 -05:00
neiljp (Neil Pilgrim) 466f5a7167 mypy: Amend zephyr mirror annotations for strict-optional. 2018-01-08 15:39:03 -05:00
neiljp (Neil Pilgrim) 2b172e08c7 mypy: Correct SVN integration & satisfy strict-optional typing.
The commit_notice_destination return value was previously not
checked against None, which indicates no message should be sent.
2018-01-08 15:39:03 -05:00
neiljp (Neil Pilgrim) 9502e0eb9a hg integration: Use explicit sys.exit. 2018-01-08 15:39:03 -05:00
neiljp (Neil Pilgrim) 55df1886cc mypy: Amend hg integration to simplify error handling/typing. 2018-01-08 15:39:03 -05:00
neiljp (Neil Pilgrim) d26e44ebb2 mypy: Add client_cert assertion & amend annotation in Zulip API. 2018-01-08 15:39:03 -05:00
neiljp (Neil Pilgrim) 13bf6f7262 mypy: Add non-None session assertion in Zulip API. 2018-01-08 15:39:03 -05:00
neiljp (Neil Pilgrim) 2a2c8ae25f API: Amend call_on_each_event error handling to not use .get().
mypy with strict-optional led to examination of res.get('result')
calls potentially raising TypeError ('error' in None).

Server code indicates this is safe, and other nearby code assumes
presence of fields in 'res' also.
2018-01-08 15:39:03 -05:00
Xavier Cooney 1de704394a interactive bots: Create idonethis bot. 2018-01-08 10:46:52 +01:00
Eeshan Garg 3030c73060 packages: Release 0.4.0. 2018-01-06 18:28:35 -03:30
Robert Hönig c36b8d1199 packaging: Include bot .conf files in zulip_bots. 2018-01-06 16:58:50 -03:30
Robert Hönig a4facb4249 Rename followup.config to followup.conf. 2018-01-06 16:58:50 -03:30
Robert Hönig 78d7f9694e zulip_bots: Move six imports. 2018-01-06 16:39:52 +01:00
Robert Hönig 0893a5f61e zulip_bots setup.py: Install deps from the bots' requirements.txt files.
This makes it straightforward to add dependencies for a bot,
and works around https://github.com/pypa/pip/issues/4957.
2018-01-06 16:39:52 +01:00
Robert Hönig 56a9cbe5af Make bot provisioning script install dependencies globally.
Previously, a bot's dependencies were installed within the
bot's directoy, which is unconventional and doesn't work with tests.
2018-01-06 16:39:52 +01:00