summary refs log tree commit diff
path: root/tests/storage
diff options
context:
space:
mode:
authorDavid Baker <dbkr@users.noreply.github.com>2016-07-26 10:49:55 +0100
committerGitHub <noreply@github.com>2016-07-26 10:49:55 +0100
commitd34e9f93b7f39fce5a98a45af3e95d3fe08b4798 (patch)
treefa88fe4599b38eac5a9f634fe9ee25da3692e333 /tests/storage
parentfederation doesn't work over ipv6 yet thanks to twisted (diff)
parentImplement updating devices (diff)
downloadsynapse-d34e9f93b7f39fce5a98a45af3e95d3fe08b4798.tar.xz
Merge pull request #949 from matrix-org/rav/update_devices
Implement updates and deletes for devices
Diffstat (limited to 'tests/storage')
-rw-r--r--tests/storage/test_devices.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/storage/test_devices.py b/tests/storage/test_devices.py
index a6ce993375..f8725acea0 100644
--- a/tests/storage/test_devices.py
+++ b/tests/storage/test_devices.py
@@ -15,6 +15,7 @@
 
 from twisted.internet import defer
 
+import synapse.api.errors
 import tests.unittest
 import tests.utils
 
@@ -67,3 +68,38 @@ class DeviceStoreTestCase(tests.unittest.TestCase):
             "device_id": "device2",
             "display_name": "display_name 2",
         }, res["device2"])
+
+    @defer.inlineCallbacks
+    def test_update_device(self):
+        yield self.store.store_device(
+            "user_id", "device_id", "display_name 1"
+        )
+
+        res = yield self.store.get_device("user_id", "device_id")
+        self.assertEqual("display_name 1", res["display_name"])
+
+        # do a no-op first
+        yield self.store.update_device(
+            "user_id", "device_id",
+        )
+        res = yield self.store.get_device("user_id", "device_id")
+        self.assertEqual("display_name 1", res["display_name"])
+
+        # do the update
+        yield self.store.update_device(
+            "user_id", "device_id",
+            new_display_name="display_name 2",
+        )
+
+        # check it worked
+        res = yield self.store.get_device("user_id", "device_id")
+        self.assertEqual("display_name 2", res["display_name"])
+
+    @defer.inlineCallbacks
+    def test_update_unknown_device(self):
+        with self.assertRaises(synapse.api.errors.StoreError) as cm:
+            yield self.store.update_device(
+                "user_id", "unknown_device_id",
+                new_display_name="display_name 2",
+            )
+        self.assertEqual(404, cm.exception.code)