Commit Graph

40 Commits

Author SHA1 Message Date
Steve Howell c235333041 test performance: Pass in users to api_* helpers.
This reduces query counts in some cases, since
we no longer need to look up the user again. In
particular, it reduces some noise when we
count queries for O(N)-related tests.

The query count is usually reduced by 2 per
API call.  We no longer need to look up Realm
and UserProfile.  In most cases we are saving
these lookups for the whole tests, since we
usually already have the `user` objects for
other reasons.  In a few places we are simply
moving where that query happens within the
test.

In some places I shorten names like `test_user`
or `user_profile` to just be `user`.
2020-03-11 14:18:29 -07:00
Tim Abbott c10cc24ee8 python: Sort webhooks imports with isort. 2020-01-14 13:07:47 -08:00
Eeshan Garg a73e8109b7 webhooks: Remove the legacy GitHub integration.
The github-services model for how GitHub would send requests to this
legacy integration is no longer available since earlier in 2019.
Removing this integration also allows us to finally remove
authenticated_api_view, the legacy authentication model from 2013 that
had been used for this integration (and other features long since
upgraded).

A few functions that were used by the Beanstalk webhook are moved into
that webhook's implementation directly.
2019-04-27 15:13:44 -07:00
Anders Kaseorg 39ac378220 webhooks: Remove unused imports.
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2019-02-02 17:05:20 -08:00
Steve Howell ced4d81856 Sweep tests for expected_subject -> expected_topic.
This is all in the webhooks tests, including some
docs for how to write those tests.
2018-11-12 15:47:11 -08:00
Eeshan Garg 185a023745 webhooks/beanstalk: Improve test coverage.
We shouldn't just ignore exceptions when encoding the incoming
auth credentials. Even if the incoming credentials are properly
encoded, it is better to know when that is the case or if
something else fails.
2018-10-04 12:16:06 -07:00
Aditya Bansal a40ae4cae5 zerver/webhooks: Change use of typing.Text to str. 2018-05-12 15:21:24 -07:00
Aditya Bansal 64ddfc6ac0 zerver/webhooks: Change use of typing.Text to str. 2018-05-10 14:19:49 -07:00
Preston Hansen e168f9938c tests: Refactor use of test and webhook data fixtures. 2018-04-19 21:50:29 -07:00
Eeshan Garg 48b8558c02 webhooks: Move github/ to github_legacy/ and remove docs. 2018-04-19 11:00:55 -07:00
Tim Abbott 34e165c100 webhooks: Fix passing client string to authenticated webhook API views.
This fixes a regression in 93678e89cd
and a4979410f9, where the webhooks using
authenticated_rest_api_view were migrated to a new model that didn't
include setting a custom Client string for the webhook.

When restoring these webhooks' client strings, we also fix places
where the client string was not capitalized the same was as the
product's name.
2018-03-16 15:43:19 -07:00
Eeshan Garg 93678e89cd webhooks: Migrate 14 webhooks to use check_send_webhook_message.
These are the straightforward ones.

Note that there is a line in zerver.lib.test_classes.build_webhook_url
that lost test coverage. That's because most of our tests test using
stream messages so the webhook URLs being tested always have a query
parameter. So the line that accounts for there being no query
parameters never gets called, which is fine, but we should still
keep it.
2018-03-16 11:34:20 -07:00
neiljp (Neil Pilgrim) 17937175ac mypy: Centralize ViewFuncT definition into new file zerver/lib/types.py.
Originally was going to centralize this in zerver/lib/request.pyi, but this
file is not visible at run-time, being only a stub. The matching request.py
file seemed inappropriate, as it doesn't actually use ViewFuncT.
2018-03-15 14:16:40 -07:00
Eeshan Garg f551f3a9b8 webhooks/beanstalk: Update text to conform to doc style guide. 2018-03-08 08:19:32 -08:00
Rishi Gupta 76898dd4d3 integrations: Make minor wording changes to integrations docs. 2018-02-27 08:23:51 -08:00
Eeshan Garg 0d39b05cf6 webhooks/beanstalk: Update text and remove screenshots.
This commit:

* Removes the unnecessary screenshot.
* Reorders the instructions and combines them in to 4 steps.
* Improves the contents of the webhook-url-with-bot-email-indented.md
  macro and makes it more consistent with create-bot-construct-url.md.
* Sets the recommended stream name to "commits", since that's what
  the webhook function for Beanstalk expects in
  zerver/webhooks/beanstalk/view.py. This allows us to use the
  create-stream.md macro.
2018-02-24 06:21:02 -05:00
Patrick Grave a2ed76c383 mypy: Use Python 3 syntax for typing in beanstalk/tests.py 2018-01-23 08:49:42 -08:00
Rhea Parekh 99cb001345 zerver/webhooks/beanstalk/view.py: Sweep force_bytes and force_str. 2017-12-26 09:09:31 -05:00
Callum Fraser 33e1879295 mypy: Use Python 3 type syntax in zerver/webhooks/beanstalk/view.py. 2017-12-18 11:32:52 -05:00
Alena Volkova 90aa6c627e tests: Replace api_auth usages with auth methods in zerver/webhooks. 2017-12-18 09:24:09 -05:00
Eeshan Garg 1dca7cc367 webhooks/beanstalk: Use indented Markdown macros. 2017-11-25 17:01:11 -08:00
Tim Abbott 73a668e7ae python: Sort imports in webhooks. 2017-11-15 15:43:10 -08:00
rht 969cc506d2 zerver/webhooks: Use python 3 syntax for typing.
Tweaked by tabbott to fix various line-wrapping issues.
2017-11-04 19:40:32 -07:00
Eeshan Garg aaaed74c3d webhooks: Import REQ, has_request_variables from zerver.lib.request.
We now import REQ and has_request_variables from zerver.lib.request,
which is where these methods are defined.

Fixes #7195.
2017-11-02 14:40:55 -07:00
Eeshan Garg 86c2c7ad34 webhooks: Migrate to check_send_stream_message.
This commit migrates all webhooks to use check_send_stream_message
instead of check_send_message. The only two webhooks that still
use check_send_message are our yo and teamcity webhooks. They
both use check_send_message for private messages.
2017-09-30 17:48:55 -07:00
rht 7115a29bee zerver/webhooks: Remove absolute_import. 2017-09-27 10:00:39 -07:00
Eeshan Garg def4650d84 webhooks/beanstalk: Migrate docs to Markdown. 2017-06-05 11:22:06 -07:00
umkay c1a8fb615c mypy: Fix strict-optional errors in webhooks directory. 2017-05-24 18:57:06 -07:00
Eeshan Garg 597db11a98 webhooks: Rename webhook fixtures to only include event type.
All webhook fixtures have now been renamed from
<webhook_name>/fixtures/<webhook_name>_<event_type>.json to
<webhook_name>/fixtures/<event_type>.json.
2017-05-13 20:07:40 -02:30
Aditya Bansal f3c1557529 pep8: Add compliance with rule E261 to beanstalk/view.py. 2017-05-07 23:21:50 -07:00
Eeshan Garg aa12002be7 webhooks: Move all fixtures to zerver/webhooks/<webhook_name>/fixtures.
All webhook fixtures in zerver/fixtures/<webhook_name> have now
been moved to dedicated webhook-specific directories under
zerver/webhooks/<webhook_name>/fixtures, where <webhook_name> is
the name of the webhook.
2017-04-28 11:07:03 -07:00
Eeshan Garg ffdd5d3588 webhooks: Don't display "Commits by" when committer is the only author.
For our Git integrations, we now only display the number of commits
pushed when the pusher also happens to be the only author of the
commits being pushed.

Part of #3968.
Follow-up to #4006.
2017-04-26 18:26:09 -02:30
Eeshan Garg b7ca533315 webhooks: Add a space between author and number of commits for Git messages.
For Git push messages, we now have a single space character between
the name of a commit's author and the number of commits by that
author, plus a period at the end.

Part of #3968.
Follow-up to #4006.
2017-04-26 18:26:09 -02:30
Eeshan Garg af69faafc9 webhooks: Use author's name to format Git push messages.
We now use the name of the author of a commit as opposed to the
committer to format Git messages with multiple committers.

Part of #3968.
Follow-up to #4006.
2017-04-26 18:26:09 -02:30
Eeshan Garg 55e1154871 webhooks/beanstalk: Filter specific Git branches. 2017-04-21 22:06:11 -02:30
Siddharth Mahapatra e7455e276b git integrations: Expand details in commit push notifications.
We now show a few new things:
(1) The number of commits pushed.
(2) Who authored the commits (just counts, not which specific ones, for brevity).

Add tests for case of multiple committers.

Part of #3968.
2017-04-21 11:07:44 -07:00
wizsid11 19d1f4cab7 git integration: Change push commits message to show url at the end. 2017-03-16 11:06:03 -07:00
Raghav Jajodia a3a03bd6a5 mypy: Added Dict, List and Set imports.
Fixed mypy errors associated with the upgrade.
2017-03-04 14:33:44 -08:00
Tomasz Kolek 6e6cbeb89d Split webhooks doc and move to particular directories. 2017-01-26 11:56:45 -08:00
Tomasz Kolek 7de45951e2 Make webhooks as separate modules with view and tests.
Create python packege for every webhook with view.py and tests.py
2017-01-25 23:14:19 -08:00