summary refs log tree commit diff
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <paul@matrix.org>2014-09-10 16:56:02 +0100
committerPaul "LeoNerd" Evans <paul@matrix.org>2014-09-10 16:56:02 +0100
commit08f5c48fc81753ac29d4f76080a44bcd5aa52ece (patch)
treef2faa955e6d60a9d8c2f3f8016e90da025888dd4
parentIt's considered polite to actually wait for DB prepare before running tests (diff)
downloadsynapse-08f5c48fc81753ac29d4f76080a44bcd5aa52ece.tar.xz
Move SQLiteMemoryDbPool implementation into tests.utils
-rw-r--r--tests/storage/test_profile.py28
-rw-r--r--tests/utils.py14
2 files changed, 15 insertions, 27 deletions
diff --git a/tests/storage/test_profile.py b/tests/storage/test_profile.py
index 45c69dafae..82e0c33be7 100644
--- a/tests/storage/test_profile.py
+++ b/tests/storage/test_profile.py
@@ -18,38 +18,12 @@ from twisted.trial import unittest
 from twisted.internet import defer
 
 from mock import Mock, call
-from twisted.enterprise.adbapi import ConnectionPool
 
 from synapse.server import HomeServer
 from synapse.storage import prepare_database
 from synapse.storage.profile import ProfileStore
 
-
-class SQLiteMemoryDbPool(ConnectionPool, object):
-    def __init__(self):
-        super(SQLiteMemoryDbPool, self).__init__(
-            "sqlite3", ":memory:",
-            cp_min=1,
-            cp_max=1,
-        )
-
-    def prepare(self):
-        return self.runWithConnection(prepare_database)
-
-    #def runInteraction(self, interaction, *args, **kwargs):
-    #    # Just use a cursor as the txn directly
-    #    txn = self.db.cursor()
-
-    #    def _on_success(result):
-    #        txn.commit()
-    #        return result
-    #    def _on_failure(failure):
-    #        txn.rollback()
-    #        raise failure
-
-    #    d = interaction(txn, *args, **kwargs)
-    #    d.addCallbacks(_on_success, _on_failure)
-    #    return d
+from tests.utils import SQLiteMemoryDbPool
 
 
 class ProfileStoreTestCase(unittest.TestCase):
diff --git a/tests/utils.py b/tests/utils.py
index d90214e418..bc5d35e56b 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -16,12 +16,14 @@
 from synapse.http.server import HttpServer
 from synapse.api.errors import cs_error, CodeMessageException, StoreError
 from synapse.api.constants import Membership
+from synapse.storage import prepare_database
 
 from synapse.api.events.room import (
     RoomMemberEvent, MessageEvent
 )
 
 from twisted.internet import defer, reactor
+from twisted.enterprise.adbapi import ConnectionPool
 
 from collections import namedtuple
 from mock import patch, Mock
@@ -120,6 +122,18 @@ class MockClock(object):
         self.now += secs
 
 
+class SQLiteMemoryDbPool(ConnectionPool, object):
+    def __init__(self):
+        super(SQLiteMemoryDbPool, self).__init__(
+            "sqlite3", ":memory:",
+            cp_min=1,
+            cp_max=1,
+        )
+
+    def prepare(self):
+        return self.runWithConnection(prepare_database)
+
+
 class MemoryDataStore(object):
 
     Room = namedtuple(