def test_fields_value_by_instance (self): class Person (Entity): firstname = Field(String) surname = Field(String) p1 = Person(firstname='Homer', surname='Simpson') p2 = Person(firstname='Bart', surname='Simpson') r = ReferenceOne() r.bind_to_entity(Person) r.set_data(p1) self.assertEqual(r.get_data().firstname, 'Homer') self.assertEqual(r.get_data().surname, 'Simpson') r.set_data(p2) self.assertEqual(r.get_data().firstname, 'Bart') self.assertEqual(r.get_data().surname, 'Simpson')
def test_type_by_instance (self): class Person (Entity): firstname = Field(String) surname = Field(String) p = Person(firstname='Homer', surname='Simpson') r = ReferenceOne() r.bind_to_entity(Person) r.set_data(p) self.assertTrue(isinstance(r.get_data(), Entity))