def test_kwarg(self): """should use the primary key given in the kwargs""" association = BelongsTo(target_klass=TargetModel, id='whatever', primary_key='asdf') self.assertEqual(association.primary_key(), 'asdf') association = Has(target_klass=TargetModel, id='whatever', primary_key='asdf') self.assertEqual(association.primary_key(), 'asdf')
def test_belongs_to(self): """ should use the source class's primary key in a belongs to association """ association = BelongsTo(target_klass=TargetModel, id='whatever', class_name='SourceModel') self.assertEqual(association.primary_key(), SourceModel.primary_key())
def test_polymorphic_belongs_to(self): """ should use the source class's primary key in a polymorphic belongs to association """ association = BelongsTo(TargetModel, "whatever", polymorphic=True) target_instance = TargetModel({"whatever_type": "SourceModel"}) self.assertEqual(association.primary_key(target_instance), SourceModel.primary_key())
def test_polymorphic_belongs_to(self): """ should use the source class's primary key in a polymorphic belongs to association """ association = BelongsTo(target_klass=TargetModel, id='whatever', polymorphic=True) target_instance = TargetModel({'whatever_type': 'SourceModel'}) self.assertEqual(association.primary_key(target_instance), SourceModel.primary_key())
def test_belongs_to(self): """ should use the source class's primary key in a belongs to association """ association = BelongsTo(TargetModel, "whatever", class_name="SourceModel") self.assertEqual(association.primary_key(), SourceModel.primary_key())
def test_kwarg(self): """should use the primary key given in the kwargs""" association = BelongsTo(TargetModel, "whatever", primary_key="asdf") self.assertEqual(association.primary_key(), "asdf") association = Has(TargetModel, "whatever", primary_key="asdf") self.assertEqual(association.primary_key(), "asdf")