diff options
| author | mike bayer <mike_mp@zzzcomputing.com> | 2020-03-23 18:55:02 +0000 |
|---|---|---|
| committer | Gerrit Code Review <gerrit@bbpush.zzzcomputing.com> | 2020-03-23 18:55:02 +0000 |
| commit | e6b6ec78e6d6f96537eaf542f469a7e88134e9fc (patch) | |
| tree | 9f5958d2cf2e03a80af7e862746c6d016560bd65 /test | |
| parent | 01299b6bdaf91691923a99fd8c0241dac6abc432 (diff) | |
| parent | 0a4f7f38ce2b878a4e59da74373938b64bbb6e92 (diff) | |
| download | sqlalchemy-e6b6ec78e6d6f96537eaf542f469a7e88134e9fc.tar.gz | |
Merge "Remove deprecated elements from selectable.py; remove lockmode"
Diffstat (limited to 'test')
| -rw-r--r-- | test/orm/test_deprecations.py | 58 | ||||
| -rw-r--r-- | test/orm/test_session.py | 4 | ||||
| -rw-r--r-- | test/orm/test_versioning.py | 69 | ||||
| -rw-r--r-- | test/sql/test_deprecations.py | 19 |
4 files changed, 4 insertions, 146 deletions
diff --git a/test/orm/test_deprecations.py b/test/orm/test_deprecations.py index 91b15d14a..4efff1f76 100644 --- a/test/orm/test_deprecations.py +++ b/test/orm/test_deprecations.py @@ -1,7 +1,6 @@ import sqlalchemy as sa from sqlalchemy import and_ from sqlalchemy import event -from sqlalchemy import exc from sqlalchemy import func from sqlalchemy import Integer from sqlalchemy import select @@ -463,7 +462,7 @@ class DeprecatedQueryTest(_fixtures.FixtureTest, AssertsCompiledSQL): # same here, this was "passing string names to Query.columns" # deprecation message, that's gone here? assert_raises_message( - exc.ArgumentError, + sa.exc.ArgumentError, "Textual column expression 'name' should be explicitly", s.query, User.id, @@ -1508,61 +1507,6 @@ class DeprecatedOptionAllTest(OptionsPathTest, _fixtures.FixtureTest): sess.query(User).options(undefer("addresses", "email_address")) -class LegacyLockModeTest(_fixtures.FixtureTest): - run_inserts = None - - @classmethod - def setup_mappers(cls): - User, users = cls.classes.User, cls.tables.users - mapper(User, users) - - def _assert_legacy(self, arg, read=False, nowait=False): - User = self.classes.User - s = Session() - - with testing.expect_deprecated( - r"The Query.with_lockmode\(\) method is deprecated" - ): - q = s.query(User).with_lockmode(arg) - sel = q._compile_context().statement - - if arg is None: - assert q._for_update_arg is None - assert sel._for_update_arg is None - return - - assert q._for_update_arg.read is read - assert q._for_update_arg.nowait is nowait - - assert sel._for_update_arg.read is read - assert sel._for_update_arg.nowait is nowait - - def test_false_legacy(self): - self._assert_legacy(None) - - def test_plain_legacy(self): - self._assert_legacy("update") - - def test_nowait_legacy(self): - self._assert_legacy("update_nowait", nowait=True) - - def test_read_legacy(self): - self._assert_legacy("read", read=True) - - def test_unknown_legacy_lock_mode(self): - User = self.classes.User - sess = Session() - with testing.expect_deprecated( - r"The Query.with_lockmode\(\) method is deprecated" - ): - assert_raises_message( - exc.ArgumentError, - "Unknown with_lockmode argument: 'unknown_mode'", - sess.query(User.id).with_lockmode, - "unknown_mode", - ) - - class InstrumentationTest(fixtures.ORMTest): def test_dict_subclass4(self): # tests #2654 diff --git a/test/orm/test_session.py b/test/orm/test_session.py index 864264af9..8dab797ed 100644 --- a/test/orm/test_session.py +++ b/test/orm/test_session.py @@ -1984,14 +1984,14 @@ class SessionInterface(fixtures.TestBase): s.refresh(m1, with_for_update=False) s.refresh(m1) - from sqlalchemy.orm.query import LockmodeArg + from sqlalchemy.orm.query import ForUpdateArg eq_( [ call[-1]["with_for_update"] for call in load_on_ident.mock_calls ], - [LockmodeArg(read=True), LockmodeArg(), None, None], + [ForUpdateArg(read=True), ForUpdateArg(), None, None], ) diff --git a/test/orm/test_versioning.py b/test/orm/test_versioning.py index ef53e613c..c6418745d 100644 --- a/test/orm/test_versioning.py +++ b/test/orm/test_versioning.py @@ -398,45 +398,6 @@ class VersioningTest(fixtures.MappedTest): s1.close() s1.query(Foo).with_for_update(read=True).get(f1s1.id) - @engines.close_open_connections - def test_versioncheck_legacy(self): - """query.with_lockmode performs a 'version check' on an already loaded - instance""" - - Foo = self.classes.Foo - - s1 = self._fixture() - f1s1 = Foo(value="f1 value") - s1.add(f1s1) - s1.commit() - - s2 = create_session(autocommit=False) - f1s2 = s2.query(Foo).get(f1s1.id) - f1s2.value = "f1 new value" - with conditional_sane_rowcount_warnings( - update=True, only_returning=True - ): - s2.commit() - - # load, version is wrong - assert_raises_message( - sa.orm.exc.StaleDataError, - r"Instance .* has version id '\d+' which does not " - r"match database-loaded version id '\d+'", - s1.query(Foo).with_for_update(read=True).get, - f1s1.id, - ) - - # reload it - this expires the old version first - s1.refresh(f1s1, with_for_update=dict(read=True)) - - # now assert version OK - s1.query(Foo).with_for_update(read=True).get(f1s1.id) - - # assert brand new load is OK too - s1.close() - s1.query(Foo).with_for_update(read=True).get(f1s1.id) - def test_versioncheck_not_versioned(self): """ensure the versioncheck logic skips if there isn't a version_id_col actually configured""" @@ -471,7 +432,7 @@ class VersioningTest(fixtures.MappedTest): f1s2.value = "f1 new value" assert_raises( - exc.DBAPIError, s1.refresh, f1s1, lockmode="update_nowait" + exc.DBAPIError, s1.refresh, f1s1, with_for_update={"nowait": True} ) s1.rollback() @@ -480,34 +441,6 @@ class VersioningTest(fixtures.MappedTest): s1.refresh(f1s1, with_for_update={"nowait": True}) assert f1s1.version_id == f1s2.version_id - @engines.close_open_connections - @testing.requires.update_nowait - def test_versioncheck_for_update_legacy(self): - """query.with_lockmode performs a 'version check' on an already loaded - instance""" - - Foo = self.classes.Foo - - s1 = self._fixture() - f1s1 = Foo(value="f1 value") - s1.add(f1s1) - s1.commit() - - s2 = create_session(autocommit=False) - f1s2 = s2.query(Foo).get(f1s1.id) - s2.refresh(f1s2, lockmode="update") - f1s2.value = "f1 new value" - - assert_raises( - exc.DBAPIError, s1.refresh, f1s1, lockmode="update_nowait" - ) - s1.rollback() - - with conditional_sane_rowcount_warnings(update=True): - s2.commit() - s1.refresh(f1s1, lockmode="update_nowait") - assert f1s1.version_id == f1s2.version_id - def test_update_multi_missing_broken_multi_rowcount(self): @util.memoized_property def rowcount(self): diff --git a/test/sql/test_deprecations.py b/test/sql/test_deprecations.py index 93b29847f..d641c18e2 100644 --- a/test/sql/test_deprecations.py +++ b/test/sql/test_deprecations.py @@ -29,7 +29,6 @@ from sqlalchemy.engine import default from sqlalchemy.sql import coercions from sqlalchemy.sql import quoted_name from sqlalchemy.sql import roles -from sqlalchemy.sql import util as sql_util from sqlalchemy.sql import visitors from sqlalchemy.sql.selectable import SelectStatementGrouping from sqlalchemy.testing import assert_raises @@ -94,24 +93,6 @@ class DeprecationWarningsTest(fixtures.TestBase, AssertsCompiledSQL): ): create_engine("mysql://", convert_unicode=True, module=mock.Mock()) - def test_join_condition_ignore_nonexistent_tables(self): - m = MetaData() - t1 = Table("t1", m, Column("id", Integer)) - t2 = Table( - "t2", m, Column("id", Integer), Column("t1id", ForeignKey("t1.id")) - ) - with testing.expect_deprecated( - "The join_condition.ignore_nonexistent_tables " - "parameter is deprecated" - ): - join_cond = sql_util.join_condition( - t1, t2, ignore_nonexistent_tables=True - ) - - t1t2 = t1.join(t2) - - assert t1t2.onclause.compare(join_cond) - def test_empty_and_or(self): with testing.expect_deprecated( r"Invoking and_\(\) without arguments is deprecated, and " |
