summary refs log tree commit diff
path: root/tests/storage
diff options
context:
space:
mode:
authorDirk Klimpel <5740567+dklimpel@users.noreply.github.com>2020-12-11 11:42:47 +0100
committerGitHub <noreply@github.com>2020-12-11 10:42:47 +0000
commit0a34cdfc6682c2654c745c4d7c2f5ffd1865dbc8 (patch)
treed88b4fe4410945941be114faea26b71818e8ff33 /tests/storage
parentDon't ratelimit autojoining of rooms (#8921) (diff)
downloadsynapse-0a34cdfc6682c2654c745c4d7c2f5ffd1865dbc8.tar.xz
Add number of local devices to Room Details Admin API (#8886)
Diffstat (limited to 'tests/storage')
-rw-r--r--tests/storage/test_devices.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/storage/test_devices.py b/tests/storage/test_devices.py
index ecb00f4e02..dabc1c5f09 100644
--- a/tests/storage/test_devices.py
+++ b/tests/storage/test_devices.py
@@ -80,6 +80,32 @@ class DeviceStoreTestCase(tests.unittest.TestCase):
         )
 
     @defer.inlineCallbacks
+    def test_count_devices_by_users(self):
+        yield defer.ensureDeferred(
+            self.store.store_device("user_id", "device1", "display_name 1")
+        )
+        yield defer.ensureDeferred(
+            self.store.store_device("user_id", "device2", "display_name 2")
+        )
+        yield defer.ensureDeferred(
+            self.store.store_device("user_id2", "device3", "display_name 3")
+        )
+
+        res = yield defer.ensureDeferred(self.store.count_devices_by_users())
+        self.assertEqual(0, res)
+
+        res = yield defer.ensureDeferred(self.store.count_devices_by_users(["unknown"]))
+        self.assertEqual(0, res)
+
+        res = yield defer.ensureDeferred(self.store.count_devices_by_users(["user_id"]))
+        self.assertEqual(2, res)
+
+        res = yield defer.ensureDeferred(
+            self.store.count_devices_by_users(["user_id", "user_id2"])
+        )
+        self.assertEqual(3, res)
+
+    @defer.inlineCallbacks
     def test_get_device_updates_by_remote(self):
         device_ids = ["device_id1", "device_id2"]