On Mon, 2007-06-11 at 09:27 -0700, [EMAIL PROTECTED] wrote:
> I'm writing tests for an application, and I sort by update_time for
> one model.  Is it possible in my fixtures to set fixed times?  Right
> now, the update_time attribute is always almost "right now".  If I try
> to set it in my JSON fixtures file, that value is overridden when the
> fixture is saved, and when I set it manually, I can't save because
> then the update_time would be when I call save(), not what I manually
> set.

Is update_time an attribute on your model? Django doesn't store any
update time by default does it?

If this is something on your model, you need to fix it in your test code
somehow. One thing I've done in the past (not in Django, but in testing
time-sensitive items), is to load all the data into the database and
then, as part of the tests setup() method, go in and update all the
necessary time values to what I would like them to be for testing
purposes. It's not a completely pure test because some of the data is
set by some other means to production, but it's close.

Sometimes overriding datetime.datetime.now (or whatever you are using to
generate the timestamps in the first place) is possible, but it's fiddly
to produce predictable, different timestamps.

Regards,
Malcolm


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to