summary refs log tree commit diff
path: root/tests/storage
diff options
context:
space:
mode:
authorMark Haines <mjark@negativecurvature.net>2015-02-11 11:46:08 +0000
committerMark Haines <mjark@negativecurvature.net>2015-02-11 11:46:08 +0000
commitf42e29cf956c00be618fa4601441d62848c1270c (patch)
treedf5ce8afb4c2972408c758e0ace795046ba170a6 /tests/storage
parentFix bug where variable was not always defined (diff)
parentFactor out some of the common homeserver setup code into a (diff)
downloadsynapse-f42e29cf956c00be618fa4601441d62848c1270c.tar.xz
Merge pull request #63 from matrix-org/homeserver_test_setup
Factor out some of the common homeserver setup code
Diffstat (limited to 'tests/storage')
-rw-r--r--tests/storage/test_base.py1
-rw-r--r--tests/storage/test_directory.py11
-rw-r--r--tests/storage/test_presence.py11
-rw-r--r--tests/storage/test_profile.py10
-rw-r--r--tests/storage/test_redaction.py14
-rw-r--r--tests/storage/test_registration.py10
-rw-r--r--tests/storage/test_room.py17
-rw-r--r--tests/storage/test_roommember.py14
-rw-r--r--tests/storage/test_stream.py14
9 files changed, 18 insertions, 84 deletions
diff --git a/tests/storage/test_base.py b/tests/storage/test_base.py
index a6f1d6a333..a0a24ce096 100644
--- a/tests/storage/test_base.py
+++ b/tests/storage/test_base.py
@@ -22,6 +22,7 @@ from mock import Mock, call
 from collections import OrderedDict
 
 from synapse.server import HomeServer
+
 from synapse.storage._base import SQLBaseStore
 
 
diff --git a/tests/storage/test_directory.py b/tests/storage/test_directory.py
index bc9ebf35e2..b9bfbc00e2 100644
--- a/tests/storage/test_directory.py
+++ b/tests/storage/test_directory.py
@@ -17,24 +17,17 @@
 from tests import unittest
 from twisted.internet import defer
 
-from synapse.server import HomeServer
 from synapse.storage.directory import DirectoryStore
 from synapse.types import RoomID, RoomAlias
 
-from tests.utils import SQLiteMemoryDbPool
+from tests.utils import setup_test_homeserver
 
 
 class DirectoryStoreTestCase(unittest.TestCase):
 
     @defer.inlineCallbacks
     def setUp(self):
-        db_pool = SQLiteMemoryDbPool()
-        yield db_pool.prepare()
-
-        hs = HomeServer(
-            "test",
-            db_pool=db_pool,
-        )
+        hs = yield setup_test_homeserver()
 
         self.store = DirectoryStore(hs)
 
diff --git a/tests/storage/test_presence.py b/tests/storage/test_presence.py
index 1ab193736b..065eebdbcf 100644
--- a/tests/storage/test_presence.py
+++ b/tests/storage/test_presence.py
@@ -17,24 +17,17 @@
 from tests import unittest
 from twisted.internet import defer
 
-from synapse.server import HomeServer
 from synapse.storage.presence import PresenceStore
 from synapse.types import UserID
 
-from tests.utils import SQLiteMemoryDbPool, MockClock
+from tests.utils import setup_test_homeserver, MockClock
 
 
 class PresenceStoreTestCase(unittest.TestCase):
 
     @defer.inlineCallbacks
     def setUp(self):
-        db_pool = SQLiteMemoryDbPool()
-        yield db_pool.prepare()
-
-        hs = HomeServer("test",
-            clock=MockClock(),
-            db_pool=db_pool,
-        )
+        hs = yield setup_test_homeserver(clock=MockClock())
 
         self.store = PresenceStore(hs)
 
diff --git a/tests/storage/test_profile.py b/tests/storage/test_profile.py
index 84381241bc..1fa783f313 100644
--- a/tests/storage/test_profile.py
+++ b/tests/storage/test_profile.py
@@ -17,23 +17,17 @@
 from tests import unittest
 from twisted.internet import defer
 
-from synapse.server import HomeServer
 from synapse.storage.profile import ProfileStore
 from synapse.types import UserID
 
-from tests.utils import SQLiteMemoryDbPool
+from tests.utils import setup_test_homeserver
 
 
 class ProfileStoreTestCase(unittest.TestCase):
 
     @defer.inlineCallbacks
     def setUp(self):
-        db_pool = SQLiteMemoryDbPool()
-        yield db_pool.prepare()
-
-        hs = HomeServer("test",
-            db_pool=db_pool,
-        )
+        hs = yield setup_test_homeserver()
 
         self.store = ProfileStore(hs)
 
diff --git a/tests/storage/test_redaction.py b/tests/storage/test_redaction.py
index 0713dfab64..b57006fcb4 100644
--- a/tests/storage/test_redaction.py
+++ b/tests/storage/test_redaction.py
@@ -17,11 +17,10 @@
 from tests import unittest
 from twisted.internet import defer
 
-from synapse.server import HomeServer
 from synapse.api.constants import EventTypes, Membership
 from synapse.types import UserID, RoomID
 
-from tests.utils import SQLiteMemoryDbPool, MockKey
+from tests.utils import setup_test_homeserver
 
 from mock import Mock
 
