Commit Graph

257 Commits

Author SHA1 Message Date
Vishnu Ks
cc553125a1 tests: Move check_user_subscribed_only_to_streams to test_classes ZulipTestCase. 2017-11-16 21:17:31 -08:00
Steve Howell
17200bfbc9 tests: Simplify test_classes.fixture_data().
We eliminate the unnecessary force_text() helper and clean up
the formatting a bit.
2017-11-09 10:32:14 -08:00
rht
8242c15b48 zerver/lib: Remove unused imports (F401). 2017-11-07 16:37:13 -08:00
rht
19bd335cbb Change urllib import to be Python 3-specific. 2017-11-07 10:46:42 -08:00
neiljp (Neil Pilgrim)
692e2150c6 mypy: Explicitly specify List[Any] in test_classes.py. 2017-11-04 19:47:45 -07:00
rht
fef7d6ba09 zerver/lib: Remove u prefix from strings.
License: Apache-2.0
Signed-off-by: rht <rhtbot@protonmail.com>
2017-11-03 15:34:37 -07:00
Greg Price
26edde21f7 alias domains: Tweak a test helper that assumes hosts are subdomains.
Because this is for tests, a heuristic like this that's right in most
situations is actually fine; we can override it in the few cases where
a test might set up a situation where it fails.

So just make it clear for the next reader that that's what's going on,
and also adjust the helper's interface slightly so that its callers
do have that flexibility.
2017-10-30 18:29:29 -07:00
Steve Howell
b3192d17ab refactor: Extract get_stream_subscriptions_for_user(). 2017-10-29 18:36:35 -07:00
Steve Howell
d6c47573b2 Eliminate ZulipTestCase.send_message().
Now all tests use these three messages instead:

    send_stream_message
    send_personal_message
    send_huddle_message
2017-10-28 10:20:59 -07:00
Greg Price
6d403ff255 tests: Simplify set_http_host to dedupe its logic.
This will make it easier to change this logic.
2017-10-27 14:42:24 -07:00
Steve Howell
4b78f69a87 tests: Introduce send_huddle_message().
The tighter interface here makes for shorter lines (or
fewer multi-line calls) and it leads to stricter type
checking.
2017-10-27 11:00:23 -07:00
Steve Howell
9707767b21 tests: Introduce send_personal_message().
The tighter interface prevents the need to specify
Recipient.PERSONAL (which can often be inaccurate in the
huddle case, anyway), and it prevents tests from confusingly
specifying a "subject" field for PMs.
2017-10-27 11:00:23 -07:00
Steve Howell
25a6fbd05d tests: Introduce send_stream_message().
Having send_stream_message() avoids the need to supply
Recipient.STREAM as a parameter, and it also uses the more
modern name of `topic_name` for topics.  Under the hood, it
avoids some annoying steps for re-formatting the recipients,
since we just have a single stream name.
2017-10-27 11:00:23 -07:00
derAnfaenger
e041abd300 tests: Add create_test_bot() helper function. 2017-10-25 15:46:07 -07:00
Tim Abbott
85917a7269 subdomains: Improve support for using the root domain.
This modifies the realm creation form to (1) support a
realm_in_root_domain flag and (2) clearly check whether the root
domain is available inside check_subdomain_available before trying to
create a realm with it; this should avoid IntegrityErrors.
2017-10-18 23:38:55 -07:00
Tim Abbott
2604eb0a07 test_classes: Refactor submit_reg_form_for_user.
This is a pure refactor in preparation for adding another argument.
2017-10-18 23:30:51 -07:00
derAnfaenger
5ddc336844 tests: Add welcome bot as user. 2017-10-11 20:45:42 -07:00
Steve Howell
9202777d7f tests: Provide more useful output in assert_length(). 2017-10-06 14:30:30 -07:00
rht
035ed93111 zerver/lib: remove import six. 2017-09-27 19:10:28 -07:00
rht
2e12fe5e2e zerver/lib: Remove print_function. 2017-09-27 18:05:45 -07:00
Tim Abbott
c3911e3fb6 test_classes: Improve error handling for send_message. 2017-09-27 15:55:29 -07:00
rht
f43e54d352 zerver/lib: Remove absolute_import. 2017-09-27 10:00:39 -07:00
Robert Hönig
c77b245944 backend tests: Add 'AARON' as bot owner of OUTGOING_WEBHOOK_BOT. 2017-09-26 16:11:27 -07:00
Tim Abbott
c5d699b6fb tests_classes: Add DEFAULT_SUBDOMAIN feature.
This should make life a little easier for those tests that need to use
the same subdomain like 20 times.
2017-08-28 23:17:33 -07:00
Tim Abbott
4a22316d90 test_decorator: Add explicit subdomains in tests. 2017-08-28 22:51:57 -07:00
Tim Abbott
a8b9ffc020 test_classes: Include more detail in incorrect JSON responses.
If the status code is wrong, we show the actual error message now,
which often saves a bit of time when debugging.
2017-08-28 21:43:41 -07:00
Tim Abbott
27101ae931 trello: Use client_head wrapper in tests. 2017-08-26 13:45:27 -07:00
Tim Abbott
d18f389bb5 test_messages: Set subdomain explicitly in most tests. 2017-08-26 13:45:27 -07:00
rht
e2e56a3e71 test_subs: Fix dict unpacking. 2017-08-26 09:01:10 -07:00
Tim Abbott
edc095db6d test_subs: Explicitly declare subdomains. 2017-08-25 16:09:51 -07:00
Tim Abbott
7a5eb9dd9f tornado: Add support for testing with subdomains. 2017-08-25 15:42:58 -07:00
Tim Abbott
43cfe73908 tests: Make requests use the "zulip" subdomain by default.
Previously, we didn't pass customized HTTP_HOST headers when making
network requests.  As we move towards a world where everything is on a
subdomain, we'll want to start doing that.

