diff --git a/tests/storage/test_events.py b/tests/storage/test_events.py
deleted file mode 100644
index 14443b53bc..0000000000
--- a/tests/storage/test_events.py
+++ /dev/null
@@ -1,115 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright 2015, 2016 OpenMarket Ltd
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-from mock import Mock
-from synapse.types import RoomID, UserID
-
-from tests import unittest
-from twisted.internet import defer
-from tests.storage.event_injector import EventInjector
-
-from tests.utils import setup_test_homeserver
-
-
-class EventsStoreTestCase(unittest.TestCase):
-
- @defer.inlineCallbacks
- def setUp(self):
- self.hs = yield setup_test_homeserver(
- resource_for_federation=Mock(),
- http_client=None,
- )
- self.store = self.hs.get_datastore()
- self.db_pool = self.hs.get_db_pool()
- self.message_handler = self.hs.get_handlers().message_handler
- self.event_injector = EventInjector(self.hs)
-
- @defer.inlineCallbacks
- def test_count_daily_messages(self):
- yield self.db_pool.runQuery("DELETE FROM stats_reporting")
-
- self.hs.clock.now = 100
-
- # Never reported before, and nothing which could be reported
- count = yield self.store.count_daily_messages()
- self.assertIsNone(count)
- count = yield self.db_pool.runQuery("SELECT COUNT(*) FROM stats_reporting")
- self.assertEqual([(0,)], count)
-
- # Create something to report
- room = RoomID.from_string("!abc123:test")
- user = UserID.from_string("@raccoonlover:test")
- yield self.event_injector.create_room(room, user)
-
- self.base_event = yield self._get_last_stream_token()
-
- yield self.event_injector.inject_message(room, user, "Raccoons are really cute")
-
- # Never reported before, something could be reported, but isn't because
- # it isn't old enough.
- count = yield self.store.count_daily_messages()
- self.assertIsNone(count)
- yield self._assert_stats_reporting(1, self.hs.clock.now)
-
- # Already reported yesterday, two new events from today.
- yield self.event_injector.inject_message(room, user, "Yeah they are!")
- yield self.event_injector.inject_message(room, user, "Incredibly!")
- self.hs.clock.now += 60 * 60 * 24
- count = yield self.store.count_daily_messages()
- self.assertEqual(2, count) # 2 since yesterday
- yield self._assert_stats_reporting(3, self.hs.clock.now) # 3 ever
-
- # Last reported too recently.
- yield self.event_injector.inject_message(room, user, "Who could disagree?")
- self.hs.clock.now += 60 * 60 * 22
- count = yield self.store.count_daily_messages()
- self.assertIsNone(count)
- yield self._assert_stats_reporting(4, self.hs.clock.now)
-
- # Last reported too long ago
- yield self.event_injector.inject_message(room, user, "No one.")
- self.hs.clock.now += 60 * 60 * 26
- count = yield self.store.count_daily_messages()
- self.assertIsNone(count)
- yield self._assert_stats_reporting(5, self.hs.clock.now)
-
- # And now let's actually report something
- yield self.event_injector.inject_message(room, user, "Indeed.")
- yield self.event_injector.inject_message(room, user, "Indeed.")
- yield self.event_injector.inject_message(room, user, "Indeed.")
- # A little over 24 hours is fine :)
- self.hs.clock.now += (60 * 60 * 24) + 50
- count = yield self.store.count_daily_messages()
- self.assertEqual(3, count)
- yield self._assert_stats_reporting(8, self.hs.clock.now)
-
- @defer.inlineCallbacks
- def _get_last_stream_token(self):
- rows = yield self.db_pool.runQuery(
- "SELECT stream_ordering"
- " FROM events"
- " ORDER BY stream_ordering DESC"
- " LIMIT 1"
- )
- if not rows:
- defer.returnValue(0)
- else:
- defer.returnValue(rows[0][0])
-
- @defer.inlineCallbacks
- def _assert_stats_reporting(self, messages, time):
- rows = yield self.db_pool.runQuery(
- "SELECT reported_stream_token, reported_time FROM stats_reporting"
- )
- self.assertEqual([(self.base_event + messages, time,)], rows)
diff --git a/tests/test_state.py b/tests/test_state.py
index 6454f994e3..feb84f3d48 100644
--- a/tests/test_state.py
+++ b/tests/test_state.py
@@ -143,6 +143,7 @@ class StateTestCase(unittest.TestCase):
"add_event_hashes",
"get_events",
"get_next_state_group",
+ "get_state_group_delta",
]
)
hs = Mock(spec_set=[
@@ -154,6 +155,7 @@ class StateTestCase(unittest.TestCase):
hs.get_auth.return_value = Auth(hs)
self.store.get_next_state_group.side_effect = Mock
+ self.store.get_state_group_delta.return_value = (None, None)
self.state = StateHandler(hs)
self.event_id = 0
diff --git a/tests/util/test_dict_cache.py b/tests/util/test_dict_cache.py
index 272b71034a..bc92f85fa6 100644
--- a/tests/util/test_dict_cache.py
+++ b/tests/util/test_dict_cache.py
@@ -28,7 +28,7 @@ class DictCacheTestCase(unittest.TestCase):
key = "test_simple_cache_hit_full"
v = self.cache.get(key)
- self.assertEqual((False, {}), v)
+ self.assertEqual((False, set(), {}), v)
seq = self.cache.sequence
test_value = {"test": "test_simple_cache_hit_full"}
diff --git a/tests/utils.py b/tests/utils.py
index d3d6c8021d..4f7e32b3ab 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -55,6 +55,7 @@ def setup_test_homeserver(name="test", datastore=None, config=None, **kargs):
config.password_providers = []
config.worker_replication_url = ""
config.worker_app = None
+ config.email_enable_notifs = False
config.use_frozen_dicts = True
config.database_config = {"name": "sqlite3"}
|