diff options
author | Richard van der Hoff <richard@matrix.org> | 2016-07-25 17:51:24 +0100 |
---|---|---|
committer | Richard van der Hoff <richard@matrix.org> | 2016-07-26 07:35:48 +0100 |
commit | 012b4c19132d57fdbc1b6b0e304eb60eaf19200f (patch) | |
tree | 93570c6bc031416b50061e3bc1f83fb519dca007 /tests/storage | |
parent | Implement deleting devices (diff) | |
download | synapse-012b4c19132d57fdbc1b6b0e304eb60eaf19200f.tar.xz |
Implement updating devices
You can update the displayname of devices now.
Diffstat (limited to 'tests/storage')
-rw-r--r-- | tests/storage/test_devices.py | 36 |
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) |