Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Fix case in wait_for_background_updates where self.store does not exist #11331

Merged
merged 4 commits into from
Dec 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/11331.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
A test helper (`wait_for_background_updates`) no longer depends on classes defining a `store` property.
11 changes: 4 additions & 7 deletions tests/unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,16 +331,13 @@ def wait_on_thread(self, deferred, timeout=10):
time.sleep(0.01)

def wait_for_background_updates(self) -> None:
"""Block until all background database updates have completed.

Note that callers must ensure there's a store property created on the
testcase.
"""
"""Block until all background database updates have completed."""
store = self.hs.get_datastore()
while not self.get_success(
self.store.db_pool.updates.has_completed_background_updates()
store.db_pool.updates.has_completed_background_updates()
):
self.get_success(
self.store.db_pool.updates.do_next_background_update(False), by=0.1
store.db_pool.updates.do_next_background_update(False), by=0.1
)

def make_homeserver(self, reactor, clock):
Expand Down