Fix up tests

pull/3764/head
Richard van der Hoff 2018-08-28 17:21:05 +01:00
parent 32eb1dedd2
commit 414fa36f3e
3 changed files with 10 additions and 6 deletions

View File

@ -20,11 +20,11 @@ from mock import Mock
from twisted.internet import defer from twisted.internet import defer
from synapse.server import HomeServer
from synapse.storage._base import SQLBaseStore from synapse.storage._base import SQLBaseStore
from synapse.storage.engines import create_engine from synapse.storage.engines import create_engine
from tests import unittest from tests import unittest
from tests.utils import TestHomeServer
class SQLBaseStoreTestCase(unittest.TestCase): class SQLBaseStoreTestCase(unittest.TestCase):
@ -51,7 +51,7 @@ class SQLBaseStoreTestCase(unittest.TestCase):
config = Mock() config = Mock()
config.event_cache_size = 1 config.event_cache_size = 1
config.database_config = {"name": "sqlite3"} config.database_config = {"name": "sqlite3"}
hs = HomeServer( hs = TestHomeServer(
"test", "test",
db_pool=self.db_pool, db_pool=self.db_pool,
config=config, config=config,

View File

@ -14,12 +14,12 @@
# limitations under the License. # limitations under the License.
from synapse.api.errors import SynapseError from synapse.api.errors import SynapseError
from synapse.server import HomeServer
from synapse.types import GroupID, RoomAlias, UserID from synapse.types import GroupID, RoomAlias, UserID
from tests import unittest from tests import unittest
from tests.utils import TestHomeServer
mock_homeserver = HomeServer(hostname="my.domain") mock_homeserver = TestHomeServer(hostname="my.domain")
class UserIDTestCase(unittest.TestCase): class UserIDTestCase(unittest.TestCase):

View File

@ -29,7 +29,7 @@ from synapse.api.errors import CodeMessageException, cs_error
from synapse.federation.transport import server from synapse.federation.transport import server
from synapse.http.server import HttpServer from synapse.http.server import HttpServer
from synapse.server import HomeServer from synapse.server import HomeServer
from synapse.storage import PostgresEngine from synapse.storage import DataStore, PostgresEngine
from synapse.storage.engines import create_engine from synapse.storage.engines import create_engine
from synapse.storage.prepare_database import ( from synapse.storage.prepare_database import (
_get_or_create_schema_state, _get_or_create_schema_state,
@ -92,10 +92,14 @@ def setupdb():
atexit.register(_cleanup) atexit.register(_cleanup)
class TestHomeServer(HomeServer):
DATASTORE_CLASS = DataStore
@defer.inlineCallbacks @defer.inlineCallbacks
def setup_test_homeserver( def setup_test_homeserver(
cleanup_func, name="test", datastore=None, config=None, reactor=None, cleanup_func, name="test", datastore=None, config=None, reactor=None,
homeserverToUse=HomeServer, **kargs homeserverToUse=TestHomeServer, **kargs
): ):
""" """
Setup a homeserver suitable for running tests against. Keyword arguments Setup a homeserver suitable for running tests against. Keyword arguments