From 2121c1690a17090a4027874751e90d02b4126fd2 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 6 Feb 2013 15:49:32 -0500 Subject: - add an "empty_inserts" requirement target plus a suite test - add suite tests for basic explicit Sequence support, result-row column access (tests that name_normalize is set correctly among many other things) --- lib/sqlalchemy/testing/suite/test_sequence.py | 54 +++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 lib/sqlalchemy/testing/suite/test_sequence.py (limited to 'lib/sqlalchemy/testing/suite/test_sequence.py') diff --git a/lib/sqlalchemy/testing/suite/test_sequence.py b/lib/sqlalchemy/testing/suite/test_sequence.py new file mode 100644 index 000000000..0b60aa5b7 --- /dev/null +++ b/lib/sqlalchemy/testing/suite/test_sequence.py @@ -0,0 +1,54 @@ +from .. import fixtures, config +from ..config import requirements +from ..assertions import eq_ + +from sqlalchemy import Integer, String, Sequence + +from ..schema import Table, Column + +class SequenceTest(fixtures.TablesTest): + __requires__ = ('sequences',) + + run_create_tables = 'each' + + @classmethod + def define_tables(cls, metadata): + Table('seq_pk', metadata, + Column('id', Integer, Sequence('tab_id_seq'), primary_key=True), + Column('data', String(50)) + ) + + def test_insert_roundtrip(self): + config.db.execute( + self.tables.seq_pk.insert(), + data="some data" + ) + self._assert_round_trip(self.tables.seq_pk, config.db) + + def test_insert_lastrowid(self): + r = config.db.execute( + self.tables.seq_pk.insert(), + data="some data" + ) + eq_( + r.inserted_primary_key, + [1] + ) + + def test_nextval_direct(self): + r = config.db.execute( + self.tables.seq_pk.c.id.default + ) + eq_( + r, 1 + ) + + + + def _assert_round_trip(self, table, conn): + row = conn.execute(table.select()).first() + eq_( + row, + (1, "some data") + ) + -- cgit v1.2.1