model-bakery 1.20.3__tar.gz → 1.20.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of model-bakery might be problematic. Click here for more details.
- {model_bakery-1.20.3 → model_bakery-1.20.5}/PKG-INFO +31 -27
- {model_bakery-1.20.3 → model_bakery-1.20.5}/README.md +29 -26
- model_bakery-1.20.5/model_bakery/__about__.py +1 -0
- {model_bakery-1.20.3 → model_bakery-1.20.5}/model_bakery/baker.py +11 -9
- {model_bakery-1.20.3 → model_bakery-1.20.5}/pyproject.toml +1 -0
- model_bakery-1.20.3/model_bakery/__about__.py +0 -1
- {model_bakery-1.20.3 → model_bakery-1.20.5}/.gitignore +0 -0
- {model_bakery-1.20.3 → model_bakery-1.20.5}/LICENSE +0 -0
- {model_bakery-1.20.3 → model_bakery-1.20.5}/model_bakery/__init__.py +0 -0
- {model_bakery-1.20.3 → model_bakery-1.20.5}/model_bakery/_types.py +0 -0
- {model_bakery-1.20.3 → model_bakery-1.20.5}/model_bakery/content_types.py +0 -0
- {model_bakery-1.20.3 → model_bakery-1.20.5}/model_bakery/exceptions.py +0 -0
- {model_bakery-1.20.3 → model_bakery-1.20.5}/model_bakery/generators.py +0 -0
- {model_bakery-1.20.3 → model_bakery-1.20.5}/model_bakery/gis.py +0 -0
- {model_bakery-1.20.3 → model_bakery-1.20.5}/model_bakery/mock_file.txt +0 -0
- {model_bakery-1.20.3 → model_bakery-1.20.5}/model_bakery/mock_img.jpeg +0 -0
- {model_bakery-1.20.3 → model_bakery-1.20.5}/model_bakery/py.typed +0 -0
- {model_bakery-1.20.3 → model_bakery-1.20.5}/model_bakery/random_gen.py +0 -0
- {model_bakery-1.20.3 → model_bakery-1.20.5}/model_bakery/recipe.py +0 -0
- {model_bakery-1.20.3 → model_bakery-1.20.5}/model_bakery/timezone.py +0 -0
- {model_bakery-1.20.3 → model_bakery-1.20.5}/model_bakery/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: model-bakery
|
|
3
|
-
Version: 1.20.
|
|
3
|
+
Version: 1.20.5
|
|
4
4
|
Summary: Smart object creation facility for Django.
|
|
5
5
|
Project-URL: Homepage, https://github.com/model-bakers/model_bakery
|
|
6
6
|
Author-email: berin <bernardoxhc@gmail.com>, amureki <amureki@hey.com>
|
|
@@ -12,6 +12,7 @@ Classifier: Framework :: Django
|
|
|
12
12
|
Classifier: Framework :: Django :: 4.2
|
|
13
13
|
Classifier: Framework :: Django :: 5.0
|
|
14
14
|
Classifier: Framework :: Django :: 5.1
|
|
15
|
+
Classifier: Framework :: Django :: 5.2
|
|
15
16
|
Classifier: Intended Audience :: Developers
|
|
16
17
|
Classifier: License :: OSI Approved :: Apache Software License
|
|
17
18
|
Classifier: Operating System :: OS Independent
|
|
@@ -47,76 +48,79 @@ Description-Content-Type: text/markdown
|
|
|
47
48
|
[](https://pypi.python.org/pypi/model_bakery/)
|
|
48
49
|
[](https://model-bakery.readthedocs.io/en/latest/?badge=latest)
|
|
49
50
|
|
|
50
|
-
*Model Bakery* offers you a smart way to create fixtures for testing in
|
|
51
|
-
Django.
|
|
52
|
-
With a simple and powerful API you can create many objects with a single
|
|
53
|
-
line of code.
|
|
51
|
+
*Model Bakery* offers you a smart way to create fixtures for testing in Django. With a simple and powerful API, you can create many objects with a single line of code.
|
|
54
52
|
|
|
55
|
-
Model Bakery is a rename of the legacy [Model Mommy project](https://pypi.org/project/model_mommy/).
|
|
53
|
+
> **Note:** Model Bakery is a rename of the legacy [Model Mommy project](https://pypi.org/project/model_mommy/).
|
|
56
54
|
|
|
57
|
-
##
|
|
55
|
+
## Installation
|
|
58
56
|
|
|
59
57
|
```bash
|
|
60
58
|
pip install model-bakery
|
|
61
59
|
```
|
|
62
60
|
|
|
63
|
-
##
|
|
64
|
-
|
|
65
|
-
### Basic usage
|
|
61
|
+
## Basic usage
|
|
66
62
|
|
|
67
63
|
```python
|
|
68
|
-
|
|
69
64
|
# models.py
|
|
70
|
-
|
|
71
65
|
from django.db import models
|
|
72
66
|
|
|
73
67
|
class Customer(models.Model):
|
|
74
|
-
enjoy_jards_macale = models.BooleanField()
|
|
75
68
|
name = models.CharField(max_length=30)
|
|
76
69
|
email = models.EmailField()
|
|
77
70
|
age = models.IntegerField()
|
|
71
|
+
is_jards_macale_fan = models.BooleanField()
|
|
78
72
|
bio = models.TextField()
|
|
79
|
-
days_since_last_login = models.BigIntegerField()
|
|
80
73
|
birthday = models.DateField()
|
|
81
74
|
last_shopping = models.DateTimeField()
|
|
82
75
|
|
|
83
76
|
# test_models.py
|
|
84
|
-
|
|
85
77
|
from django.test import TestCase
|
|
86
78
|
from model_bakery import baker
|
|
87
|
-
from pprint import pprint
|
|
88
79
|
|
|
89
80
|
class TestCustomerModel(TestCase):
|
|
90
81
|
def setUp(self):
|
|
91
82
|
self.customer = baker.make('shop.Customer')
|
|
92
|
-
|
|
83
|
+
print(self.customer.__dict__)
|
|
93
84
|
|
|
94
85
|
"""
|
|
95
86
|
{'_state': <django.db.models.base.ModelState object at 0x1129a3240>,
|
|
96
87
|
'age': 3841,
|
|
97
88
|
'bio': 'vUFzMUMyKzlnTyiCxfgODIhrnkjzgQwHtzIbtnVDKflqevczfnaOACkDNqvCHwvtWdLwoiKrCqfppAlogSLECtMmfleeveyqefkGyTGnpbkVQTtviQVDESpXascHAluGHYEotSypSiHvHzFteKIcUebrzUVigiOacfnGdvijEPrZdSCIIBjuXZMaWLrMXyrsUCdKPLRBRYklRdtZhgtxuASXdhNGhDsrnPHrYRClhrSJSVFojMkUHBvSZhoXoCrTfHsAjenCEHvcLeCecsXwXgWJcnJPSFdOmOpiHRnhSgRF',
|
|
98
89
|
'birthday': datetime.date(2019, 12, 3),
|
|
99
|
-
'
|
|
90
|
+
'email': 'rpNATNsxoj@example.com',
|
|
91
|
+
'is_jards_macale_fan': True,
|
|
100
92
|
'id': 1,
|
|
101
93
|
'last_shopping': datetime.datetime(2019, 12, 3, 21, 42, 34, 77019),
|
|
102
|
-
'name': 'qiayYnESvqcYLLBzxpFOcGBIfnQEPx'
|
|
103
|
-
'days_since_last_login': 6016}
|
|
94
|
+
'name': 'qiayYnESvqcYLLBzxpFOcGBIfnQEPx'}
|
|
104
95
|
"""
|
|
105
|
-
|
|
106
96
|
```
|
|
107
97
|
|
|
108
|
-
|
|
98
|
+
## Documentation
|
|
99
|
+
|
|
100
|
+
For more detailed information, check out the [full documentation](https://model-bakery.readthedocs.io/).
|
|
109
101
|
|
|
110
102
|
## Contributing
|
|
111
103
|
|
|
112
|
-
|
|
104
|
+
As an open-source project, Model Bakery welcomes contributions of many forms:
|
|
105
|
+
|
|
106
|
+
- Code patches
|
|
107
|
+
- Documentation improvements
|
|
108
|
+
- Bug reports
|
|
109
|
+
|
|
110
|
+
Take a look at our [contribution guidelines](CONTRIBUTING.md) for instructions
|
|
111
|
+
on how to set up your local environment.
|
|
113
112
|
|
|
114
113
|
## Maintainers
|
|
115
114
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
115
|
+
- [Bernardo Fontes](https://github.com/berinhard/)
|
|
116
|
+
- [Rustem Saiargaliev](https://github.com/amureki/)
|
|
117
|
+
- [Tim Klein](https://github.com/timjklein36)
|
|
119
118
|
|
|
120
119
|
## Creator
|
|
121
120
|
|
|
122
|
-
|
|
121
|
+
- [Vanderson Mota](https://github.com/vandersonmota/)
|
|
122
|
+
|
|
123
|
+
## License
|
|
124
|
+
|
|
125
|
+
Model Bakery is licensed under the MIT License.
|
|
126
|
+
See the [LICENSE](LICENSE) file for more information.
|
|
@@ -5,76 +5,79 @@
|
|
|
5
5
|
[](https://pypi.python.org/pypi/model_bakery/)
|
|
6
6
|
[](https://model-bakery.readthedocs.io/en/latest/?badge=latest)
|
|
7
7
|
|
|
8
|
-
*Model Bakery* offers you a smart way to create fixtures for testing in
|
|
9
|
-
Django.
|
|
10
|
-
With a simple and powerful API you can create many objects with a single
|
|
11
|
-
line of code.
|
|
8
|
+
*Model Bakery* offers you a smart way to create fixtures for testing in Django. With a simple and powerful API, you can create many objects with a single line of code.
|
|
12
9
|
|
|
13
|
-
Model Bakery is a rename of the legacy [Model Mommy project](https://pypi.org/project/model_mommy/).
|
|
10
|
+
> **Note:** Model Bakery is a rename of the legacy [Model Mommy project](https://pypi.org/project/model_mommy/).
|
|
14
11
|
|
|
15
|
-
##
|
|
12
|
+
## Installation
|
|
16
13
|
|
|
17
14
|
```bash
|
|
18
15
|
pip install model-bakery
|
|
19
16
|
```
|
|
20
17
|
|
|
21
|
-
##
|
|
22
|
-
|
|
23
|
-
### Basic usage
|
|
18
|
+
## Basic usage
|
|
24
19
|
|
|
25
20
|
```python
|
|
26
|
-
|
|
27
21
|
# models.py
|
|
28
|
-
|
|
29
22
|
from django.db import models
|
|
30
23
|
|
|
31
24
|
class Customer(models.Model):
|
|
32
|
-
enjoy_jards_macale = models.BooleanField()
|
|
33
25
|
name = models.CharField(max_length=30)
|
|
34
26
|
email = models.EmailField()
|
|
35
27
|
age = models.IntegerField()
|
|
28
|
+
is_jards_macale_fan = models.BooleanField()
|
|
36
29
|
bio = models.TextField()
|
|
37
|
-
days_since_last_login = models.BigIntegerField()
|
|
38
30
|
birthday = models.DateField()
|
|
39
31
|
last_shopping = models.DateTimeField()
|
|
40
32
|
|
|
41
33
|
# test_models.py
|
|
42
|
-
|
|
43
34
|
from django.test import TestCase
|
|
44
35
|
from model_bakery import baker
|
|
45
|
-
from pprint import pprint
|
|
46
36
|
|
|
47
37
|
class TestCustomerModel(TestCase):
|
|
48
38
|
def setUp(self):
|
|
49
39
|
self.customer = baker.make('shop.Customer')
|
|
50
|
-
|
|
40
|
+
print(self.customer.__dict__)
|
|
51
41
|
|
|
52
42
|
"""
|
|
53
43
|
{'_state': <django.db.models.base.ModelState object at 0x1129a3240>,
|
|
54
44
|
'age': 3841,
|
|
55
45
|
'bio': 'vUFzMUMyKzlnTyiCxfgODIhrnkjzgQwHtzIbtnVDKflqevczfnaOACkDNqvCHwvtWdLwoiKrCqfppAlogSLECtMmfleeveyqefkGyTGnpbkVQTtviQVDESpXascHAluGHYEotSypSiHvHzFteKIcUebrzUVigiOacfnGdvijEPrZdSCIIBjuXZMaWLrMXyrsUCdKPLRBRYklRdtZhgtxuASXdhNGhDsrnPHrYRClhrSJSVFojMkUHBvSZhoXoCrTfHsAjenCEHvcLeCecsXwXgWJcnJPSFdOmOpiHRnhSgRF',
|
|
56
46
|
'birthday': datetime.date(2019, 12, 3),
|
|
57
|
-
'
|
|
47
|
+
'email': 'rpNATNsxoj@example.com',
|
|
48
|
+
'is_jards_macale_fan': True,
|
|
58
49
|
'id': 1,
|
|
59
50
|
'last_shopping': datetime.datetime(2019, 12, 3, 21, 42, 34, 77019),
|
|
60
|
-
'name': 'qiayYnESvqcYLLBzxpFOcGBIfnQEPx'
|
|
61
|
-
'days_since_last_login': 6016}
|
|
51
|
+
'name': 'qiayYnESvqcYLLBzxpFOcGBIfnQEPx'}
|
|
62
52
|
"""
|
|
63
|
-
|
|
64
53
|
```
|
|
65
54
|
|
|
66
|
-
|
|
55
|
+
## Documentation
|
|
56
|
+
|
|
57
|
+
For more detailed information, check out the [full documentation](https://model-bakery.readthedocs.io/).
|
|
67
58
|
|
|
68
59
|
## Contributing
|
|
69
60
|
|
|
70
|
-
|
|
61
|
+
As an open-source project, Model Bakery welcomes contributions of many forms:
|
|
62
|
+
|
|
63
|
+
- Code patches
|
|
64
|
+
- Documentation improvements
|
|
65
|
+
- Bug reports
|
|
66
|
+
|
|
67
|
+
Take a look at our [contribution guidelines](CONTRIBUTING.md) for instructions
|
|
68
|
+
on how to set up your local environment.
|
|
71
69
|
|
|
72
70
|
## Maintainers
|
|
73
71
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
72
|
+
- [Bernardo Fontes](https://github.com/berinhard/)
|
|
73
|
+
- [Rustem Saiargaliev](https://github.com/amureki/)
|
|
74
|
+
- [Tim Klein](https://github.com/timjklein36)
|
|
77
75
|
|
|
78
76
|
## Creator
|
|
79
77
|
|
|
80
|
-
|
|
78
|
+
- [Vanderson Mota](https://github.com/vandersonmota/)
|
|
79
|
+
|
|
80
|
+
## License
|
|
81
|
+
|
|
82
|
+
Model Bakery is licensed under the MIT License.
|
|
83
|
+
See the [LICENSE](LICENSE) file for more information.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "1.20.5"
|
|
@@ -83,7 +83,7 @@ def make(
|
|
|
83
83
|
_model: Union[str, Type[M]],
|
|
84
84
|
_quantity: None = None,
|
|
85
85
|
make_m2m: bool = False,
|
|
86
|
-
_save_kwargs: Optional[Dict] = None,
|
|
86
|
+
_save_kwargs: Optional[Dict[str, Any]] = None,
|
|
87
87
|
_refresh_after_create: bool = False,
|
|
88
88
|
_create_files: bool = False,
|
|
89
89
|
_using: str = "",
|
|
@@ -97,7 +97,7 @@ def make(
|
|
|
97
97
|
_model: Union[str, Type[M]],
|
|
98
98
|
_quantity: int,
|
|
99
99
|
make_m2m: bool = False,
|
|
100
|
-
_save_kwargs: Optional[Dict] = None,
|
|
100
|
+
_save_kwargs: Optional[Dict[str, Any]] = None,
|
|
101
101
|
_refresh_after_create: bool = False,
|
|
102
102
|
_create_files: bool = False,
|
|
103
103
|
_using: str = "",
|
|
@@ -111,7 +111,7 @@ def make(
|
|
|
111
111
|
_model,
|
|
112
112
|
_quantity: Optional[int] = None,
|
|
113
113
|
make_m2m: bool = False,
|
|
114
|
-
_save_kwargs: Optional[Dict] = None,
|
|
114
|
+
_save_kwargs: Optional[Dict[str, Any]] = None,
|
|
115
115
|
_refresh_after_create: bool = False,
|
|
116
116
|
_create_files: bool = False,
|
|
117
117
|
_using: str = "",
|
|
@@ -155,7 +155,7 @@ def prepare(
|
|
|
155
155
|
_quantity: None = None,
|
|
156
156
|
_save_related: bool = False,
|
|
157
157
|
_using: str = "",
|
|
158
|
-
**attrs,
|
|
158
|
+
**attrs: Any,
|
|
159
159
|
) -> M: ...
|
|
160
160
|
|
|
161
161
|
|
|
@@ -166,7 +166,7 @@ def prepare(
|
|
|
166
166
|
_save_related: bool = False,
|
|
167
167
|
_using: str = "",
|
|
168
168
|
_fill_optional: Union[List[str], bool] = False,
|
|
169
|
-
**attrs,
|
|
169
|
+
**attrs: Any,
|
|
170
170
|
) -> List[M]: ...
|
|
171
171
|
|
|
172
172
|
|
|
@@ -176,7 +176,7 @@ def prepare(
|
|
|
176
176
|
_save_related: bool = False,
|
|
177
177
|
_using: str = "",
|
|
178
178
|
_fill_optional: Union[List[str], bool] = False,
|
|
179
|
-
**attrs,
|
|
179
|
+
**attrs: Any,
|
|
180
180
|
):
|
|
181
181
|
"""Create but do not persist an instance from a given model.
|
|
182
182
|
|
|
@@ -590,9 +590,6 @@ class Baker(Generic[M]):
|
|
|
590
590
|
else:
|
|
591
591
|
field.fill_optional = field.name in self.fill_in_optional
|
|
592
592
|
|
|
593
|
-
if _is_auto_datetime_field(field):
|
|
594
|
-
return True
|
|
595
|
-
|
|
596
593
|
if isinstance(field, FileField) and not self.create_files:
|
|
597
594
|
return True
|
|
598
595
|
|
|
@@ -647,8 +644,13 @@ class Baker(Generic[M]):
|
|
|
647
644
|
if not attrs:
|
|
648
645
|
return
|
|
649
646
|
|
|
647
|
+
# use .update() to force update auto_now fields
|
|
650
648
|
instance.__class__.objects.filter(pk=instance.pk).update(**attrs)
|
|
651
649
|
|
|
650
|
+
# to make the resulting instance has the specified values
|
|
651
|
+
for k, v in attrs.items():
|
|
652
|
+
setattr(instance, k, v)
|
|
653
|
+
|
|
652
654
|
def _handle_one_to_many(self, instance: Model, attrs: Dict[str, Any]):
|
|
653
655
|
for key, values in attrs.items():
|
|
654
656
|
manager = getattr(instance, key)
|
|
@@ -25,6 +25,7 @@ classifiers = [
|
|
|
25
25
|
"Framework :: Django :: 4.2",
|
|
26
26
|
"Framework :: Django :: 5.0",
|
|
27
27
|
"Framework :: Django :: 5.1",
|
|
28
|
+
"Framework :: Django :: 5.2",
|
|
28
29
|
"Intended Audience :: Developers",
|
|
29
30
|
"License :: OSI Approved :: Apache Software License",
|
|
30
31
|
"Operating System :: OS Independent",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "1.20.3"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|