model-bakery 1.20.0__py3-none-any.whl → 1.20.2__py3-none-any.whl
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/__about__.py +1 -1
- model_bakery/baker.py +5 -1
- model_bakery/recipe.py +3 -1
- model_bakery/timezone.py +2 -2
- model_bakery/utils.py +4 -1
- {model_bakery-1.20.0.dist-info → model_bakery-1.20.2.dist-info}/METADATA +2 -2
- {model_bakery-1.20.0.dist-info → model_bakery-1.20.2.dist-info}/RECORD +9 -9
- {model_bakery-1.20.0.dist-info → model_bakery-1.20.2.dist-info}/WHEEL +1 -1
- {model_bakery-1.20.0.dist-info → model_bakery-1.20.2.dist-info}/licenses/LICENSE +0 -0
model_bakery/__about__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "1.20.
|
|
1
|
+
__version__ = "1.20.2"
|
model_bakery/baker.py
CHANGED
|
@@ -699,6 +699,8 @@ class Baker(Generic[M]):
|
|
|
699
699
|
ct_field_name = data["content_type_field"]
|
|
700
700
|
oid_field_name = data["object_id_field"]
|
|
701
701
|
value = data["value"]
|
|
702
|
+
if callable(value):
|
|
703
|
+
value = value()
|
|
702
704
|
if is_iterator(value):
|
|
703
705
|
value = next(value)
|
|
704
706
|
if value is None:
|
|
@@ -714,7 +716,9 @@ class Baker(Generic[M]):
|
|
|
714
716
|
setattr(
|
|
715
717
|
instance,
|
|
716
718
|
ct_field_name,
|
|
717
|
-
contenttypes_models.ContentType.objects.get_for_model(
|
|
719
|
+
contenttypes_models.ContentType.objects.get_for_model(
|
|
720
|
+
value, for_concrete_model=False
|
|
721
|
+
),
|
|
718
722
|
)
|
|
719
723
|
setattr(instance, oid_field_name, value.pk)
|
|
720
724
|
|
model_bakery/recipe.py
CHANGED
|
@@ -164,9 +164,11 @@ class Recipe(Generic[M]):
|
|
|
164
164
|
**attrs: Any,
|
|
165
165
|
) -> Union[M, List[M]]:
|
|
166
166
|
defaults = {
|
|
167
|
-
"_quantity": _quantity,
|
|
168
167
|
"_save_related": _save_related,
|
|
169
168
|
}
|
|
169
|
+
if _quantity is not None:
|
|
170
|
+
defaults["_quantity"] = _quantity # type: ignore[assignment]
|
|
171
|
+
|
|
170
172
|
defaults.update(attrs)
|
|
171
173
|
return baker.prepare(
|
|
172
174
|
self._model, _using=_using, **self._mapping(_using, defaults)
|
model_bakery/timezone.py
CHANGED
|
@@ -8,6 +8,6 @@ from django.conf import settings
|
|
|
8
8
|
def tz_aware(value: datetime) -> datetime:
|
|
9
9
|
"""Return an UTC-aware datetime in case of USE_TZ=True."""
|
|
10
10
|
if settings.USE_TZ:
|
|
11
|
-
|
|
11
|
+
return value.replace(tzinfo=timezone.utc)
|
|
12
12
|
|
|
13
|
-
return value
|
|
13
|
+
return value.replace(tzinfo=None)
|
model_bakery/utils.py
CHANGED
|
@@ -86,7 +86,10 @@ def seq(value, increment_by=1, start=None, suffix=None):
|
|
|
86
86
|
start = (date - epoch_datetime).total_seconds()
|
|
87
87
|
increment_by = increment_by.total_seconds()
|
|
88
88
|
for n in itertools.count(increment_by, increment_by):
|
|
89
|
-
series_date = tz_aware(
|
|
89
|
+
series_date = tz_aware(
|
|
90
|
+
datetime.datetime.fromtimestamp(start + n, tz=datetime.timezone.utc)
|
|
91
|
+
)
|
|
92
|
+
|
|
90
93
|
if type(value) is datetime.time:
|
|
91
94
|
yield series_date.time()
|
|
92
95
|
elif type(value) is datetime.date:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: model-bakery
|
|
3
|
-
Version: 1.20.
|
|
3
|
+
Version: 1.20.2
|
|
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>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
model_bakery/__about__.py,sha256=
|
|
1
|
+
model_bakery/__about__.py,sha256=eQzQdw3fIHlmkOHFxyZvsA45EcuNLz70oImv88u9p_o,23
|
|
2
2
|
model_bakery/__init__.py,sha256=yY0xZUrr_mskBm07iF-MFBEiXzOuKrlMwpKWkXZs8v0,31
|
|
3
3
|
model_bakery/_types.py,sha256=P0iKC5-Cnh3lyzyZs1mlCfOW31zbEZpxqWCuYonucKo,130
|
|
4
|
-
model_bakery/baker.py,sha256=
|
|
4
|
+
model_bakery/baker.py,sha256=jvaffAalyp6f57keMYAiE3H09vZyBm7BZD3i6NzFGGc,31041
|
|
5
5
|
model_bakery/content_types.py,sha256=3POJ12aqPuSvCdKYuwb1GlJpSocgByG2JW5kw7VBNxQ,395
|
|
6
6
|
model_bakery/exceptions.py,sha256=q1oBZvfxL7HAD-F9aWgiYs4P4rz-hJ5TjeX7gcb3Q0I,333
|
|
7
7
|
model_bakery/generators.py,sha256=weuPptRtWnznjXGB658ftLQtSj5RMwngx-ryBXapNjE,5173
|
|
@@ -10,10 +10,10 @@ model_bakery/mock_file.txt,sha256=CO5zPS6Uydk48ZRnGcRKVEYKd2YjaUMa9QOgF5gGMCo,10
|
|
|
10
10
|
model_bakery/mock_img.jpeg,sha256=iF2ybgAVtDvl48-8VKdv_QFHKfnqeOaeGwR6ZLexJkY,1916
|
|
11
11
|
model_bakery/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
12
|
model_bakery/random_gen.py,sha256=3rvZCg5px6NOY1Q3fHSqw51BY6iQfCmOoRX4SsCOp6U,10084
|
|
13
|
-
model_bakery/recipe.py,sha256=
|
|
14
|
-
model_bakery/timezone.py,sha256=
|
|
15
|
-
model_bakery/utils.py,sha256=
|
|
16
|
-
model_bakery-1.20.
|
|
17
|
-
model_bakery-1.20.
|
|
18
|
-
model_bakery-1.20.
|
|
19
|
-
model_bakery-1.20.
|
|
13
|
+
model_bakery/recipe.py,sha256=lxsfdrNKydHLgPRiUTVh7DssmG-z2f8gL6okJ7yoCSQ,8451
|
|
14
|
+
model_bakery/timezone.py,sha256=IvrzSer02FkUd_8DcJVOwTcRzeBn4qZ2pYvcI3QOr9E,345
|
|
15
|
+
model_bakery/utils.py,sha256=NjUsWuPmCYy6kHLjWmYnH7l-MVqlqiqSh7uq1U7EWaI,4635
|
|
16
|
+
model_bakery-1.20.2.dist-info/METADATA,sha256=ZBGqfCpaviQhuSpRpycfAHU9ibVRhzuESUVpuNd2OEU,4406
|
|
17
|
+
model_bakery-1.20.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
18
|
+
model_bakery-1.20.2.dist-info/licenses/LICENSE,sha256=kCwHls7z8Y7NyZCmdnV1qLSdLrQ8bHrXLji5HOasgUc,611
|
|
19
|
+
model_bakery-1.20.2.dist-info/RECORD,,
|
|
File without changes
|