summary refs log tree commit diff
path: root/tests/handlers
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2016-07-22 14:52:53 +0100
committerRichard van der Hoff <richard@matrix.org>2016-07-26 07:35:48 +0100
commit436bffd15fb8382a0d2dddd3c6f7a077ba751da2 (patch)
treed4c3857cb66386bf48f06293ae8ae28a558073ca /tests/handlers
parentLog when adding listeners (diff)
downloadsynapse-436bffd15fb8382a0d2dddd3c6f7a077ba751da2.tar.xz
Implement deleting devices
Diffstat (limited to 'tests/handlers')
-rw-r--r--tests/handlers/test_device.py22
1 files changed, 20 insertions, 2 deletions
diff --git a/tests/handlers/test_device.py b/tests/handlers/test_device.py
index 331aa13fed..214e722eb3 100644
--- a/tests/handlers/test_device.py
+++ b/tests/handlers/test_device.py
@@ -12,11 +12,14 @@
 # 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.
-from synapse import types
+
 from twisted.internet import defer
 
+import synapse.api.errors
 import synapse.handlers.device
+
 import synapse.storage
+from synapse import types
 from tests import unittest, utils
 
 user1 = "@boris:aaa"
@@ -27,7 +30,7 @@ class DeviceTestCase(unittest.TestCase):
     def __init__(self, *args, **kwargs):
         super(DeviceTestCase, self).__init__(*args, **kwargs)
         self.store = None    # type: synapse.storage.DataStore
-        self.handler = None  # type: device.DeviceHandler
+        self.handler = None  # type: synapse.handlers.device.DeviceHandler
         self.clock = None    # type: utils.MockClock
 
     @defer.inlineCallbacks
@@ -124,6 +127,21 @@ class DeviceTestCase(unittest.TestCase):
         }, res)
 
     @defer.inlineCallbacks
+    def test_delete_device(self):
+        yield self._record_users()
+
+        # delete the device
+        yield self.handler.delete_device(user1, "abc")
+
+        # check the device was deleted
+        with self.assertRaises(synapse.api.errors.NotFoundError):
+            yield self.handler.get_device(user1, "abc")
+
+        # we'd like to check the access token was invalidated, but that's a
+        # bit of a PITA.
+
+
+    @defer.inlineCallbacks
     def _record_users(self):
         # check this works for both devices which have a recorded client_ip,
         # and those which don't.