diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-11-10 19:00:28 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2010-11-10 19:00:28 -0500 |
| commit | 3564ea86e7cd982a353b42be4105a40bdf9415a3 (patch) | |
| tree | b1c9369a285e6e290e70c7817869c9326db9a810 /test/orm/test_scoping.py | |
| parent | a9b270a3ed4faf85f772897a867caf6762ff9160 (diff) | |
| download | sqlalchemy-3564ea86e7cd982a353b42be4105a40bdf9415a3.tar.gz | |
- move deprecated interfaces down to bottom of TOC, update verbiage
- more docs for engine, pool, DDL events
- update DDL sequences documentation to use events
- update DDL() docstring to refer to execute_if()
- document parameters for DDLElement.execute_if()
- add retval=True flag to Engine.on_before_execute(), on_before_cursor_execute().
wrap the function if retval=False, check for appropriate usage of the flag, add
tests.
- remove ScopedSession.mapper and tests entirely
- remove ExtensionCarrier and tests
- change remaining tests that use MapperExtension to use MapperEvents
Diffstat (limited to 'test/orm/test_scoping.py')
| -rw-r--r-- | test/orm/test_scoping.py | 174 |
1 files changed, 0 insertions, 174 deletions
diff --git a/test/orm/test_scoping.py b/test/orm/test_scoping.py index 1682e0f7e..fa1777c85 100644 --- a/test/orm/test_scoping.py +++ b/test/orm/test_scoping.py @@ -92,179 +92,5 @@ class ScopedSessionTest(_base.MappedTest): Session.configure, bind=testing.db ) -class ScopedMapperTest(_ScopedTest): - - @classmethod - def define_tables(cls, metadata): - Table('table1', metadata, - Column('id', Integer, primary_key=True, test_needs_autoincrement=True), - Column('data', String(30))) - Table('table2', metadata, - Column('id', Integer, primary_key=True, test_needs_autoincrement=True), - Column('someid', None, ForeignKey('table1.id'))) - - @classmethod - def setup_classes(cls): - class SomeObject(_base.ComparableEntity): - pass - class SomeOtherObject(_base.ComparableEntity): - pass - - @classmethod - @testing.uses_deprecated() - @testing.resolve_artifact_names - def setup_mappers(cls): - Session = scoped_session(sa.orm.create_session) - Session.mapper(SomeObject, table1, properties={ - 'options':relationship(SomeOtherObject) - }) - Session.mapper(SomeOtherObject, table2) - - cls.scoping['Session'] = Session - - @classmethod - @testing.resolve_artifact_names - def insert_data(cls): - s = SomeObject() - s.id = 1 - s.data = 'hello' - sso = SomeOtherObject() - s.options.append(sso) - Session.flush() - Session.expunge_all() - - @testing.resolve_artifact_names - def test_query(self): - sso = SomeOtherObject.query().first() - assert SomeObject.query.filter_by(id=1).one().options[0].id == sso.id - - @testing.uses_deprecated() - @testing.resolve_artifact_names - def test_query_compiles(self): - class Foo(object): - pass - Session.mapper(Foo, table2) - assert hasattr(Foo, 'query') - - ext = sa.orm.MapperExtension() - - class Bar(object): - pass - Session.mapper(Bar, table2, extension=[ext]) - assert hasattr(Bar, 'query') - - class Baz(object): - pass - Session.mapper(Baz, table2, extension=ext) - assert hasattr(Baz, 'query') - - @testing.uses_deprecated() - @testing.resolve_artifact_names - def test_default_constructor_state_not_shared(self): - scope = scoped_session(sa.orm.sessionmaker()) - - class A(object): - pass - class B(object): - def __init__(self): - pass - - scope.mapper(A, table1) - scope.mapper(B, table2) - - A(foo='bar') - assert_raises(TypeError, B, foo='bar') - - scope = scoped_session(sa.orm.sessionmaker()) - - class C(object): - def __init__(self): - pass - class D(object): - pass - - scope.mapper(C, table1) - scope.mapper(D, table2) - - assert_raises(TypeError, C, foo='bar') - D(foo='bar') - - @testing.uses_deprecated() - @testing.resolve_artifact_names - def test_validating_constructor(self): - s2 = SomeObject(someid=12) - s3 = SomeOtherObject(someid=123, bogus=345) - - class ValidatedOtherObject(object): pass - Session.mapper(ValidatedOtherObject, table2, validate=True) - - v1 = ValidatedOtherObject(someid=12) - assert_raises(sa.exc.ArgumentError, ValidatedOtherObject, - someid=12, bogus=345) - - @testing.uses_deprecated() - @testing.resolve_artifact_names - def test_dont_clobber_methods(self): - class MyClass(object): - def expunge(self): - return "an expunge !" - - Session.mapper(MyClass, table2) - - assert MyClass().expunge() == "an expunge !" - - -class ScopedMapperTest2(_ScopedTest): - - @classmethod - def define_tables(cls, metadata): - Table('table1', metadata, - Column('id', Integer, primary_key=True, test_needs_autoincrement=True), - Column('data', String(30)), - Column('type', String(30))) - Table('table2', metadata, - Column('id', Integer, primary_key=True, test_needs_autoincrement=True), - Column('someid', None, ForeignKey('table1.id')), - Column('somedata', String(30))) - - @classmethod - def setup_classes(cls): - class BaseClass(_base.ComparableEntity): - pass - class SubClass(BaseClass): - pass - - @classmethod - @testing.uses_deprecated() - @testing.resolve_artifact_names - def setup_mappers(cls): - Session = scoped_session(sa.orm.sessionmaker()) - - Session.mapper(BaseClass, table1, - polymorphic_identity='base', - polymorphic_on=table1.c.type) - Session.mapper(SubClass, table2, - polymorphic_identity='sub', - inherits=BaseClass) - - cls.scoping['Session'] = Session - - @testing.resolve_artifact_names - def test_inheritance(self): - def expunge_list(l): - for x in l: - Session.expunge(x) - return l - - b = BaseClass(data='b1') - s = SubClass(data='s1', somedata='somedata') - Session.commit() - Session.expunge_all() - - eq_(expunge_list([BaseClass(data='b1'), - SubClass(data='s1', somedata='somedata')]), - BaseClass.query.all()) - eq_(expunge_list([SubClass(data='s1', somedata='somedata')]), - SubClass.query.all()) |
