Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
user_topics: Update tests to verify end-to-end behaviour.
Prakhar Pratyush5c86d3ca9e0a
diff --git a/zerver/tests/test_user_topics.py b/zerver/tests/test_user_topics.pyindex 259ae7c29ad..f191272033b 100644--- a/zerver/tests/test_user_topics.py+++ b/zerver/tests/test_user_topics.py@@ -23,13 +23,14 @@ class MutedTopicsTests(ZulipTestCase):mock_date_muted = datetime(2020, 1, 1, tzinfo=timezone.utc).timestamp()- do_set_user_topic_visibility_policy(- user,- stream,- "Verona3",- visibility_policy=UserTopic.VisibilityPolicy.MUTED,- last_updated=datetime(2020, 1, 1, tzinfo=timezone.utc),- )+ url = "/api/v1/users/me/subscriptions/muted_topics"+ data = {"stream_id": stream.id, "topic": "Verona3", "op": "add"}+ with mock.patch(+ "zerver.views.user_topics.timezone_now",+ return_value=datetime(2020, 1, 1, tzinfo=timezone.utc),+ ):+ result = self.api_patch(user, url, data)+ self.assert_json_success(result)stream.deactivated = Truestream.save()@@ -55,14 +56,16 @@ class MutedTopicsTests(ZulipTestCase):)self.assertEqual(user_ids, set())+ url = "/api/v1/users/me/subscriptions/muted_topics"+ data = {"stream_id": stream.id, "topic": "test TOPIC", "op": "add"}+def mute_topic_for_user(user: UserProfile) -> None:- do_set_user_topic_visibility_policy(- user,- stream,- "test TOPIC",- visibility_policy=UserTopic.VisibilityPolicy.MUTED,- last_updated=date_muted,- )+ with mock.patch(+ "zerver.views.user_topics.timezone_now",+ return_value=datetime(2020, 1, 1, tzinfo=timezone.utc),+ ):+ result = self.api_patch(user, url, data)+ self.assert_json_success(result)mute_topic_for_user(hamlet)user_ids = stream_topic_target.user_ids_with_visibility_policy(