Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Clean up tests.storage.test_main to remove use of legacy code. (#11493
Browse files Browse the repository at this point in the history
)
  • Loading branch information
reivilibre authored Dec 2, 2021
1 parent 8a4c296 commit 16d39a5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
1 change: 1 addition & 0 deletions changelog.d/11493.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Clean up `tests.storage.test_main` to remove use of legacy code.
27 changes: 10 additions & 17 deletions tests/storage/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,42 +13,35 @@
# limitations under the License.


from twisted.internet import defer

from synapse.types import UserID

from tests import unittest
from tests.utils import setup_test_homeserver


class DataStoreTestCase(unittest.TestCase):
@defer.inlineCallbacks
def setUp(self):
hs = yield setup_test_homeserver(self.addCleanup)
class DataStoreTestCase(unittest.HomeserverTestCase):
def setUp(self) -> None:
super(DataStoreTestCase, self).setUp()

self.store = hs.get_datastore()
self.store = self.hs.get_datastore()

self.user = UserID.from_string("@abcde:test")
self.displayname = "Frank"

@defer.inlineCallbacks
def test_get_users_paginate(self):
yield defer.ensureDeferred(
self.store.register_user(self.user.to_string(), "pass")
)
yield defer.ensureDeferred(self.store.create_profile(self.user.localpart))
yield defer.ensureDeferred(
def test_get_users_paginate(self) -> None:
self.get_success(self.store.register_user(self.user.to_string(), "pass"))
self.get_success(self.store.create_profile(self.user.localpart))
self.get_success(
self.store.set_profile_displayname(self.user.localpart, self.displayname)
)

users, total = yield defer.ensureDeferred(
users, total = self.get_success(
self.store.get_users_paginate(0, 10, name="bc", guests=False)
)

self.assertEquals(1, total)
self.assertEquals(self.displayname, users.pop()["displayname"])

users, total = yield defer.ensureDeferred(
users, total = self.get_success(
self.store.get_users_paginate(0, 10, name="BC", guests=False)
)

Expand Down

0 comments on commit 16d39a5

Please sign in to comment.