Skip to content

Commit

Permalink
Fix up tests
Browse files Browse the repository at this point in the history
  • Loading branch information
richvdh committed Aug 28, 2018
1 parent 32eb1de commit 414fa36
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions tests/storage/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@

from twisted.internet import defer

from synapse.server import HomeServer
from synapse.storage._base import SQLBaseStore
from synapse.storage.engines import create_engine

from tests import unittest
from tests.utils import TestHomeServer


class SQLBaseStoreTestCase(unittest.TestCase):
Expand All @@ -51,7 +51,7 @@ def runWithConnection(func, *args, **kwargs):
config = Mock()
config.event_cache_size = 1
config.database_config = {"name": "sqlite3"}
hs = HomeServer(
hs = TestHomeServer(
"test",
db_pool=self.db_pool,
config=config,
Expand Down
4 changes: 2 additions & 2 deletions tests/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
# limitations under the License.

from synapse.api.errors import SynapseError
from synapse.server import HomeServer
from synapse.types import GroupID, RoomAlias, UserID

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):
Expand Down
8 changes: 6 additions & 2 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from synapse.federation.transport import server
from synapse.http.server import HttpServer
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.prepare_database import (
_get_or_create_schema_state,
Expand Down Expand Up @@ -92,10 +92,14 @@ def _cleanup():
atexit.register(_cleanup)


class TestHomeServer(HomeServer):
DATASTORE_CLASS = DataStore


@defer.inlineCallbacks
def setup_test_homeserver(
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
Expand Down

0 comments on commit 414fa36

Please sign in to comment.