[Checkins] SVN: relstorage/trunk/relstorage/ added tests of dropping the schema and creating it again

Shane Hathaway shane at hathawaymix.org
Sat Jan 24 21:36:34 EST 2009


Log message for revision 94996:
  added tests of dropping the schema and creating it again

Changed:
  U   relstorage/trunk/relstorage/adapters/mysql.py
  U   relstorage/trunk/relstorage/adapters/oracle.py
  U   relstorage/trunk/relstorage/adapters/postgresql.py
  U   relstorage/trunk/relstorage/tests/reltestbase.py

-=-
Modified: relstorage/trunk/relstorage/adapters/mysql.py
===================================================================
--- relstorage/trunk/relstorage/adapters/mysql.py	2009-01-25 01:37:07 UTC (rev 94995)
+++ relstorage/trunk/relstorage/adapters/mysql.py	2009-01-25 02:36:33 UTC (rev 94996)
@@ -276,6 +276,25 @@
             self.close(conn, cursor)
 
 
+    def drop_all(self):
+        """Drop all tables and sequences."""
+        conn, cursor = self.open()
+        try:
+            try:
+                for tablename in ('pack_state_tid', 'pack_state',
+                        'pack_object', 'object_refs_added', 'object_ref',
+                        'current_object', 'object_state', 'new_oid',
+                        'transaction'):
+                    cursor.execute("DROP TABLE IF EXISTS %s" % tablename)
+            except:
+                conn.rollback()
+                raise
+            else:
+                conn.commit()
+        finally:
+            self.close(conn, cursor)
+
+
     def open(self, transaction_mode="ISOLATION LEVEL READ COMMITTED"):
         """Open a database connection and return (conn, cursor)."""
         try:

Modified: relstorage/trunk/relstorage/adapters/oracle.py
===================================================================
--- relstorage/trunk/relstorage/adapters/oracle.py	2009-01-25 01:37:07 UTC (rev 94995)
+++ relstorage/trunk/relstorage/adapters/oracle.py	2009-01-25 02:36:33 UTC (rev 94996)
@@ -313,6 +313,27 @@
             self.close(conn, cursor)
 
 
+    def drop_all(self):
+        """Drop all tables and sequences."""
+        conn, cursor = self.open()
+        try:
+            try:
+                for tablename in ('pack_state_tid', 'pack_state',
+                        'pack_object', 'object_refs_added', 'object_ref',
+                        'current_object', 'object_state', 'transaction',
+                        'commit_lock', 'pack_lock',
+                        'temp_store', 'temp_undo', 'temp_pack_visit'):
+                    cursor.execute("DROP TABLE %s" % tablename)
+                cursor.execute("DROP SEQUENCE zoid_seq")
+            except:
+                conn.rollback()
+                raise
+            else:
+                conn.commit()
+        finally:
+            self.close(conn, cursor)
+
+
     def open(self, transaction_mode="ISOLATION LEVEL READ COMMITTED",
             twophase=False):
         """Open a database connection and return (conn, cursor)."""

Modified: relstorage/trunk/relstorage/adapters/postgresql.py
===================================================================
--- relstorage/trunk/relstorage/adapters/postgresql.py	2009-01-25 01:37:07 UTC (rev 94995)
+++ relstorage/trunk/relstorage/adapters/postgresql.py	2009-01-25 02:36:33 UTC (rev 94996)
@@ -186,6 +186,26 @@
             self.close(conn, cursor)
 
 
+    def drop_all(self):
+        """Drop all tables and sequences."""
+        conn, cursor = self.open()
+        try:
+            try:
+                for tablename in ('pack_state_tid', 'pack_state',
+                        'pack_object', 'object_refs_added', 'object_ref',
+                        'current_object', 'object_state', 'transaction',
+                        'commit_lock', 'pack_lock'):
+                    cursor.execute("DROP TABLE IF EXISTS %s" % tablename)
+                cursor.execute("DROP SEQUENCE zoid_seq")
+            except:
+                conn.rollback()
+                raise
+            else:
+                conn.commit()
+        finally:
+            self.close(conn, cursor)
+
+
     def open(self,
             isolation=psycopg2.extensions.ISOLATION_LEVEL_READ_COMMITTED):
         """Open a database connection and return (conn, cursor)."""

Modified: relstorage/trunk/relstorage/tests/reltestbase.py
===================================================================
--- relstorage/trunk/relstorage/tests/reltestbase.py	2009-01-25 01:37:07 UTC (rev 94995)
+++ relstorage/trunk/relstorage/tests/reltestbase.py	2009-01-25 02:36:33 UTC (rev 94996)
@@ -70,6 +70,10 @@
     ReadOnlyStorage.ReadOnlyStorage
     ):
 
+    def checkDropAndPrepare(self):
+        self._storage._adapter.drop_all()
+        self._storage._adapter.prepare_schema()
+
     def checkCrossConnectionInvalidation(self):
         # Verify connections see updated state at txn boundaries
         db = DB(self._storage)



More information about the Checkins mailing list