Closed Jaymon closed 1 year ago
The Orm.testdata
method can go through all the fields, if one of the fields is a foreign key, it can then call that Orm's testdata method so it can layer building the objects and handle the dependencies and return a fully populated object, creating all the dependent objects along the way
I think https://github.com/Jaymon/prom/blob/master/prom/extras/testdata.py handles this. It allows fields to have a testdata
method that it will use.
So the idea is that you could add an
Orm.testdata()
method that would look at each field and generate an instance that satisfies the constraints of that field, but you can also override field values. And you could also pass in atestdata
generator intoField
so you can customize it.So basically, by default the
Field.testdata()
would check for choice values, defaults, and things like that and generate a value for that field. TheOrm.testdata
method would call all the field testdata methods to get a set of field values and then return an instance, something like this: