Skip to content

Commit

Permalink
fix hidden requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
devkral committed Jan 21, 2025
1 parent 1744df1 commit 249ee18
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions docs/testing/model-factory.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ You will need to re-enable via setting the mapping in a subclass to a mapping fu

### Setting database and schema

By default the database and schema of the model is used unchanged. You can however provide an other database or schema than the default by defining
By default the database and schema of the model used is unchanged. You can however provide an other database or schema than the default by defining
them as class or instance variables (not by keyword arguments) on a Factory.
The syntax is the same like for database models, you define them on the main model. You can also overwrite them one-time in the build method.
The syntax is the same as the one used for database models, you define them on the main model. You can also overwrite them one-time in the build method.

- `__using_schema__` (str or None)
- `database` (Database or None)
Expand All @@ -82,9 +82,9 @@ The syntax is the same like for database models, you define them on the main mod

### Parametrizing relation fields

Relation fields are fields like ForeignKey ManyToMany, OneToOne and RelatedFIeld.
Relation fields are fields like ForeignKey ManyToMany, OneToOne and RelatedField.

For parametrizing relation fields exist two variants:
To parametrize relation fields there are two variants:

1. Pass `build()` parameters as field parameters. For 1-n relations there are two extra parameters min=0, max=100, which allow to specify how many
instances are generated.
Expand All @@ -109,21 +109,21 @@ There are two special parameters which are always available for all fields:
The first randomly excludes a field value. The second randomly sets a value to None.
You can either pass True for a equal distribution or a number from 0-100 to bias it.


### Excluding a field

To exclude a field there are 3 ways
To exclude a field there are three ways

- Provide a field with `exclude=True`. It should be defined under the name of the value.
- Add the field name to the exclude parameter of build.
- Raise `edgy.testing.exceptions.ExcludeValue` in a callback.

Let's revisit one of the first examples. Here the id field is excluded by a different named FactoryField.

```python
{!> ../docs_src/testing/factory/factory_fields_exclude.py !}
```

Note however that the FactoryField can only be overwritten by its provided name or in case it is unset its implicit name.
Note: However that the FactoryField can only be overwritten by its provided name or in case it is unset its implicit name.
When multiple fields have the same name, the last found in the same class is overwritting the other.

Otherwise the mro order is used.
Expand All @@ -142,14 +142,14 @@ or for wrapping factory fields via the `to_factory_field` or `to_list_factory_fi

The parameters are:

- faker (not available for factories for relationship fields. Here is the provided faker or faker of the parent model used). Provide a custom Faker instance.
- **faker** (not available for factories for relationship fields. Here is the provided faker or faker of the parent model used). Provide a custom Faker instance.
This can be useful when the seed is modified.
- parameters ({fieldname: {parametername: parametervalue} | FactoryCallback}): Provide per field name either a callback which returns the value or parameters.
- overwrites ({fieldname: value}): Provide the value directly. Skip any evaluation
- exclude (e.g. {"id"}): Exclude the values from stubbing. Useful for removing the autogenerated id.
- database (Database | None | False): Use a different database. When None pick the one of the ModelFactory if available, then fallback to the model.
- **parameters** ({fieldname: {parametername: parametervalue} | FactoryCallback}): Provide per field name either a callback which returns the value or parameters.
- **overwrites** ({fieldname: value}): Provide the value directly. Skip any evaluation
- **exclude** (e.g. {"id"}): Exclude the values from stubbing. Useful for removing the autogenerated id.
- **database** (Database | None | False): Use a different database. When None pick the one of the ModelFactory if available, then fallback to the model.
When `False`, just use the one of the model.
- schema (str | None | False): Use a different schema. When `None` pick the one of the ModelFactory if available, then fallback to the model.
- **schema** (str | None | False): Use a different schema. When `None` pick the one of the ModelFactory if available, then fallback to the model.
When `False`, just use the one of the model.

```python
Expand Down

0 comments on commit 249ee18

Please sign in to comment.