From cee5befbd4ed6dab17a59e242d5d6d8e033b9f84 Mon Sep 17 00:00:00 2001 From: Will Hunt Date: Thu, 11 Jul 2019 14:39:32 +0100 Subject: [PATCH] Add test for m.presence cap --- .../rest/client/v2_alpha/test_capabilities.py | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/rest/client/v2_alpha/test_capabilities.py b/tests/rest/client/v2_alpha/test_capabilities.py index b9e01c9418..ba6e289ee2 100644 --- a/tests/rest/client/v2_alpha/test_capabilities.py +++ b/tests/rest/client/v2_alpha/test_capabilities.py @@ -79,3 +79,37 @@ class CapabilitiesTestCase(unittest.HomeserverTestCase): self.assertEqual(channel.code, 200) self.assertFalse(capabilities["m.change_password"]["enabled"]) + + def test_get_presence(self): + self.register_user("user", "pass") + access_token = self.login("user", "pass") + + self.hs.get_config().use_presence = True + request, channel = self.make_request("GET", self.url, access_token=access_token) + self.render(request) + capabilities = channel.json_body["capabilities"] + self.assertEqual(channel.code, 200) + + self.assertEqual( + True, + capabilities["m.presence"]["send_enabled"], + ) + self.assertEqual( + True, + capabilities["m.presence"]["receive_enabled"], + ) + + self.hs.get_config().use_presence = False + request, channel = self.make_request("GET", self.url, access_token=access_token) + self.render(request) + capabilities = channel.json_body["capabilities"] + self.assertEqual(channel.code, 200) + + self.assertEqual( + False, + capabilities["m.presence"]["send_enabled"], + ) + self.assertEqual( + False, + capabilities["m.presence"]["receive_enabled"], + ) \ No newline at end of file