2017-03-08 12:46:05 +01:00
|
|
|
from __future__ import absolute_import
|
|
|
|
from __future__ import print_function
|
|
|
|
|
|
|
|
import ujson
|
|
|
|
|
|
|
|
from django.http import HttpResponse
|
|
|
|
from mock import patch
|
|
|
|
from typing import Any, Dict
|
|
|
|
|
|
|
|
from zerver.lib.test_classes import ZulipTestCase
|
|
|
|
from zerver.models import get_user_profile_by_email
|
|
|
|
|
|
|
|
class MutedTopicsTests(ZulipTestCase):
|
|
|
|
def test_json_set(self):
|
|
|
|
# type: () -> None
|
|
|
|
email = 'hamlet@zulip.com'
|
|
|
|
self.login(email)
|
|
|
|
|
2017-01-10 01:23:53 +01:00
|
|
|
url = '/json/users/me/subscriptions/muted_topics'
|
2017-03-08 12:46:05 +01:00
|
|
|
data = {'muted_topics': '[["stream", "topic"]]'}
|
|
|
|
result = self.client_post(url, data)
|
|
|
|
self.assert_json_success(result)
|
|
|
|
|
|
|
|
user = get_user_profile_by_email(email)
|
|
|
|
self.assertEqual(ujson.loads(user.muted_topics), [["stream", "topic"]])
|
|
|
|
|
2017-01-10 01:23:53 +01:00
|
|
|
url = '/json/users/me/subscriptions/muted_topics'
|
2017-03-08 12:46:05 +01:00
|
|
|
data = {'muted_topics': '[["stream2", "topic2"]]'}
|
|
|
|
result = self.client_post(url, data)
|
|
|
|
self.assert_json_success(result)
|
|
|
|
|
|
|
|
user = get_user_profile_by_email(email)
|
|
|
|
self.assertEqual(ujson.loads(user.muted_topics), [["stream2", "topic2"]])
|