def test_source_option(self): """ should use the source option as the target association name if provided """ association = HasManyThrough(target_klass=self.Site, id='dumb_comments', through='articles', source='comments') self.assertEqual(association.source_association().id, 'comments')
def test_source_association_exists_on_proxy(self): """ should raise when the source association is not defined on the proxy association's class """ association = HasManyThrough(target_klass=self.Site, id=self.id, through='articles') self.assertRaises(errors.AssociationNotFound, association.source_association)
def setUp(self): self.klass = fixtures.association_models.Test self.id = 'has_many_through' self.association = HasManyThrough(target_klass=self.klass, id=self.id) self.adapter = TestAdapter # assign fixtures.association_models.ModelClass to self.ModelClass for m in self.MODELS: setattr(self, m, getattr(fixtures.association_models, m))
def test_association_name(self): """should use the source association that matches the association id""" association = HasManyThrough(target_klass=self.Site, id='comments', through='articles') self.assertEqual(association.source_association().id, 'comments')
def test_through_exists(self): """should raise when through is not an existing association""" association = HasManyThrough(target_klass=self.Site, id=self.id, through='a_tunnel') self.assertRaises(errors.AssociationNotFound, association.proxy_association)
def test_not_polymorphic(self): """should not allow polymorphic associations""" association = HasManyThrough(target_klass=self.Site, id='comments', through='articles', as_='whatever') self.assertEqual(association.polymorphic(), False)