diff options
author | Matthew Hodgson <matthew.hodgson@openmarket.com> | 2014-08-13 16:14:30 +0100 |
---|---|---|
committer | Matthew Hodgson <matthew.hodgson@openmarket.com> | 2014-08-13 16:14:30 +0100 |
commit | 2ec5f6c2f2bccca6fe3004fd7d4c2632428a4ba5 (patch) | |
tree | 93449489f2a1244b4f807f79fed5e23446d60e56 /tests/rest/test_presence.py | |
parent | timestamps (diff) | |
parent | Don't pass host_web_client flag to register_servlets, it needs to be a Resour... (diff) | |
download | synapse-2ec5f6c2f2bccca6fe3004fd7d4c2632428a4ba5.tar.xz |
Merge branch 'master' of git+ssh://github.com/matrix-org/synapse
Diffstat (limited to 'tests/rest/test_presence.py')
-rw-r--r-- | tests/rest/test_presence.py | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/tests/rest/test_presence.py b/tests/rest/test_presence.py index 3a2e86e5c4..7c54e067c9 100644 --- a/tests/rest/test_presence.py +++ b/tests/rest/test_presence.py @@ -1,4 +1,18 @@ # -*- coding: utf-8 -*- +# Copyright 2014 matrix.org +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + """Tests REST events for /presence paths.""" from twisted.trial import unittest @@ -17,7 +31,7 @@ logging.getLogger().addHandler(logging.NullHandler()) OFFLINE = PresenceState.OFFLINE -BUSY = PresenceState.BUSY +UNAVAILABLE = PresenceState.UNAVAILABLE ONLINE = PresenceState.ONLINE @@ -55,7 +69,7 @@ class PresenceStateTestCase(unittest.TestCase): def test_get_my_status(self): mocked_get = self.mock_handler.get_state mocked_get.return_value = defer.succeed( - {"state": 2, "status_msg": "Available"}) + {"state": ONLINE, "status_msg": "Available"}) (code, response) = yield self.mock_server.trigger("GET", "/presence/%s/status" % (myid), None) @@ -73,12 +87,12 @@ class PresenceStateTestCase(unittest.TestCase): (code, response) = yield self.mock_server.trigger("PUT", "/presence/%s/status" % (myid), - '{"state": 1, "status_msg": "Away"}') + '{"state": "unavailable", "status_msg": "Away"}') self.assertEquals(200, code) mocked_set.assert_called_with(target_user=self.u_apple, auth_user=self.u_apple, - state={"state": 1, "status_msg": "Away"}) + state={"state": UNAVAILABLE, "status_msg": "Away"}) class PresenceListTestCase(unittest.TestCase): @@ -220,7 +234,7 @@ class PresenceEventStreamTestCase(unittest.TestCase): # I'll already get my own presence state change self.assertEquals({"start": "0", "end": "1", "chunk": [ {"type": "m.presence", - "content": {"user_id": "@apple:test", "state": 2}}, + "content": {"user_id": "@apple:test", "state": ONLINE}}, ]}, response) self.mock_datastore.set_presence_state.return_value = defer.succeed( @@ -237,5 +251,5 @@ class PresenceEventStreamTestCase(unittest.TestCase): self.assertEquals(200, code) self.assertEquals({"start": "1", "end": "2", "chunk": [ {"type": "m.presence", - "content": {"user_id": "@banana:test", "state": 2}}, + "content": {"user_id": "@banana:test", "state": ONLINE}}, ]}, response) |