Commit Graph

704 Commits

Author SHA1 Message Date
Daria Phoebe Brashear
8343cd4300 zephyr_mirror.py: update zulip server url for zephyr documentation
zulipchat.com hosts the documentation (as well as the server); make the
url reflect it
2017-06-26 14:07:28 -07:00
Shane Kearns
954436540f integrations/perforce: Skip messages for missing streams.
For a large perforce server with many users, this allows projects
to opt-in to zulip notifications by creating the stream for the
branch to be monitored.

Commits to paths for which a stream mapping yields a result,
but no stream exists in Zulip, are simply dropped silently.

This behaviour is opt-in, by setting the configuration key
ZULIP_IGNORE_MISSING_STREAM = True
in the zulip_perforce_config.py file.
2017-06-22 14:27:13 -04:00
Shane Kearns
6d467b4fff integrations/perforce: Display changelist ID as a p4web link.
The general regex-based linkify in zulip does not allow '@' as the
prefix. In any case we know here that it is definitely a changelist
number, which is better.

Adding P4_WEB="https://p4web.example.com" to the config will enable
this behaviour. If P4_WEB is absent from the config, or has the
value None, no link is inserted.
2017-06-22 14:27:13 -04:00
Shane Kearns
dd0eca3e58 integrations/perforce: Fix formatting of multiple paragraphs.
This fixes multiple paragraphs in a commit message escaping
from the block quote by using triple-backquote quoting instead
of '>' which only applies to one paragraph.
2017-06-22 14:27:13 -04:00
Rohitt Vashishtha
180c99cb63 bots: Add tests for github_detail bot. 2017-06-22 11:25:31 -04:00
Rohitt Vashishtha
ec4276cc6c bots: Fix github details bot. 2017-06-22 11:25:31 -04:00
Rohitt Vashishtha
686acbcd3b bots: Move github issue bot to api/bots. 2017-06-22 11:25:31 -04:00
vaibhav
9904edcd14 zulip-bot-server: Add test suite for zulip bot server.
Fixes: #5358.
2017-06-22 10:37:05 -04:00
vaibhav
5f53497ccd zulip-bot-server: Rename and move source file to api/zulip directory and
add support for running the server from any place.
2017-06-22 10:37:05 -04:00
vaibhav
7fbf517c9c zulip-bot-server: Add optparse for parsing the flaskbotrc file path and
commandline arguments.
2017-06-22 10:37:05 -04:00
vaibhav
26f1799ea4 zulip-bot-server: Add error handling and informative error messages. 2017-06-22 10:37:05 -04:00
Rohitt Vashishtha
45f27cd058 bots: Allow optional config files for bots. 2017-06-21 16:43:58 -04:00
Rohitt Vashishtha
f33e6858cd bots: Add HTTP status code support to mock http conversations. 2017-06-21 16:43:58 -04:00
Abhijeet Kaur
c42d935be8 bots: Move "EmbeddedBotHandler" class to "zerver/lib/bot_lib.py" file.
This would keep embedded classes for zulip at one place, that is, in
"zerver" directory. This also fixes break in PyPI package for bindings.
2017-06-21 16:01:16 -04:00
Abhijeet Kaur
55c0dee1c3 bots: Add a separate class "EmbeddedHandlerBots" in bot_lib.py.
Add another class for bot type as embedded bot, for bots that run directly
on Zulip server. This class uses internal 'internal_send_messages' from
actions.py instead of using the 'send_message' function from Zulip Client
class.

