Commit Graph

21 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
Mateusz Mandera
6a0b68bc7f models: Delete get_stream_recipient function and its uses.
With recipient being now a Stream field, there's no more use for
this helper function.
2020-02-18 10:49:14 -08:00
Ryan Rehman
3dc7d60ffe muting: Record DateTime when a Topic is muted.
This includes the necessary migration to add
the date_muted field to the MutedTopic class
and populates it with a hard coded value.
2020-02-02 20:49:53 -08:00
Anders Kaseorg
3127fb4dbd zerver/tests: Remove unused imports.
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2019-02-02 17:43:03 -08:00
Steve Howell
c35afb942f Accept stream_id for muting endpoints. 2018-12-27 20:26:30 -08:00
Yago González
8b141e6dbc muting: Correct agrammatical error message.
The error message displayed when unmuting a topic that wasn't previously
muted wasn't properly formulated.
2018-08-27 14:12:03 -07:00
Alena Volkova
26eb23afc7 tests: Replace api_auth usages with auth methods in zerver/tests. 2017-12-18 09:24:09 -05:00
rht
4f5b1c0a5a zerver/tests: Use python 3 syntax for typing in most files. 2017-11-16 21:52:01 -08:00
Steve Howell
a28841e8aa Extract get_stream_recipient().
Do you call get_recipient(Recipient.STREAM, stream_id) or
get_recipient(stream_id, Recipient.STREAM)?  I could never
remember, and it was not very type safe, since both parameters
are integers.
2017-10-28 17:57:39 -07:00
Steve Howell
78b1a8442b Add StreamTopicTarget.user_ids_muting_topic(). 2017-10-23 17:26:15 -07:00
Steve Howell
c567f105c9 Have topic_is_muted take a stream_id.
This function doesn't need a full Stream object to detect
whether a stream is muted, so we can save future callers
from doing unnecessary DB fetches.
2017-10-05 09:32:16 -07:00
rht
26f5d9a32c zerver/tests: Remove print_function. 2017-09-27 18:05:45 -07:00
rht
1e87a4b68c zerver/tests: Remove absolute_import. 2017-09-27 10:00:39 -07:00
Steve Howell
4ac6bc46c7 Add MutedTopic model.
This commit completely switches us over to using a
dedicated model called MutedTopic to track which topics
a user has muted.

This includes the necessary migrations to create the
table and populate it from legacy data in UserProfile.

A subsequent commit will actually remove the old field
in UserProfile.
2017-09-02 09:19:51 -07:00
Steve Howell
06ca364049 minor: Test round-trip behavior for mutes.
Instead of peeking directly at the DB to verify our mutes are
set correctly, we now use the library function.  This prepares
us to modify the DB internals while preserving the tests.
2017-08-30 09:14:41 -07:00
Steve Howell
0501570cd1 Remove POST-based API for setting topic mutes. 2017-08-29 16:53:38 -04:00
Rick Chern
e53d1c3885 tests: Remove get_user_profile_by_email from most tests. 2017-05-24 13:05:19 -07:00
Steve Howell
7f9057ba99 tests: Use example_user() in more places. 2017-05-08 11:57:38 -07:00
kunall17
5a1e952cb5 Implemented test's for muting/unmuting a topic 2017-03-15 16:19:00 -07:00
Amy Liu
e5ab3123af Migrate json/set_muted_topics to muting/topics. 2017-03-09 20:52:29 -08:00
Tim Abbott
ff598a091c tests: Extract zerver/tests/test_muting.py. 2017-03-08 03:57:37 -08:00