diff --git a/tests/storage/test_background_update.py b/tests/storage/test_background_update.py
new file mode 100644
index 0000000000..29289fa9b4
--- /dev/null
+++ b/tests/storage/test_background_update.py
@@ -0,0 +1,76 @@
+from tests import unittest
+from twisted.internet import defer
+
+from synapse.api.constants import EventTypes
+from synapse.types import UserID, RoomID, RoomAlias
+
+from tests.utils import setup_test_homeserver
+
+from mock import Mock
+
+class BackgroundUpdateTestCase(unittest.TestCase):
+
+ @defer.inlineCallbacks
+ def setUp(self):
+ hs = yield setup_test_homeserver()
+ self.store = hs.get_datastore()
+ self.clock = hs.get_clock()
+
+ self.update_handler = Mock()
+
+ yield self.store.register_background_update_handler(
+ "test_update", self.update_handler
+ )
+
+ @defer.inlineCallbacks
+ def test_do_background_update(self):
+ desired_count = 1000;
+ duration_ms = 42;
+
+ @defer.inlineCallbacks
+ def update(progress, count):
+ self.clock.advance_time_msec(count * duration_ms)
+ progress = {"my_key": progress["my_key"] + 1}
+ yield self.store.runInteraction(
+ "update_progress",
+ self.store._background_update_progress_txn,
+ "test_update",
+ progress,
+ )
+ defer.returnValue(count)
+
+ self.update_handler.side_effect = update
+
+ yield self.store.start_background_update("test_update", {"my_key": 1})
+
+ self.update_handler.reset_mock()
+ result = yield self.store.do_background_update(
+ duration_ms * desired_count
+ )
+ self.assertIsNotNone(result)
+ self.update_handler.assert_called_once_with(
+ {"my_key": 1}, self.store.DEFAULT_BACKGROUND_BATCH_SIZE
+ )
+
+ @defer.inlineCallbacks
+ def update(progress, count):
+ yield self.store._end_background_update("test_update")
+ defer.returnValue(count)
+
+ self.update_handler.side_effect = update
+
+ self.update_handler.reset_mock()
+ result = yield self.store.do_background_update(
+ duration_ms * desired_count
+ )
+ self.assertIsNotNone(result)
+ self.update_handler.assert_called_once_with(
+ {"my_key": 2}, desired_count
+ )
+
+ self.update_handler.reset_mock()
+ result = yield self.store.do_background_update(
+ duration_ms * desired_count
+ )
+ self.assertIsNone(result)
+ self.assertFalse(self.update_handler.called)
diff --git a/tests/storage/test_redaction.py b/tests/storage/test_redaction.py
index b57006fcb4..dbf9700e6a 100644
--- a/tests/storage/test_redaction.py
+++ b/tests/storage/test_redaction.py
@@ -120,7 +120,6 @@ class RedactionTestCase(unittest.TestCase):
self.u_alice.to_string(),
start,
end,
- None, # Is currently ignored
)
self.assertEqual(1, len(results))
@@ -149,7 +148,6 @@ class RedactionTestCase(unittest.TestCase):
self.u_alice.to_string(),
start,
end,
- None, # Is currently ignored
)
self.assertEqual(1, len(results))
@@ -199,7 +197,6 @@ class RedactionTestCase(unittest.TestCase):
self.u_alice.to_string(),
start,
end,
- None, # Is currently ignored
)
self.assertEqual(1, len(results))
@@ -228,7 +225,6 @@ class RedactionTestCase(unittest.TestCase):
self.u_alice.to_string(),
start,
end,
- None, # Is currently ignored
)
self.assertEqual(1, len(results))
diff --git a/tests/storage/test_room.py b/tests/storage/test_room.py
index caffce64e3..91c967548d 100644
--- a/tests/storage/test_room.py
+++ b/tests/storage/test_room.py
@@ -73,6 +73,8 @@ class RoomStoreTestCase(unittest.TestCase):
"room_id": self.room.to_string(),
"topic": None,
"aliases": [self.alias.to_string()],
+ "world_readable": False,
+ "guest_can_join": False,
}, rooms[0])
diff --git a/tests/storage/test_stream.py b/tests/storage/test_stream.py
index a658a789aa..e5c2c5cc8e 100644
--- a/tests/storage/test_stream.py
+++ b/tests/storage/test_stream.py
@@ -68,7 +68,6 @@ class StreamStoreTestCase(unittest.TestCase):
self.u_bob.to_string(),
start,
end,
- None, # Is currently ignored
)
self.assertEqual(1, len(results))
@@ -105,7 +104,6 @@ class StreamStoreTestCase(unittest.TestCase):
self.u_alice.to_string(),
start,
end,
- None, # Is currently ignored
)
self.assertEqual(1, len(results))
@@ -147,7 +145,6 @@ class StreamStoreTestCase(unittest.TestCase):
self.u_bob.to_string(),
start,
end,
- None, # Is currently ignored
)
# We should not get the message, as it happened *after* bob left.
@@ -175,7 +172,6 @@ class StreamStoreTestCase(unittest.TestCase):
self.u_bob.to_string(),
start,
end,
- None, # Is currently ignored
)
# We should not get the message, as it happened *after* bob left.
|