1
0

test_main.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # Copyright 2020 Awesome Technologies Innovationslabor GmbH
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. from twisted.internet import defer
  15. from synapse.types import UserID
  16. from tests import unittest
  17. from tests.utils import setup_test_homeserver
  18. class DataStoreTestCase(unittest.TestCase):
  19. @defer.inlineCallbacks
  20. def setUp(self):
  21. hs = yield setup_test_homeserver(self.addCleanup)
  22. self.store = hs.get_datastore()
  23. self.user = UserID.from_string("@abcde:test")
  24. self.displayname = "Frank"
  25. @defer.inlineCallbacks
  26. def test_get_users_paginate(self):
  27. yield defer.ensureDeferred(
  28. self.store.register_user(self.user.to_string(), "pass")
  29. )
  30. yield defer.ensureDeferred(self.store.create_profile(self.user.localpart))
  31. yield defer.ensureDeferred(
  32. self.store.set_profile_displayname(self.user.localpart, self.displayname)
  33. )
  34. users, total = yield defer.ensureDeferred(
  35. self.store.get_users_paginate(0, 10, name="bc", guests=False)
  36. )
  37. self.assertEquals(1, total)
  38. self.assertEquals(self.displayname, users.pop()["displayname"])
  39. users, total = yield defer.ensureDeferred(
  40. self.store.get_users_paginate(0, 10, name="BC", guests=False)
  41. )
  42. self.assertEquals(1, total)
  43. self.assertEquals(self.displayname, users.pop()["displayname"])