Commit Graph

146 Commits

Author SHA1 Message Date
Steve Howell 942db9b6c5 tests: Added ZulipTestCase.example_user() function.
The example_user() function is specifically designed for
AARON, hamlet, cordelia, and friends, and it allows a concise
way of using their built-in user profiles. Eventually, the
widespread use of example_user() should help us with refactorings
such as moving the tests users out of the "zulip.com" realm
and deprecating get_user_profile_by_email.
2017-05-08 11:57:38 -07:00
hackerkid 83eb161249 Set user timezone automatically during signup. 2017-05-04 16:36:51 -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
Umair Khan d011bd736d api_auth: Change email to identifier.
We can have an email or a server uuid as an argument so identifier
looks like a more appropriate name
2017-04-27 11:30:53 -07:00
Aditya Bansal bdcddd35d0 tests: Add wrapper for client.logout in ZulipTestCase.
In this commit we add a logout wrapper so as to enable developers
to just do self.logout instead of doing a post request at API
endpoint for logout. This is achieved by adding a wrapper function
for the Django's client.logout contained in TestCase. We add this
by extending ZulipTestCase to have a logout function.
2017-04-21 21:45:55 -07:00
Eeshan Garg dded73ec6f webhooks: Stop overriding build_webhook_url for URL query parameters. 2017-04-21 22:06:11 -02:30
Eeshan Garg e68b957f3d webhooks/gogs: Filter specific Gogs branches. 2017-04-21 22:06:11 -02:30
Tim Abbott cddee49e75 Add support infrastructure for push notification bouncer service.
This is an incomplete cleaned-up continuation of Lisa Neigut's push
notification bouncer work.  It supports registration and
deregistration of individual push tokens with a central push
notification bouncer server.

It still is missing a few things before we can complete this effort:
* A registration form for server admins to configure their server for
  this service, with tests.
* Code (and tests) for actually bouncing the notifications.
2017-04-18 23:03:06 -07:00
Jacob Hurwitz 8343d80873 Fix mobile home view returning messages older than the pointer.
In cases where old unread messages in the home view might have been
leaked (either due to bugs or unusual muting interactions), it's
theoretically possible for the first unread message in the home view
to be far older than the pointer.

Since the Zulip mobile app is loading messages following the
use_first_unread logic, we need to plug this gap.

Probably a longer-term solution will involve changing how
update_message_flags works to automatically advance the pointer, but
this change should make it possible for the mobile apps to
consistently use the `use_first_unread` mechanism for fetching the
latest home view messages.

With tweaks to the tests by tabbott.

Fixes zulip/zulip-mobile#422.
2017-04-18 21:39:24 -07:00
K.Kanakhin 3d4020fd1c tests: Add AssertNotIn helper to the base test class. 2017-04-12 14:09:14 -07:00
Umair Khan 07ea08c184 test_classes: Remove assert_max_length.
We should avoid this kind of assertions because they are
not deterministic.
2017-04-04 17:07:34 -07:00
Tim Abbott 3617ebfd41 api: Rename get_old_messages to get_messages in the backend.
Fixes #1315.
2017-03-23 23:52:44 -07:00
Tim Abbott eb19a25aba events: Fix races in stream creation event and add tests.
This fixes 2 issues:
* Being added to an invite_only stream did not correctly update the
  "streams" key of the initial state.

* Once that's resolved, subscribe_to_stream when called on a
  nonexistant stream would both send a "create" event (from
  create_stream_if_needed) and an "occupy" event (from
  bulk_add_subscriptions).

  The second event should just be suppressed in that case, and this
  implements that suppression.
2017-03-23 22:43:09 -07:00
Akash Kothawale 4c2bfae83e get_stream: Throw DoesNotExist if stream is not found.
This makes get_stream match get_realm, get_user_profile_by_email,
etc., in interface, and is more convenient for mypy annotations
because `get_stream` now doesn't return an Optional[Stream].
2017-03-23 15:42:00 -07:00
Umair Khan 804c62045f testing: Flush API_KEYS before every test.
This makes our test performance for each test more consistent.
2017-03-22 12:07:06 -07:00
Tim Abbott a474f4359d tests: Set maxDiff to None unconditionally. 2017-03-21 07:34:16 -07:00
Elliott Jin fde1aa506b tests: Prevent misuse of assert_in_success_response.
Changing assert_in_success_response to require List[Text] instead of
Iterable[Text] prevents the following misuse:

    self.assert_in_response_success("message", response)

Currently, this will check whether 'm', 'e', 's', 'a', and 'g' separately
appear in the response, which is probably not the intended behavior.  The
correct usage is as follows:

    self.assert_in_response_success(["message"], response)
2017-03-18 15:49:35 -07:00
Umair Khan 7b1742fdef send_message: Allow message to be sent to a huddle. 2017-03-14 09:35:08 -07:00
Tim Abbott 8bdbcbc371 lint: Fix unnecessarily translated test file strings.
Our linter for translation strings shouldn't check test files, since
then we'll end up translating non-user-facing strings.

