From 1f4c4e107f24cbb36110e8cb88908b34bac74b01 Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Tue, 17 Feb 2009 21:40:55 -0500 Subject: Add a "mock and monkey" layer to set up testing infrastructure, e.g. for predictable dates and times. Fill out the autorespond.txt test to show that when the date flips over, the response counts reset. Add a date/time factory which we should use rather than the built-in datetime for now() and today() so that they can be appropriately tested. --- src/mailman/database/autorespond.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/mailman/database/autorespond.py') diff --git a/src/mailman/database/autorespond.py b/src/mailman/database/autorespond.py index 9561e804c..0a22dfa14 100644 --- a/src/mailman/database/autorespond.py +++ b/src/mailman/database/autorespond.py @@ -27,7 +27,6 @@ __all__ = [ ] -from datetime import date from storm.locals import And, Date, Int, Reference from zope.interface import implements @@ -37,6 +36,7 @@ from mailman.database.types import Enum from mailman.interfaces.autorespond import ( IAutoResponseRecord, IAutoResponseSet, Response) from mailman.interfaces.mailinglist import IMailingList +from mailman.utilities.datetime import today @@ -58,7 +58,7 @@ class AutoResponseRecord(Model): self.mailing_list = mailing_list self.address = address self.response_type = response_type - self.date_sent = date.today() + self.date_sent = today() @@ -75,7 +75,7 @@ class AutoResponseSet: And(AutoResponseRecord.address == address, AutoResponseRecord.mailing_list == self._mailing_list, AutoResponseRecord.response_type == response_type, - AutoResponseRecord.date_sent == date.today())).count() + AutoResponseRecord.date_sent == today())).count() def response_sent(self, address, response_type): """See `IAutoResponseSet`.""" -- cgit v1.2.3-70-g09d2