1
0

test_main.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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 synapse.types import UserID
  15. from tests import unittest
  16. class DataStoreTestCase(unittest.HomeserverTestCase):
  17. def setUp(self) -> None:
  18. super().setUp()
  19. self.store = self.hs.get_datastores().main
  20. self.user = UserID.from_string("@abcde:test")
  21. self.displayname = "Frank"
  22. def test_get_users_paginate(self) -> None:
  23. self.get_success(self.store.register_user(self.user.to_string(), "pass"))
  24. self.get_success(self.store.create_profile(self.user))
  25. self.get_success(
  26. self.store.set_profile_displayname(self.user, self.displayname)
  27. )
  28. users, total = self.get_success(
  29. self.store.get_users_paginate(0, 10, name="bc", guests=False)
  30. )
  31. self.assertEqual(1, total)
  32. self.assertEqual(self.displayname, users.pop().displayname)
  33. users, total = self.get_success(
  34. self.store.get_users_paginate(0, 10, name="BC", guests=False)
  35. )
  36. self.assertEqual(1, total)
  37. self.assertEqual(self.displayname, users.pop().displayname)