summary refs log tree commit diff
path: root/tests/handlers/test_profile.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/handlers/test_profile.py')
-rw-r--r--tests/handlers/test_profile.py27
1 files changed, 22 insertions, 5 deletions
diff --git a/tests/handlers/test_profile.py b/tests/handlers/test_profile.py
index 8e7a89b479..ee2be9b6d5 100644
--- a/tests/handlers/test_profile.py
+++ b/tests/handlers/test_profile.py
@@ -14,18 +14,15 @@
 # limitations under the License.
 
 
-from twisted.trial import unittest
+from tests import unittest
 from twisted.internet import defer
 
 from mock import Mock
-import logging
 
 from synapse.api.errors import AuthError
 from synapse.server import HomeServer
 from synapse.handlers.profile import ProfileHandler
-
-
-logging.getLogger().addHandler(logging.NullHandler())
+from synapse.api.constants import Membership
 
 
 class ProfileHandlers(object):
@@ -54,6 +51,7 @@ class ProfileTestCase(unittest.TestCase):
                     "set_profile_displayname",
                     "get_profile_avatar_url",
                     "set_profile_avatar_url",
+                    "get_rooms_for_user_where_membership_is",
                 ]),
                 handlers=None,
                 resource_for_federation=Mock(),
@@ -69,6 +67,10 @@ class ProfileTestCase(unittest.TestCase):
 
         self.handler = hs.get_handlers().profile_handler
 
+        self.mock_get_joined = (
+            self.datastore.get_rooms_for_user_where_membership_is
+        )
+
         # TODO(paul): Icky signal declarings.. booo
         hs.get_distributor().declare("changed_presencelike_data")
 
@@ -87,8 +89,15 @@ class ProfileTestCase(unittest.TestCase):
         mocked_set = self.datastore.set_profile_displayname
         mocked_set.return_value = defer.succeed(())
 
+        self.mock_get_joined.return_value = defer.succeed([])
+
         yield self.handler.set_displayname(self.frank, self.frank, "Frank Jr.")
 
+        self.mock_get_joined.assert_called_once_with(
+            self.frank.to_string(),
+            [Membership.JOIN]
+        )
+
         mocked_set.assert_called_with("1234ABCD", "Frank Jr.")
 
     @defer.inlineCallbacks
@@ -139,7 +148,15 @@ class ProfileTestCase(unittest.TestCase):
         mocked_set = self.datastore.set_profile_avatar_url
         mocked_set.return_value = defer.succeed(())
 
+        self.mock_get_joined.return_value = defer.succeed([])
+
         yield self.handler.set_avatar_url(self.frank, self.frank,
                 "http://my.server/pic.gif")
 
+        self.mock_get_joined.assert_called_once_with(
+            self.frank.to_string(),
+            [Membership.JOIN]
+        )
+
+
         mocked_set.assert_called_with("1234ABCD", "http://my.server/pic.gif")