The vast majority of our test code is written to interact with the
default "zulip" realm, which has a subdomain of "zulip".  While
probably longer-term, we'll wish this was the root domain, for now, we
need to make our HTTP requests match what is expected by the test
code.

This commit almost certainly introduces some weird bugs where code was
expecting a different subdomain but the tests doesn't fail yet.  It's
not clear how to find all of these, but I've done some grepping.
2017-08-25 15:42:49 -07:00
Tim Abbott
b0c8404622 tests: Add subdomain option to client_get and friends.
This should help make it easy to set the domain explicitly in tests
where that's important.
2017-08-25 15:42:42 -07:00
Tim Abbott
4229faf36e tests: Remove old six.PY2 code paths. 2017-08-25 11:05:16 -07:00
Tim Abbott
50defd9b70 test_classes: Remove some unnecessary functions. 2017-08-24 23:33:12 -07:00
Tim Abbott
7d08ff69f0 tests: Remove most references to get_api_key.
This test helper doesn't really have value.
2017-08-24 23:30:46 -07:00
Tim Abbott
59aae22f99 registration: Fix find_my_team handling of unusual users. 2017-08-24 23:17:08 -07:00
Tim Abbott
e915fa058a test_classes: Stop using get_realm_by_email_domain.
get_realm_by_email_domain was intended to be registration flow code
not used in other code, but it was leaked to a few places.  This
removes one of the main remaining references to it outside the
registration code path.
2017-08-24 21:38:02 -07:00
Tim Abbott
95ed00bade tests: Remove now-unused subscribe_to_stream helper. 2017-08-24 21:38:02 -07:00
Tim Abbott
69059dcac8 tests: Clean up subscribing from webhook tests. 2017-08-24 21:37:57 -07:00
Tim Abbott
5fa7c3e0b2 test_classes: Clean up API for unsubscribing.
The old API required test authors to unnecessarily repeat themselves.
2017-08-24 21:37:57 -07:00
Tim Abbott
eb720485c5 tests: Add and use new self.subscribe.
This new method cleans up the API for subscribing to something from a
test case.
2017-08-24 21:37:57 -07:00
Umair Khan
abed403a81 result.json: Upgrade test_classes. 2017-08-17 09:03:35 -07:00
Jack Zhang
e915321f89 registration: Remove organization type selection in realm creation. 2017-07-21 13:09:06 -07:00
Tim Abbott
6ac9bae5f5 bulk_add_subscriptions: Clarify name of from_stream_creation arg.
The old name was ambigious for whether it was about user or stream
creation.
2017-07-17 17:23:41 -07:00
Vishnu Ks
098569ccb4 test_classes: Use get_user in unsubscribe_from_stream. 2017-07-13 14:13:03 -07:00
Vishnu Ks
99e78cbead test_classes: Use get_user in get_streams function. 2017-07-13 14:13:03 -07:00
Vishnu Ks
bf729c9a4d test_classes: Use get_user in notification_bot fcuntion. 2017-07-13 00:45:24 +05:30
Vishnu Ks
f28b29177b test_classes: Use get_user in mit_user function. 2017-07-13 00:45:24 +05:30
Vishnu Ks
0b701b52df test_classes: Use get_user in example_user function. 2017-07-13 00:45:24 +05:30
Vishnu Ks
c5f75a8f3d test_classes: Remove client_put_multipart function.
We are no longer using this method anywhere. Removing this
is essential for making the backend coverage tests to pass.
2017-07-07 10:31:43 -07:00
Rishi Gupta
36cd122905 models: Change default org_type to CORPORATE.
Once we implement org_type-specific features, it'll be easy to change a
corporate realm to a community realm, but hard to go the other way. The main
difference (the main thing that makes migrating from a community realm to a
corporate realm hard) is that you'd have to make everyone sign another terms
of service.
2017-06-29 15:14:58 -07:00
Tim Abbott
6aaca44e17 tests: Fix str/Text mypy issues in various tests. 2017-05-24 15:19:38 -07:00
Rick Chern
e53d1c3885 tests: Remove get_user_profile_by_email from most tests. 2017-05-24 13:05:19 -07:00
umkay
ccc70445d6 mypy: Fix strict-optional errors for test files.
Fix mypy --strict-optional errors in zerver/tests
2017-05-24 12:43:28 -07:00
Vishnu Ks
f5d8e256aa Add ZulipTestCase.example_email and ZulipTestCase.mit_email function. 2017-05-23 15:27:21 -07:00
Vishnu Ks
7f06a7fa2a Add ZulipTestCase.mit_user() function. 2017-05-22 19:02:42 -07:00
Aditya Bansal
26ff19f005 pep8: Add compliance with rule E261 to zerver/lib/test_classes.py. 2017-05-18 03:00:32 +05:30
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
Umair Khan
10ed47156d api_auth: Use is_remote_server. 2017-05-11 12:02:26 -07:00
Steve Howell
3b2a3601c1 tests: Add ZulipTestCase.notification_bot(). 2017-05-08 11:57:38 -07:00
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