diff options
author | Erik Johnston <erik@matrix.org> | 2015-03-09 13:29:41 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2015-03-09 13:29:41 +0000 |
commit | f31e65ca8b3a056b81c9ee1c8e5be298e36ed495 (patch) | |
tree | 414d6a488f090cea0aff41ef8ca7346f47567a62 /tests/utils.py | |
parent | Merge branch 'develop' of github.com:matrix-org/synapse into erikj-perf (diff) | |
parent | D'oh: underscore, not hyphen (diff) | |
download | synapse-f31e65ca8b3a056b81c9ee1c8e5be298e36ed495.tar.xz |
Merge branch 'develop' of github.com:matrix-org/synapse into erikj-perf
Diffstat (limited to 'tests/utils.py')
-rw-r--r-- | tests/utils.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/utils.py b/tests/utils.py index 97fa8d8181..81e82a80df 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -17,6 +17,7 @@ from synapse.http.server import HttpServer from synapse.api.errors import cs_error, CodeMessageException, StoreError from synapse.api.constants import EventTypes from synapse.storage import prepare_database +from synapse.server import HomeServer from synapse.util.logcontext import LoggingContext @@ -31,6 +32,36 @@ import urlparse from inspect import getcallargs +@defer.inlineCallbacks +def setup_test_homeserver(name="test", datastore=None, config=None, **kargs): + """Setup a homeserver suitable for running tests against. Keyword arguments + are passed to the Homeserver constructor. If no datastore is supplied a + datastore backed by an in-memory sqlite db will be given to the HS. + """ + if config is None: + config = Mock() + config.signing_key = [MockKey()] + config.event_cache_size = 1 + config.disable_registration = False + + if datastore is None: + db_pool = SQLiteMemoryDbPool() + yield db_pool.prepare() + hs = HomeServer( + name, db_pool=db_pool, config=config, + version_string="Synapse/tests", + **kargs + ) + else: + hs = HomeServer( + name, db_pool=None, datastore=datastore, config=config, + version_string="Synapse/tests", + **kargs + ) + + defer.returnValue(hs) + + def get_mock_call_args(pattern_func, mock_func): """ Return the arguments the mock function was called with interpreted by the pattern functions argument list. |