class HasManyTestCase(BaseAssociationTestCase): def setUp(self): self.klass = fixtures.association_models.Test self.id = 'has_many' self.foreign_key = 'some_id' self.has_many = HasMany(target_klass=self.klass, id=self.id) def test_type(self): """should set type to has_many""" self.assertEqual('has_many', self.has_many.type()) def test_collection(self): """should set collection to true""" self.assertTrue(self.has_many.collection()) def test_get_descriptor(self): """should return first object in scope""" TestAdapter.data = { 'id': 1 } class Test(fixtures.association_models.AssocTest): id = Field() foo_id = Field() assoc = HasMany(target_klass=Test, id='foo', klass=Test) Test.foo = assoc instance = Test(id=1, foo_id=1) self.assertEqual(Test.foo, assoc) self.assertEqual(type(instance.foo), Relation)
class HasManyTestCase(BaseAssociationTestCase): def setUp(self): self.klass = fixtures.association_models.Test self.id = "has_many" self.foreign_key = "some_id" self.has_many = HasMany(self.klass, self.id) def test_type(self): """should set type to has_many""" self.assertEqual("has_many", self.has_many.type()) def test_collection(self): """should set collection to true""" self.assertTrue(self.has_many.collection())