From ab7cd3c40ae1f17e4ee8ddc452976748266ecd78 Mon Sep 17 00:00:00 2001 From: Prakhar Pratyush Date: Mon, 3 Apr 2023 03:06:13 +0530 Subject: [PATCH] user_topics: Update test to verify end-to-end behaviour. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit updates 'test_user_ids_unmuting_topic' to make anĀ api_post call to '/api/v1/user_topics' instead of calling the internal function 'do_set_user_topic_visibility_policy' to verify the logic. --- zerver/tests/test_user_topics.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/zerver/tests/test_user_topics.py b/zerver/tests/test_user_topics.py index 2de7132fb4..78ddb5256f 100644 --- a/zerver/tests/test_user_topics.py +++ b/zerver/tests/test_user_topics.py @@ -470,14 +470,17 @@ class UnmutedTopicsTests(ZulipTestCase): ) self.assertEqual(user_ids, set()) + url = "/api/v1/user_topics" + def set_topic_visibility_for_user(user: UserProfile, visibility_policy: int) -> None: - do_set_user_topic_visibility_policy( - user, - stream, - "test TOPIC", - visibility_policy=visibility_policy, - last_updated=date_unmuted, - ) + data = { + "stream_id": stream.id, + "topic": "test TOPIC", + "visibility_policy": visibility_policy, + } + with time_machine.travel(datetime(2020, 1, 1, tzinfo=timezone.utc), tick=False): + result = self.api_post(user, url, data) + self.assert_json_success(result) set_topic_visibility_for_user(hamlet, UserTopic.VisibilityPolicy.UNMUTED) set_topic_visibility_for_user(cordelia, UserTopic.VisibilityPolicy.MUTED)