factory
– Factory Superclass¶
Contains the Factory base class and metaclass for all the factories created by PyFactory.
-
class
pyfactory.factory.
Factory
[source]¶ This is the base class for all created factories. All factories at some point lead back to this superclass.
-
_model
¶ Subclasses of this class should define this variable to be the class to use as the model for all the schemas.
-
_model_builder
¶ Subclasses of this class should define this variable to be the value to use as the model builder for all the schemas.
-
schema
(schema, **kwargs)[source]¶ This returns the raw schema result for the given name. This will not resolve any special fields.
- Parameters
schema: The name of the schema to retrieve.
**kwargs (optional): Any additional keyword arguments given override the attributes returned. This allows for customization of the factory defaults.
-
attributes
(schema, _pyfactory_scope='attributes', **kwargs)[source]¶ This returns the attributes for a particular schema. The attributes are returned as a dict instead of a model instance.
- Parameters
schema: The name of the schema to retrieve.
**kwargs (optional): Any additional keyword arguments given override the attributes returned. This allows for customization of the factory defaults.
-
build
(schema, **kwargs)[source]¶ This builds a model but does not save it. The arguments are the same as
attributes()
.
-
create
(schema, **kwargs)[source]¶ This builds a model based on the schema with the given name and saves it, returning the new model. The arguments are the same as
attributes()
.
-