Fixup tests
parent
75f87450d8
commit
852f80d8a6
|
@ -20,6 +20,7 @@ from synapse.replication.tcp.client import (
|
||||||
ReplicationClientHandler,
|
ReplicationClientHandler,
|
||||||
)
|
)
|
||||||
from synapse.replication.tcp.resource import ReplicationStreamProtocolFactory
|
from synapse.replication.tcp.resource import ReplicationStreamProtocolFactory
|
||||||
|
from synapse.storage.database import Database
|
||||||
|
|
||||||
from tests import unittest
|
from tests import unittest
|
||||||
from tests.server import FakeTransport
|
from tests.server import FakeTransport
|
||||||
|
@ -42,7 +43,9 @@ class BaseSlavedStoreTestCase(unittest.HomeserverTestCase):
|
||||||
|
|
||||||
self.master_store = self.hs.get_datastore()
|
self.master_store = self.hs.get_datastore()
|
||||||
self.storage = hs.get_storage()
|
self.storage = hs.get_storage()
|
||||||
self.slaved_store = self.STORE_TYPE(self.hs.get_db_conn(), self.hs)
|
self.slaved_store = self.STORE_TYPE(
|
||||||
|
Database(hs), self.hs.get_db_conn(), self.hs
|
||||||
|
)
|
||||||
self.event_id = 0
|
self.event_id = 0
|
||||||
|
|
||||||
server_factory = ReplicationStreamProtocolFactory(self.hs)
|
server_factory = ReplicationStreamProtocolFactory(self.hs)
|
||||||
|
|
|
@ -55,7 +55,8 @@ class ApplicationServiceStoreTestCase(unittest.TestCase):
|
||||||
self._add_appservice("token2", "as2", "some_url", "some_hs_token", "bob")
|
self._add_appservice("token2", "as2", "some_url", "some_hs_token", "bob")
|
||||||
self._add_appservice("token3", "as3", "some_url", "some_hs_token", "bob")
|
self._add_appservice("token3", "as3", "some_url", "some_hs_token", "bob")
|
||||||
# must be done after inserts
|
# must be done after inserts
|
||||||
self.store = ApplicationServiceStore(hs.get_db_conn(), hs)
|
database = Database(hs)
|
||||||
|
self.store = ApplicationServiceStore(database, hs.get_db_conn(), hs)
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
# TODO: suboptimal that we need to create files for tests!
|
# TODO: suboptimal that we need to create files for tests!
|
||||||
|
@ -124,7 +125,8 @@ class ApplicationServiceTransactionStoreTestCase(unittest.TestCase):
|
||||||
|
|
||||||
self.as_yaml_files = []
|
self.as_yaml_files = []
|
||||||
|
|
||||||
self.store = TestTransactionStore(hs.get_db_conn(), hs)
|
database = Database(hs)
|
||||||
|
self.store = TestTransactionStore(database, hs.get_db_conn(), hs)
|
||||||
|
|
||||||
def _add_service(self, url, as_token, id):
|
def _add_service(self, url, as_token, id):
|
||||||
as_yaml = dict(
|
as_yaml = dict(
|
||||||
|
@ -417,7 +419,7 @@ class ApplicationServiceStoreConfigTestCase(unittest.TestCase):
|
||||||
hs.config.event_cache_size = 1
|
hs.config.event_cache_size = 1
|
||||||
hs.config.password_providers = []
|
hs.config.password_providers = []
|
||||||
|
|
||||||
ApplicationServiceStore(hs.get_db_conn(), hs)
|
ApplicationServiceStore(Database(hs), hs.get_db_conn(), hs)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def test_duplicate_ids(self):
|
def test_duplicate_ids(self):
|
||||||
|
@ -433,7 +435,7 @@ class ApplicationServiceStoreConfigTestCase(unittest.TestCase):
|
||||||
hs.config.password_providers = []
|
hs.config.password_providers = []
|
||||||
|
|
||||||
with self.assertRaises(ConfigError) as cm:
|
with self.assertRaises(ConfigError) as cm:
|
||||||
ApplicationServiceStore(hs.get_db_conn(), hs)
|
ApplicationServiceStore(Database(hs), hs.get_db_conn(), hs)
|
||||||
|
|
||||||
e = cm.exception
|
e = cm.exception
|
||||||
self.assertIn(f1, str(e))
|
self.assertIn(f1, str(e))
|
||||||
|
@ -454,7 +456,7 @@ class ApplicationServiceStoreConfigTestCase(unittest.TestCase):
|
||||||
hs.config.password_providers = []
|
hs.config.password_providers = []
|
||||||
|
|
||||||
with self.assertRaises(ConfigError) as cm:
|
with self.assertRaises(ConfigError) as cm:
|
||||||
ApplicationServiceStore(hs.get_db_conn(), hs)
|
ApplicationServiceStore(Database(hs), hs.get_db_conn(), hs)
|
||||||
|
|
||||||
e = cm.exception
|
e = cm.exception
|
||||||
self.assertIn(f1, str(e))
|
self.assertIn(f1, str(e))
|
||||||
|
|
|
@ -21,6 +21,7 @@ from mock import Mock
|
||||||
from twisted.internet import defer
|
from twisted.internet import defer
|
||||||
|
|
||||||
from synapse.storage._base import SQLBaseStore
|
from synapse.storage._base import SQLBaseStore
|
||||||
|
from synapse.storage.database import Database
|
||||||
from synapse.storage.engines import create_engine
|
from synapse.storage.engines import create_engine
|
||||||
|
|
||||||
from tests import unittest
|
from tests import unittest
|
||||||
|
@ -59,7 +60,7 @@ class SQLBaseStoreTestCase(unittest.TestCase):
|
||||||
"test", db_pool=self.db_pool, config=config, database_engine=fake_engine
|
"test", db_pool=self.db_pool, config=config, database_engine=fake_engine
|
||||||
)
|
)
|
||||||
|
|
||||||
self.datastore = SQLBaseStore(None, hs)
|
self.datastore = SQLBaseStore(Database(hs), None, hs)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def test_insert_1col(self):
|
def test_insert_1col(self):
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
|
|
||||||
from twisted.internet import defer
|
from twisted.internet import defer
|
||||||
|
|
||||||
from synapse.storage.data_stores.main.profile import ProfileStore
|
|
||||||
from synapse.types import UserID
|
from synapse.types import UserID
|
||||||
|
|
||||||
from tests import unittest
|
from tests import unittest
|
||||||
|
@ -28,7 +27,7 @@ class ProfileStoreTestCase(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
hs = yield setup_test_homeserver(self.addCleanup)
|
hs = yield setup_test_homeserver(self.addCleanup)
|
||||||
|
|
||||||
self.store = ProfileStore(hs.get_db_conn(), hs)
|
self.store = hs.get_datastore()
|
||||||
|
|
||||||
self.u_frank = UserID.from_string("@frank:test")
|
self.u_frank = UserID.from_string("@frank:test")
|
||||||
|
|
||||||
|
|
|
@ -15,8 +15,6 @@
|
||||||
|
|
||||||
from twisted.internet import defer
|
from twisted.internet import defer
|
||||||
|
|
||||||
from synapse.storage.data_stores.main.user_directory import UserDirectoryStore
|
|
||||||
|
|
||||||
from tests import unittest
|
from tests import unittest
|
||||||
from tests.utils import setup_test_homeserver
|
from tests.utils import setup_test_homeserver
|
||||||
|
|
||||||
|
@ -29,7 +27,7 @@ class UserDirectoryStoreTestCase(unittest.TestCase):
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.hs = yield setup_test_homeserver(self.addCleanup)
|
self.hs = yield setup_test_homeserver(self.addCleanup)
|
||||||
self.store = UserDirectoryStore(self.hs.get_db_conn(), self.hs)
|
self.store = self.hs.get_datastore()
|
||||||
|
|
||||||
# alice and bob are both in !room_id. bobby is not but shares
|
# alice and bob are both in !room_id. bobby is not but shares
|
||||||
# a homeserver with alice.
|
# a homeserver with alice.
|
||||||
|
|
|
@ -33,6 +33,8 @@ class MessageAcceptTests(unittest.TestCase):
|
||||||
self.reactor.advance(0.1)
|
self.reactor.advance(0.1)
|
||||||
self.room_id = self.successResultOf(room)["room_id"]
|
self.room_id = self.successResultOf(room)["room_id"]
|
||||||
|
|
||||||
|
self.store = self.homeserver.get_datastore()
|
||||||
|
|
||||||
# Figure out what the most recent event is
|
# Figure out what the most recent event is
|
||||||
most_recent = self.successResultOf(
|
most_recent = self.successResultOf(
|
||||||
maybeDeferred(
|
maybeDeferred(
|
||||||
|
@ -77,10 +79,7 @@ class MessageAcceptTests(unittest.TestCase):
|
||||||
# Make sure we actually joined the room
|
# Make sure we actually joined the room
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
self.successResultOf(
|
self.successResultOf(
|
||||||
maybeDeferred(
|
maybeDeferred(self.store.get_latest_event_ids_in_room, self.room_id)
|
||||||
self.homeserver.get_datastore().get_latest_event_ids_in_room,
|
|
||||||
self.room_id,
|
|
||||||
)
|
|
||||||
)[0],
|
)[0],
|
||||||
"$join:test.serv",
|
"$join:test.serv",
|
||||||
)
|
)
|
||||||
|
@ -100,10 +99,7 @@ class MessageAcceptTests(unittest.TestCase):
|
||||||
|
|
||||||
# Figure out what the most recent event is
|
# Figure out what the most recent event is
|
||||||
most_recent = self.successResultOf(
|
most_recent = self.successResultOf(
|
||||||
maybeDeferred(
|
maybeDeferred(self.store.get_latest_event_ids_in_room, self.room_id)
|
||||||
self.homeserver.get_datastore().get_latest_event_ids_in_room,
|
|
||||||
self.room_id,
|
|
||||||
)
|
|
||||||
)[0]
|
)[0]
|
||||||
|
|
||||||
# Now lie about an event
|
# Now lie about an event
|
||||||
|
@ -141,7 +137,5 @@ class MessageAcceptTests(unittest.TestCase):
|
||||||
)
|
)
|
||||||
|
|
||||||
# Make sure the invalid event isn't there
|
# Make sure the invalid event isn't there
|
||||||
extrem = maybeDeferred(
|
extrem = maybeDeferred(self.store.get_latest_event_ids_in_room, self.room_id)
|
||||||
self.homeserver.get_datastore().get_latest_event_ids_in_room, self.room_id
|
|
||||||
)
|
|
||||||
self.assertEqual(self.successResultOf(extrem)[0], "$join:test.serv")
|
self.assertEqual(self.successResultOf(extrem)[0], "$join:test.serv")
|
||||||
|
|
Loading…
Reference in New Issue