test_transactions.py 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # -*- coding: utf-8 -*-
  2. # Copyright 2018 New Vector Ltd
  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 tests.unittest import HomeserverTestCase
  16. class TransactionStoreTestCase(HomeserverTestCase):
  17. def prepare(self, reactor, clock, homeserver):
  18. self.store = homeserver.get_datastore()
  19. def test_get_set_transactions(self):
  20. """Tests that we can successfully get a non-existent entry for
  21. destination retries, as well as testing tht we can set and get
  22. correctly.
  23. """
  24. d = self.store.get_destination_retry_timings("example.com")
  25. r = self.get_success(d)
  26. self.assertIsNone(r)
  27. d = self.store.set_destination_retry_timings("example.com", 50, 100)
  28. self.get_success(d)
  29. d = self.store.get_destination_retry_timings("example.com")
  30. r = self.get_success(d)
  31. self.assert_dict({"retry_last_ts": 50, "retry_interval": 100}, r)
  32. def test_initial_set_transactions(self):
  33. """Tests that we can successfully set the destination retries (there
  34. was a bug around invalidating the cache that broke this)
  35. """
  36. d = self.store.set_destination_retry_timings("example.com", 50, 100)
  37. self.get_success(d)