]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
test another version of the mixin here
authorMike Bayer <mike_mp@zzzcomputing.com>
Tue, 6 Apr 2010 16:32:51 +0000 (12:32 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 6 Apr 2010 16:32:51 +0000 (12:32 -0400)
test/ext/test_declarative.py

index b0140fb4207d18ac7e6875593f7bf2cb0e135352..67e650c34f5542facaadfc3638805015005af9c8 100644 (file)
@@ -2074,6 +2074,32 @@ class DeclarativeMixinTest(DeclarativeTestBase):
 
         assert class_mapper(Person).polymorphic_on is Person.__table__.c.type
         eq_(class_mapper(Engineer).polymorphic_identity, 'Engineer')
+
+    def test_mapper_args_classproperty_two(self):
+        # same as test_mapper_args_classproperty, but
+        # we repeat ComputedMapperArgs on both classes
+        # for no apparent reason.
+        
+        class ComputedMapperArgs:
+            @classproperty
+            def __mapper_args__(cls):
+                if cls.__name__=='Person':
+                    return dict(polymorphic_on=cls.discriminator)
+                else:
+                    return dict(polymorphic_identity=cls.__name__)
+
+        class Person(Base,ComputedMapperArgs):
+            __tablename__ = 'people'
+            id = Column(Integer, primary_key=True)
+            discriminator = Column('type', String(50))
+
+        class Engineer(Person, ComputedMapperArgs):
+            pass
+
+        compile_mappers()
+
+        assert class_mapper(Person).polymorphic_on is Person.__table__.c.type
+        eq_(class_mapper(Engineer).polymorphic_identity, 'Engineer')
         
     def test_table_args_composite(self):