test_transactions.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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", 1000, 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(
  32. {"retry_last_ts": 50, "retry_interval": 100, "failure_ts": 1000}, r
  33. )
  34. def test_initial_set_transactions(self):
  35. """Tests that we can successfully set the destination retries (there
  36. was a bug around invalidating the cache that broke this)
  37. """
  38. d = self.store.set_destination_retry_timings("example.com", 1000, 50, 100)
  39. self.get_success(d)