diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-09-02 15:10:32 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-09-16 16:20:18 -0400 |
| commit | 01a0a2d542909456a28fba8e6f16c0e0346e1278 (patch) | |
| tree | 6539a2ded845c16edc002c8c952e6be57f72b5b0 /test | |
| parent | 65d8deac95b63ea5702a9ce6b5d9a6c9a6a60991 (diff) | |
| download | sqlalchemy-01a0a2d542909456a28fba8e6f16c0e0346e1278.tar.gz | |
Additions to support HAAlchemy plugin
- add a connect=True key to connection record to support
pre-loading of _ConnectionRecord objects
- ensure _ConnectionRecord.close() leaves the record in a good
state for reopening
- add _ConnectionRecord.record_info for persistent storage
- add "in_use" accessor based on fairy_ref being present or not
- allow for the exclusions system and SuiteRequirements to be
usable without the full plugin_base setup.
- move some Python-env requirements to the importable
requirements.py module.
- allow starttime to be queried
- add additional events for engine plugins
- have "dialect" be a first-class parameter to the pool,
ensure the engine strategy supplies it up front
Change-Id: Ibf549f7a1766e49d335cd6f5e26bacfaef9a8229
Diffstat (limited to 'test')
| -rw-r--r-- | test/engine/test_parseconnect.py | 3 | ||||
| -rw-r--r-- | test/engine/test_pool.py | 75 | ||||
| -rw-r--r-- | test/requirements.py | 39 |
3 files changed, 78 insertions, 39 deletions
diff --git a/test/engine/test_parseconnect.py b/test/engine/test_parseconnect.py index 0e1f6c3d2..894fff280 100644 --- a/test/engine/test_parseconnect.py +++ b/test/engine/test_parseconnect.py @@ -6,6 +6,7 @@ import sqlalchemy as tsa from sqlalchemy.testing import fixtures from sqlalchemy import testing from sqlalchemy.testing.mock import Mock, MagicMock, call +from sqlalchemy.testing import mock from sqlalchemy.dialects import registry from sqlalchemy.dialects import plugins @@ -403,6 +404,8 @@ class TestRegNewDBAPI(fixtures.TestBase): MyEnginePlugin.mock_calls, [ call(e.url, {}), + call.handle_dialect_kwargs(sqlite.dialect, mock.ANY), + call.handle_pool_kwargs(mock.ANY, {"dialect": e.dialect}), call.engine_created(e) ] ) diff --git a/test/engine/test_pool.py b/test/engine/test_pool.py index 057289199..5b87c90b8 100644 --- a/test/engine/test_pool.py +++ b/test/engine/test_pool.py @@ -232,6 +232,81 @@ class PoolTest(PoolTestBase): assert not c2.info assert 'foo2' in c.info + def test_rec_info(self): + p = self._queuepool_fixture(pool_size=1, max_overflow=0) + + c = p.connect() + self.assert_(not c.record_info) + self.assert_(c.record_info is c._connection_record.record_info) + + c.record_info['foo'] = 'bar' + c.close() + del c + + c = p.connect() + self.assert_('foo' in c.record_info) + + c.invalidate() + c = p.connect() + self.assert_('foo' in c.record_info) + + c.record_info['foo2'] = 'bar2' + c.detach() + is_(c.record_info, None) + is_(c._connection_record, None) + + c2 = p.connect() + + assert c2.record_info + assert 'foo2' in c2.record_info + + def test_rec_unconnected(self): + # test production of a _ConnectionRecord with an + # initally unconnected state. + + dbapi = MockDBAPI() + p1 = pool.Pool( + creator=lambda: dbapi.connect('foo.db') + ) + + r1 = pool._ConnectionRecord(p1, connect=False) + + assert not r1.connection + c1 = r1.get_connection() + is_(c1, r1.connection) + + def test_rec_close_reopen(self): + # test that _ConnectionRecord.close() allows + # the record to be reusable + dbapi = MockDBAPI() + p1 = pool.Pool( + creator=lambda: dbapi.connect('foo.db') + ) + + r1 = pool._ConnectionRecord(p1) + + c1 = r1.connection + c2 = r1.get_connection() + is_(c1, c2) + + r1.close() + + assert not r1.connection + eq_( + c1.mock_calls, + [call.close()] + ) + + c2 = r1.get_connection() + + is_not_(c1, c2) + is_(c2, r1.connection) + + eq_( + c2.mock_calls, + [] + ) + class PoolDialectTest(PoolTestBase): def _dialect(self): diff --git a/test/requirements.py b/test/requirements.py index 87e3bb726..3a2fcf03b 100644 --- a/test/requirements.py +++ b/test/requirements.py @@ -748,45 +748,6 @@ class DefaultRequirements(SuiteRequirements): return fails_on("postgresql+pg8000") @property - def python2(self): - return skip_if( - lambda: sys.version_info >= (3,), - "Python version 2.xx is required." - ) - - @property - def python3(self): - return skip_if( - lambda: sys.version_info < (3,), - "Python version 3.xx is required." - ) - - @property - def cpython(self): - return only_if(lambda: util.cpython, - "cPython interpreter needed" - ) - - - @property - def non_broken_pickle(self): - from sqlalchemy.util import pickle - return only_if( - lambda: not util.pypy and pickle.__name__ == 'cPickle' - or sys.version_info >= (3, 2), - "Needs cPickle+cPython or newer Python 3 pickle" - ) - - - @property - def predictable_gc(self): - """target platform must remove all cycles unconditionally when - gc.collect() is called, as well as clean out unreferenced subclasses. - - """ - return self.cpython - - @property def hstore(self): def check_hstore(config): if not against(config, "postgresql"): |
