forked from MirrorHub/synapse
Clean up tests.storage.test_main
to remove use of legacy code. (#11493)
This commit is contained in:
parent
8a4c296987
commit
16d39a5490
2 changed files with 11 additions and 17 deletions
1
changelog.d/11493.misc
Normal file
1
changelog.d/11493.misc
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Clean up `tests.storage.test_main` to remove use of legacy code.
|
|
@ -13,42 +13,35 @@
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
|
||||||
from twisted.internet import defer
|
|
||||||
|
|
||||||
from synapse.types import UserID
|
from synapse.types import UserID
|
||||||
|
|
||||||
from tests import unittest
|
from tests import unittest
|
||||||
from tests.utils import setup_test_homeserver
|
|
||||||
|
|
||||||
|
|
||||||
class DataStoreTestCase(unittest.TestCase):
|
class DataStoreTestCase(unittest.HomeserverTestCase):
|
||||||
@defer.inlineCallbacks
|
def setUp(self) -> None:
|
||||||
def setUp(self):
|
super(DataStoreTestCase, self).setUp()
|
||||||
hs = yield setup_test_homeserver(self.addCleanup)
|
|
||||||
|
|
||||||
self.store = hs.get_datastore()
|
self.store = self.hs.get_datastore()
|
||||||
|
|
||||||
self.user = UserID.from_string("@abcde:test")
|
self.user = UserID.from_string("@abcde:test")
|
||||||
self.displayname = "Frank"
|
self.displayname = "Frank"
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
def test_get_users_paginate(self) -> None:
|
||||||
def test_get_users_paginate(self):
|
self.get_success(self.store.register_user(self.user.to_string(), "pass"))
|
||||||
yield defer.ensureDeferred(
|
self.get_success(self.store.create_profile(self.user.localpart))
|
||||||
self.store.register_user(self.user.to_string(), "pass")
|
self.get_success(
|
||||||
)
|
|
||||||
yield defer.ensureDeferred(self.store.create_profile(self.user.localpart))
|
|
||||||
yield defer.ensureDeferred(
|
|
||||||
self.store.set_profile_displayname(self.user.localpart, self.displayname)
|
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.store.get_users_paginate(0, 10, name="bc", guests=False)
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assertEquals(1, total)
|
self.assertEquals(1, total)
|
||||||
self.assertEquals(self.displayname, users.pop()["displayname"])
|
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)
|
self.store.get_users_paginate(0, 10, name="BC", guests=False)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue