diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-02-13 14:17:11 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-02-13 14:17:11 -0500 |
| commit | 02ae6ab3fdf2c0c07910d06aa1d7d5048cdabd9d (patch) | |
| tree | da0f70bf0eecfd1f14968542377a268064509405 | |
| parent | aa3b59af54a7828b8b18f3dfb33a09f254616e20 (diff) | |
| download | sqlalchemy-02ae6ab3fdf2c0c07910d06aa1d7d5048cdabd9d.tar.gz | |
- add a test suite that ensures textual autocommit works
for correct expressions
Change-Id: I17d35169be914924828487abba05658dff380f2a
| -rw-r--r-- | test/engine/test_execute.py | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/test/engine/test_execute.py b/test/engine/test_execute.py index 145877dd3..32834f950 100644 --- a/test/engine/test_execute.py +++ b/test/engine/test_execute.py @@ -2635,3 +2635,59 @@ class DialectEventTest(fixtures.TestBase): conn.connection.invalidate() conn = e.connect() eq_(conn.info['boom'], "one") + + +class AutocommitTextTest(fixtures.TestBase): + __backend__ = True + + def _test_keyword(self, keyword, expected=True): + dbapi = Mock( + connect=Mock( + return_value=Mock( + cursor=Mock( + return_value=Mock( + description=() + ) + ) + ) + ) + ) + engine = engines.testing_engine( + options={ + "_initialize": False, + "pool_reset_on_return": None + }) + engine.dialect.dbapi = dbapi + engine.execute("%s something table something" % keyword) + if expected: + eq_( + dbapi.connect().mock_calls, + [call.cursor(), call.commit()] + ) + else: + eq_( + dbapi.connect().mock_calls, + [call.cursor()] + ) + + def test_update(self): + self._test_keyword("UPDATE") + + def test_insert(self): + self._test_keyword("INSERT") + + def test_delete(self): + self._test_keyword("DELETE") + + def test_alter(self): + self._test_keyword("ALTER TABLE") + + def test_create(self): + self._test_keyword("CREATE TABLE foobar") + + def test_drop(self): + self._test_keyword("DROP TABLE foobar") + + def test_select(self): + self._test_keyword("SELECT foo FROM table", False) + |