@@ -30,16 +29,7 @@ class RedactionTestCase(unittest.TestCase):
 
     @defer.inlineCallbacks
     def setUp(self):
-        db_pool = SQLiteMemoryDbPool()
-        yield db_pool.prepare()
-
-        self.mock_config = Mock()
-        self.mock_config.signing_key = [MockKey()]
-
-        hs = HomeServer(
-            "test",
-            db_pool=db_pool,
-            config=self.mock_config,
+        hs = yield setup_test_homeserver(
             resource_for_federation=Mock(),
             http_client=None,
         )
diff --git a/tests/storage/test_registration.py b/tests/storage/test_registration.py
index 6f8bea2f61..e0b81f2b57 100644
--- a/tests/storage/test_registration.py
+++ b/tests/storage/test_registration.py
@@ -17,22 +17,16 @@
 from tests import unittest
 from twisted.internet import defer
 
-from synapse.server import HomeServer
 from synapse.storage.registration import RegistrationStore
 
-from tests.utils import SQLiteMemoryDbPool
+from tests.utils import setup_test_homeserver
 
 
 class RegistrationStoreTestCase(unittest.TestCase):
 
     @defer.inlineCallbacks
     def setUp(self):
-        db_pool = SQLiteMemoryDbPool()
-        yield db_pool.prepare()
-
-        hs = HomeServer("test",
-            db_pool=db_pool,
-        )
+        hs = yield setup_test_homeserver()
 
         self.store = RegistrationStore(hs)
 
diff --git a/tests/storage/test_room.py b/tests/storage/test_room.py
index 71e5d34143..c88dd446fb 100644
--- a/tests/storage/test_room.py
+++ b/tests/storage/test_room.py
@@ -17,23 +17,17 @@
 from tests import unittest
 from twisted.internet import defer
 
-from synapse.server import HomeServer
 from synapse.api.constants import EventTypes
 from synapse.types import UserID, RoomID, RoomAlias
 
-from tests.utils import SQLiteMemoryDbPool
+from tests.utils import setup_test_homeserver
 
 
 class RoomStoreTestCase(unittest.TestCase):
 
     @defer.inlineCallbacks
     def setUp(self):
-        db_pool = SQLiteMemoryDbPool()
-        yield db_pool.prepare()
-
-        hs = HomeServer("test",
-            db_pool=db_pool,
-        )
+        hs = yield setup_test_homeserver()
 
         # We can't test RoomStore on its own without the DirectoryStore, for
         # management of the 'room_aliases' table
@@ -86,12 +80,7 @@ class RoomEventsStoreTestCase(unittest.TestCase):
 
     @defer.inlineCallbacks
     def setUp(self):
-        db_pool = SQLiteMemoryDbPool()
-        yield db_pool.prepare()
-
-        hs = HomeServer("test",
-            db_pool=db_pool,
-        )
+        hs = setup_test_homeserver()
 
         # Room events need the full datastore, for persist_event() and
         # get_room_state()
diff --git a/tests/storage/test_roommember.py b/tests/storage/test_roommember.py
index 2b9048e2a9..811fea544b 100644
--- a/tests/storage/test_roommember.py
+++ b/tests/storage/test_roommember.py
@@ -17,11 +17,10 @@
 from tests import unittest
 from twisted.internet import defer
 
-from synapse.server import HomeServer
 from synapse.api.constants import EventTypes, Membership
 from synapse.types import UserID, RoomID
 
-from tests.utils import SQLiteMemoryDbPool, MockKey
+from tests.utils import setup_test_homeserver
 
 from mock import Mock
 
@@ -30,16 +29,7 @@ class RoomMemberStoreTestCase(unittest.TestCase):
 
     @defer.inlineCallbacks
     def setUp(self):
-        db_pool = SQLiteMemoryDbPool()
-        yield db_pool.prepare()
-
-        self.mock_config = Mock()
-        self.mock_config.signing_key = [MockKey()]
-
-        hs = HomeServer(
-            "test",
-            db_pool=db_pool,
-            config=self.mock_config,
+        hs = yield setup_test_homeserver(
             resource_for_federation=Mock(),
             http_client=None,
         )
diff --git a/tests/storage/test_stream.py b/tests/storage/test_stream.py
index b7f6e2aa80..0c9b89d765 100644
--- a/tests/storage/test_stream.py
+++ b/tests/storage/test_stream.py
@@ -17,11 +17,10 @@
 from tests import unittest
 from twisted.internet import defer
 
-from synapse.server import HomeServer
 from synapse.api.constants import EventTypes, Membership
 from synapse.types import UserID, RoomID
 
-from tests.utils import SQLiteMemoryDbPool, MockKey
+from tests.utils import setup_test_homeserver
 
 from mock import Mock
 
@@ -30,16 +29,7 @@ class StreamStoreTestCase(unittest.TestCase):
 
     @defer.inlineCallbacks
     def setUp(self):
-        db_pool = SQLiteMemoryDbPool()
-        yield db_pool.prepare()
-
-        self.mock_config = Mock()
-        self.mock_config.signing_key = [MockKey()]
-
-        hs = HomeServer(
-            "test",
-            db_pool=db_pool,
-            config=self.mock_config,
+        hs = yield setup_test_homeserver(
             resource_for_federation=Mock(),
             http_client=None,
         )