summary refs log tree commit diff
path: root/synapse/streams
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <paul@matrix.org>2014-08-27 18:28:53 +0100
committerPaul "LeoNerd" Evans <paul@matrix.org>2014-08-27 18:30:09 +0100
commit407c86c013c2d99eba872e94273d8e0f5726de4b (patch)
tree70af9e1b4ab5958095fa59a5e5280d3664d00c87 /synapse/streams
parentSplit out MessageHandler (diff)
downloadsynapse-407c86c013c2d99eba872e94273d8e0f5726de4b.tar.xz
Define a NullSource useful for unit-testing
Diffstat (limited to 'synapse/streams')
-rw-r--r--synapse/streams/events.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/synapse/streams/events.py b/synapse/streams/events.py
index 2e6ea6ca26..eaa397c650 100644
--- a/synapse/streams/events.py
+++ b/synapse/streams/events.py
@@ -19,6 +19,22 @@ from synapse.api.constants import Membership
 from synapse.types import StreamToken
 
 
+class NullSource(object):
+    """This event source never yields any events and its token remains at
+    zero. It may be useful for unit-testing."""
+    def __init__(self, hs):
+        pass
+
+    def get_new_events_for_user(self, user, from_token, limit):
+        return defer.succeed(([], from_token))
+
+    def get_current_token_part(self):
+        return defer.succeed(0)
+
+    def get_pagination_rows(self, user, pagination_config, key):
+        return defer.succeed(([], from_token))
+
+
 class RoomEventSource(object):
     def __init__(self, hs):
         self.store = hs.get_datastore()