Open YPCrumble opened 7 years ago
Indeed; this is the goal of the (stalled) https://github.com/FactoryBoy/factory_boy/tree/wip/auto_factory branch.
I might be able to give it a shot at a future open-source sprint I would be attending. Once the core is done, it would be easier to auto-define default values.
@rbarrois very cool! Let me know if I could be helpful in any way? Happy to contribute.
With Faker being part of factory_boy now for random generation, it might be useful as mentioned in a comment on another issue, to get a PR going for Faker to have max number of characters on more of the providers, and then simply hook into the pre-defined providers that exist there for the automation.
I've implemented this functionality in the form of a custom FactoryOptions class (overriding declarations
seemed to be the only place I could effectively hook in without forking the code). It will automatically wire up a Faker Provider based on the name/type of the field.
However, I need to work with my employer before I can push it out to the project. Hopefully I can polish the code and get it pushed out within a few months. Lots of higher priorities on my plate at the moment.
Thank you for this great library!
This is similar to #330 but I would like to extend it to include a default
factory.Fuzzy
value for common fields like CharField, IntegerField, etc. that are not blank/nullable in the db.Right now for a model like this:
...I have to specify a
field
value explicitly using factory_boy (let me know if this isn't the case and I'm missing something!):...for large models this would save a lot of typing.
I apologize in advance if this is already possible and I missed it or if it's been brought up before - I searched open and closed issues and couldn't find anything. I'd also love to hear if there's a reason it's just way to complicated to achieve!