test_main.py 1.7 KB

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