<s> from datetime import datetime <EOL> from time import mktime <EOL> from email . utils import parsedate <EOL> from circuits . web import Controller <EOL> from . helpers import urlopen <EOL> class Root ( Controller ) : <EOL> def index ( self ) : <EOL> self . expires ( <NUM_LIT> ) <EOL> return "<STR_LIT>" <EOL> def nocache ( self ) : <EOL> self . expires ( <NUM_LIT:0> ) <EOL> return "<STR_LIT>" <EOL> def test ( webapp ) : <EOL> f = urlopen ( webapp . server . http . base ) <EOL> s = f . read ( ) <EOL> assert s == b"<STR_LIT>" <EOL> expires = f . headers [ "<STR_LIT>" ] <EOL> diff = ( mktime ( parsedate ( expires ) ) - mktime ( datetime . utcnow ( ) . timetuple ( ) ) ) <EOL> assert <NUM_LIT> - ( <NUM_LIT> * <NUM_LIT:0.1> ) < diff < <NUM_LIT> + ( <NUM_LIT> * <NUM_LIT:0.1> ) <EOL> def test_nocache ( webapp ) : <EOL> f = urlopen ( "<STR_LIT>" % webapp . server . http . base ) <EOL> s = f . read ( ) <EOL> assert s == b"<STR_LIT>" <EOL> expires = f . headers [ "<STR_LIT>" ] <EOL> pragma = f . headers [ "<STR_LIT>" ] <EOL> cacheControl = f . headers [ "<STR_LIT>" ] <EOL> now = datetime . utcnow ( ) <EOL> lastyear = now . replace ( year = now . year - <NUM_LIT:1> ) <EOL> diff = ( mktime ( parsedate ( expires ) ) - mktime ( lastyear . utctimetuple ( ) ) ) <EOL> assert diff < <NUM_LIT:1.0> <EOL> assert pragma == "<STR_LIT>" <EOL> assert cacheControl == "<STR_LIT>" </s>
