summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/testing/suite
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2012-09-27 02:37:33 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2012-09-27 02:37:33 -0400
commit20cdc64588b0f6ae52f8380c11d0ed848005377b (patch)
tree08f6cc8f82263f1e402c1c05c83b66a1f4b016ac /lib/sqlalchemy/testing/suite
parent21cac5b598a83ef0e24423dc523629b475aa3af0 (diff)
downloadsqlalchemy-20cdc64588b0f6ae52f8380c11d0ed848005377b.tar.gz
trying different approaches to test layout. in this one, the testing modules
become an externally usable package but still remains within the main sqlalchemy parent package. in this system, we use kind of an ugly hack to get the noseplugin imported outside of the "sqlalchemy" package, while still making it available within sqlalchemy for usage by third party libraries.
Diffstat (limited to 'lib/sqlalchemy/testing/suite')
-rw-r--r--lib/sqlalchemy/testing/suite/__init__.py0
-rw-r--r--lib/sqlalchemy/testing/suite/requirements.py24
-rw-r--r--lib/sqlalchemy/testing/suite/test_ddl.py48
-rw-r--r--lib/sqlalchemy/testing/suite/test_reflection.py0
-rw-r--r--lib/sqlalchemy/testing/suite/test_sequencing.py36
5 files changed, 108 insertions, 0 deletions
diff --git a/lib/sqlalchemy/testing/suite/__init__.py b/lib/sqlalchemy/testing/suite/__init__.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/lib/sqlalchemy/testing/suite/__init__.py
diff --git a/lib/sqlalchemy/testing/suite/requirements.py b/lib/sqlalchemy/testing/suite/requirements.py
new file mode 100644
index 000000000..5eda39b2b
--- /dev/null
+++ b/lib/sqlalchemy/testing/suite/requirements.py
@@ -0,0 +1,24 @@
+from ..requirements import Requirements
+from .. import exclusions
+
+
+class SuiteRequirements(Requirements):
+
+ @property
+ def create_table(self):
+ """target platform can emit basic CreateTable DDL."""
+
+ return exclusions.open
+
+ @property
+ def drop_table(self):
+ """target platform can emit basic DropTable DDL."""
+
+ return exclusions.open
+
+ @property
+ def autoincrement_insert(self):
+ """target platform generates new surrogate integer primary key values
+ when insert() is executed, excluding the pk column."""
+
+ return exclusions.open
diff --git a/lib/sqlalchemy/testing/suite/test_ddl.py b/lib/sqlalchemy/testing/suite/test_ddl.py
new file mode 100644
index 000000000..1285c4196
--- /dev/null
+++ b/lib/sqlalchemy/testing/suite/test_ddl.py
@@ -0,0 +1,48 @@
+from .. import fixtures, config, util
+from ..config import requirements
+from ..assertions import eq_
+
+from sqlalchemy import Table, Column, Integer, String
+
+
+class TableDDLTest(fixtures.TestBase):
+
+ def _simple_fixture(self):
+ return Table('test_table', self.metadata,
+ Column('id', Integer, primary_key=True),
+ Column('data', String(50))
+ )
+
+ def _simple_roundtrip(self):
+ with config.db.begin() as conn:
+ conn.execute("insert into test_table(id, data) values "
+ "(1, 'some data')")
+ result = conn.execute("select id, data from test_table")
+ eq_(
+ result.first(),
+ (1, 'some data')
+ )
+
+
+ @requirements.create_table
+ @util.provide_metadata
+ def test_create_table(self):
+ table = self._simple_fixture()
+ table.create(
+ config.db, checkfirst=False
+ )
+ self._simple_roundtrip()
+
+
+ @requirements.drop_table
+ @util.provide_metadata
+ def test_drop_table(self):
+ table = self._simple_fixture()
+ table.create(
+ config.db, checkfirst=False
+ )
+ table.drop(
+ config.db, checkfirst=False
+ )
+
+__all__ = ('TableDDLTest',) \ No newline at end of file
diff --git a/lib/sqlalchemy/testing/suite/test_reflection.py b/lib/sqlalchemy/testing/suite/test_reflection.py
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/lib/sqlalchemy/testing/suite/test_reflection.py
diff --git a/lib/sqlalchemy/testing/suite/test_sequencing.py b/lib/sqlalchemy/testing/suite/test_sequencing.py
new file mode 100644
index 000000000..7b09ecb76
--- /dev/null
+++ b/lib/sqlalchemy/testing/suite/test_sequencing.py
@@ -0,0 +1,36 @@
+from .. import fixtures, config, util
+from ..config import requirements
+from ..assertions import eq_
+
+from sqlalchemy import Table, Column, Integer, String
+
+
+class InsertSequencingTest(fixtures.TablesTest):
+ run_deletes = 'each'
+
+ @classmethod
+ def define_tables(cls, metadata):
+ Table('plain_pk', metadata,
+ Column('id', Integer, primary_key=True),
+ Column('data', String(50))
+ )
+
+ def _assert_round_trip(self, table):
+ row = config.db.execute(table.select()).first()
+ eq_(
+ row,
+ (1, "some data")
+ )
+
+ @requirements.autoincrement_insert
+ def test_autoincrement_on_insert(self):
+
+ config.db.execute(
+ self.tables.plain_pk.insert(),
+ data="some data"
+ )
+ self._assert_round_trip(self.tables.plain_pk)
+
+
+
+__all__ = ('InsertSequencingTest',) \ No newline at end of file