def url_view(request, URL=URL): """model for test hooks""" matchdict = request.matchdict try: context = URL.m.find({'short_url' : matchdict['short_url']}).one() resp = HTTPFound(location=context.url) resp.expires=expire_one_year() except StopIteration: resp = HTTPNotFound(body="<h1>404 Not Found</h1> Nobody here but us fish...glug glug.") return resp
def test_expire_one_year(self): import datetime from tattoo.utility import expire_one_year nowish = datetime.datetime.now() delta = expire_one_year()-nowish self.assertEquals(delta.days, 365)