class HasOneTestCase(BaseAssociationTestCase): def setUp(self): self.klass = fixtures.association_models.Test self.id = 'has_one' self.foreign_key = 'some_id' self.has_one = HasOne(target_klass=self.klass, id=self.id) def test_type(self): """should set type to has_one""" self.assertEqual('has_one', self.has_one.type()) def test_collection(self): """should set collection to false""" self.assertFalse(self.has_one.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 = HasOne(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), Test)
class HasOneTestCase(BaseAssociationTestCase): def setUp(self): self.klass = fixtures.association_models.Test self.id = "has_one" self.foreign_key = "some_id" self.has_one = HasOne(self.klass, self.id) def test_type(self): """should set type to has_one""" self.assertEqual("has_one", self.has_one.type()) def test_collection(self): """should set collection to false""" self.assertFalse(self.has_one.collection())