So we fix that, and actually add the opposite lint rule.
2017-03-09 00:37:44 -08:00
Tim Abbott c8e38aaa55 coverage: Add coverage for OPTIONS HTTP method. 2017-03-05 00:53:26 -08:00
Tim Abbott 546fb9199d coverage: bring test_classes.py to 100% coverage. 2017-03-05 00:53:26 -08:00
Umair Khan a9bc625dda testing: Serialize test_upload.
This commit makes test_upload tests compatible with parallel model.
2017-02-17 12:40:39 -08:00
Tim Abbott 0c363dffca lint: Ban use of deprecated assertEquals. 2017-02-08 16:38:43 -08:00
Tim Abbott 84b18f865a users: Verify full names explicitly in account registration.
I believe this completes the project of ensuring that our recent work
on limiting what characters can appears in users' full names covers
the entire codebase.
2017-02-07 20:20:32 -08:00
Tim Abbott 54bcc675f7 subscribe_to_stream: Return the stream object.
This simplifies some code paths a bit.
2017-01-29 20:26:59 -08:00
Rishi Gupta 89af775e03 test_classes: Remove domain from ZulipTestCase.register. 2017-01-06 19:45:08 -08:00
Rishi Gupta 021c65a656 test_classes: Remove domain from ZulipTestCase.submit_reg_form_for_user. 2017-01-06 19:45:08 -08:00
Juan Verhook cfa9c2eaf2 mypy: Update zerver directory to use Text 2016-12-29 09:12:15 -08:00
Rishi Gupta 717afcb408 Remove calls to get_realm in preparation for its deprecation.
Also removes two calls to email_to_domain.
2016-12-26 17:53:32 -08:00
Robert Hönig 0917493588 mypy: Convert zerver/lib to use typing.Text. 2016-12-25 10:33:45 -08:00
Sampriti Panda 567fab1137 tests: Add client_put_multipart to allow for file uploads using PUT 2016-12-21 13:35:22 -08:00
Rafid Aslam 5cc8838df4 tests: Add `assert_url_serves_contents_of_file()` to `ZulipTestCase`
Add `assert_url_serves_contents_of_file()` in `ZulipTestCase` class
and deduplicate some codes.

Fixes #1276.
2016-12-20 08:06:22 -08:00
Sampriti Panda c0326d1938 Add lint rule to disallow python calls with versions (e.g: python2, python3)
Fixes #2435
2016-12-19 08:00:48 -08:00
Tomasz Kolek 34511065dc Fix tests problem with backward incompatible function name.
Add __init__ methods to some of testing clases with overriding method name.
2016-12-16 07:04:55 -08:00
sidhant bhavnani 4634c3d656 Change call signature for users_subscribed_to_stream()
The function users_subscribed_to_stream() now takes realm now, instead of domain.
2016-12-05 15:46:19 -08:00
nikolay abc2ff4a06 pep8: Fix many rule E128 violations.
[Tweaked by tabbott to adjust some approaches used in wrapping]
2016-12-03 13:33:31 -08:00
Rafid Aslam c5316b4002 lint: Fix E127 pep8 violations.
Fix pep8: E127 continuation line over-indented for visual indent
style issue.
2016-12-01 10:23:55 -08:00
sylvan1 443cf92640 mypy: Change Generator[None, None, None] to Iterator[None].
Fixes #1648.
2016-11-27 10:42:16 -08:00
Tim Abbott 3d1bcb05e1 tornado: Move event_queue.py to zerver/tornado/.
Fixes #729.
2016-11-26 22:29:28 -08:00
Tim Abbott 169d404579 tornado: Move zerver.lib.handlers into zerver.tornado.handlers.
This cleans up the confusingly duplicated file names, while also
moving more of the Tornado-specific code under zerver/tornado/.
2016-11-26 22:29:28 -08:00
Rishi Gupta 4b183cd526 domain migration: Remove several instances of get_realm.
Remove the easy to remove instances of get_realm.
2016-11-26 15:19:56 -08:00
Calvin Lee 7a3ef2b0eb tests: Add assert_in_success_response in ZulipTestCase.
Clean up the instances of self.assertIn("string", result.content.decode("utf-8")),
and replace them with self.assert_in_response("string").

Fixes: #2313
2016-11-26 14:52:44 -08:00
Steve Howell 1527823b9f code cleanup: Remove some unused variables in test classes. 2016-11-26 09:52:37 -08:00
Steve Howell 3a8282ff44 Add test coverage for /notify_tornado.
We now have test coverage for all of our endpoints.
2016-11-17 10:11:46 -08:00
Rishi Gupta c1713c9659 Prevent code from using email domain to determine realm when subdomains.
Also removes the intermediate step of going through Realm.domain in the
non-subdomains case. Part of a larger project to remove Realm.domain
entirely.
2016-11-11 15:26:51 -08:00
sinwar 4582a98c09 tests: Split out ZulipTestCase and WebhookTestCase to a separate file.
Fixes #1671.
2016-11-10 19:29:43 -08:00