def test_create_property_with_property_class(self, pc_mock): class LocalProperty(properties.AbstractProperty): @property def value(self): pass def set_value_force(self, value): pass self.assertEqual(properties.property( property_class=LocalProperty, *self.ARGS, **self.KWARGS), FAKE_VALUE) pc_mock.assert_called_once_with( prop_class=LocalProperty, prop_type=1, args=self.ARGS[1:], kwargs=self.KWARGS)
def test_create_property(self, pc_mock): self.assertEqual(properties.property(*self.ARGS, **self.KWARGS), FAKE_VALUE) pc_mock.assert_called_once_with( prop_class=properties.Property, prop_type=1, args=self.ARGS[1:], kwargs=self.KWARGS)
def relationship(property_type, *args, **kwargs): for arg in args: if not issubclass(arg, models.Model): raise exc.RelationshipModelError(model=arg) kwargs['property_class'] = kwargs.get('property_class', Relationship) return properties.property(property_type=property_type, *args, **kwargs)