test_account_data.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # Copyright 2016 OpenMarket Ltd
  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.replication.slave.storage.account_data import SlavedAccountDataStore
  16. from ._base import BaseSlavedStoreTestCase
  17. USER_ID = "@feeling:blue"
  18. TYPE = "my.type"
  19. class SlavedAccountDataStoreTestCase(BaseSlavedStoreTestCase):
  20. STORE_TYPE = SlavedAccountDataStore
  21. @defer.inlineCallbacks
  22. def test_user_account_data(self):
  23. yield self.master_store.add_account_data_for_user(
  24. USER_ID, TYPE, {"a": 1}
  25. )
  26. yield self.replicate()
  27. yield self.check(
  28. "get_global_account_data_by_type_for_user",
  29. [TYPE, USER_ID], {"a": 1}
  30. )
  31. yield self.master_store.add_account_data_for_user(
  32. USER_ID, TYPE, {"a": 2}
  33. )
  34. yield self.replicate()
  35. yield self.check(
  36. "get_global_account_data_by_type_for_user",
  37. [TYPE, USER_ID], {"a": 2}
  38. )