We haven't gone ahead with creating an abstract superclass right away.
We just have two versions for now, it would be easier to iterate a little
more on the interfaces, and then only add the superclass when we're ready
to lock down the interface.
2017-06-21 10:22:53 -04:00
Abhijeet Kaur
bc6b66cdfc bots: Remove unnecessary comment from test_giphy file.
This comment was added to explain the functionality of the
method called below it. Some changes in the method have led this
comment to be unnecessary.
2017-06-21 10:22:53 -04:00
Abhijeet Kaur
68777e93a0 bots: Rename BotHandlerApi class to ExternalBotHandler.
This change is done for better understanding of the class functionality
from its class name. Now there will be 3 different classes for bots,
namely 'ExternalBotHandler', 'FlaskBotHandler' and  'EmbeddedBotHandler'.
2017-06-21 10:22:53 -04:00
neiljp
f1b3e943c6 Extend message parameters passed in check_expected_responses 2017-06-20 07:19:12 -04:00
Robert Hönig
d91691be2f bots: Update yoda bot to use get_config_info(). 2017-06-19 07:11:08 -04:00
Robert Hönig
a48da1e6ca bots: Update weather bot to use get_config_info(). 2017-06-19 07:11:08 -04:00
Robert Hönig
651a21810d bots: Update foursquare bot to use get_config_info(). 2017-06-19 07:11:08 -04:00
Robert Hönig
c0f820e459 bots: Update commute bot to use get_config_info(). 2017-06-19 07:11:08 -04:00
Robert Hönig
bc183b8e61 bots: tests: Remove superfluous sys.path insertion. 2017-06-19 07:11:08 -04:00
Robert Hönig
a869cab2db bots: Correctly set paths to bot modules for testing. 2017-06-19 07:11:08 -04:00
Tim Abbott
5f299328b0 mypy: Fix likely typeshed warning with readfp. 2017-06-15 03:42:05 -07:00
Robert Hönig
6b0aa7f345 bots: Check existance of config file in get_config_info(). 2017-06-15 02:17:31 -07:00
Robert Hönig
790240cc57 bots: Test get_config_info with giphy bot.
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.
2017-06-14 20:25:07 -07:00
Robert Hönig
027f344f7e bots: tests: Mock bots only once.
This is done by moving the mocking and patching
code to the `setUp` and `tearDown` functions.
2017-06-14 20:25:07 -07:00
Robert Hönig
af5a17540b bots: Add get_config_info function for bots. 2017-06-14 20:25:07 -07:00
Robert Hönig
6d47d1bdba bots: Add non-obligatory initialize func for bots.
A bot that implements `initialize(client)` has initial
access to the `client` object, before `handle_message`
is called.
2017-06-14 20:25:07 -07:00
Robert Hönig
f9c5086658 bots: Rename BotHandlerApi object client to bot_handler. 2017-06-13 11:13:23 -07:00
Robert Hönig
21b8a78bb8 bots: Move mock http conversations to fixtures. 2017-06-13 09:22:35 -07:00
vaibhav
dbc56e29a5 bots: Add simple flask server for running contrib bots. 2017-06-12 22:08:44 -07:00
Robert Hönig
8aadad6db8 bots: tests: Move http mock to context manager.
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().
2017-06-09 05:25:17 -05:00
Tim Abbott
202f01b06c test-bots: Fail if a bot is missing __init__.py. 2017-06-08 09:21:12 -07:00
neiljp
68c6389fa6 Switch back to single suite of tests & add --exclude option 2017-06-08 09:18:24 -07:00
Tim Abbott
ddcc1d3c2b bots: Add missing __init__.py files. 2017-06-08 09:18:24 -07:00
Tim Abbott
d3df4307d3 test-bots: Fix lint errors. 2017-06-07 14:02:27 -07:00
derAnfaenger
9e3e2c56ce bots: Refactor and simplify bot_test_lib.py.
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.
2017-06-06 23:06:40 -07:00
neiljp
130c79d4d8 test-bots: Enable list of bots to test & check for valid bot names. 2017-06-06 22:29:57 -07:00
Tim Abbott
d18e0bcdca log2zulip: Fix paths to the rest of the project. 2017-06-05 23:48:31 -07:00
Abhijeet Kaur
46883c5c0d bots: Add test file for 'giphy' bot.
This bot replies with different gif for the same query
that is provided. Mocked a definite response from requests.get
function.
2017-06-05 15:11:46 -07:00
Tim Abbott
96c75db558 bots: Refactor bot testing library to still support un-mocked HTTP.
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.
2017-06-05 15:11:46 -07:00
Abhijeet Kaur
bcc4ced413 bots: Add mock test support for bots using internet services.
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.
2017-06-05 15:11:24 -07:00
Aditya Bansal
0b746c5df4 pep8: Add compliance with rule E261 bots_test_lib.py. 2017-06-04 09:18:22 -07:00
Aditya Bansal
e3cf43399f pep8: Add compliance with rule E261 send.py. 2017-06-04 15:05:34 +05:30
Aditya Bansal
d2c215afde pep8: Add compliance with rule E261 zephyr_mirror_backend.py. 2017-06-04 15:05:22 +05:30
Aditya Bansal
cf9725836c pep8: Add compliance with rule E261 rss-bot. 2017-06-04 15:02:31 +05:30
Aditya Bansal
880314e45e pep8: Add compliance with rule E261 jabber_mirror_backend.py. 2017-06-04 15:01:39 +05:30
Aditya Bansal
02b855a389 pep8: Add compliance with rule E261 test-bots. 2017-06-04 15:00:58 +05:30