berinhard / model_mommy

No longer maintained, please migrate to model_bakery
http://model-bakery.readthedocs.org/
Other
903 stars 141 forks source link

Unable to create date-based sequences in recipes #173

Closed lightstrike closed 10 years ago

lightstrike commented 10 years ago

I'd like to be able create a recipe sequence using a date-based increment along the lines of the following:

ending_time=seq(datetime.now(), increment_by=timedelta(days=1))

It looks like only strings and integers are supported right now: https://github.com/vandersonmota/model_mommy/blob/master/model_mommy/recipe.py#L79

I'd be happy to help implement this. Curious what your overall thoughts are and if there's an approach you'd like to see this solved with.

vandersonmota commented 10 years ago

Hi @lightstrike Yes, only strings and integers are suported now. About the approach, i would like to keep it generator based, if possible. itertools.count requires a number, so the seq function will get a little bit more complicated.

Do you have something in mind?

lightstrike commented 10 years ago

How would you feel about adding an "increment_type" argument that would default to string/number but would increment based on time with other arguments. A couple examples:

ending_time=seq(datetime.now(), increment_by=1, increment_type="days") ending_time=seq(datetime.now(), increment_by=5, increment_type="minutes")

vandersonmota commented 10 years ago

we could accept a timedelta as argument, so we don't add extra args to handle datetime fields.

vandersonmota commented 10 years ago

done: 6a113db773808d8240c0af354a317dd6cdc79a5c and 9658cf1daf5c4d3e98996d1cf36bb6cb48bd0c90