pyconjp / pycon.jp.2021.review

https://pyconjp.github.io/pycon.jp.2021.review/
MIT License
0 stars 0 forks source link

開発者はダミープロポーザルを登録できる #20

Closed ftnext closed 3 years ago

ftnext commented 3 years ago

factory_boy を試す

https://kuroneko0208.hatenablog.com/entry/2015/01/25/031727

ftnext commented 3 years ago

https://factoryboy.readthedocs.io/en/latest/index.html#realistic-random-values を参考にFakerを使ってランダムな値を生成

文字列

https://faker.readthedocs.io/en/latest/providers/faker.providers.lorem.html

参考:https://python.hotexamples.com/examples/faker/Faker/sentence/python-faker-sentence-method-examples.html

整数

https://faker.readthedocs.io/en/latest/providers/faker.providers.python.html#faker.providers.python.Provider.pyint

UUID

https://faker.readthedocs.io/en/latest/providers/faker.providers.misc.html#faker.providers.misc.Provider.uuid4

選択肢から

https://factoryboy.readthedocs.io/en/latest/fuzzy.html#fuzzychoice

Use import factory.fuzzy to load this module.

ftnext commented 3 years ago

https://factoryboy.readthedocs.io/en/latest/introduction.html#strategies

Starting from 2.0, factory.Factory.create() simply calls AssociatedClass(**kwargs). You should use DjangoModelFactory for Django models.

factory.Factory.create() ではDBに保存されないので、動作確認では便利だった