@@ -152,7 +152,7 @@ def req(self, headers):
152
152
return self .c .cached_request (mock_request )
153
153
154
154
def test_cache_request_no_headers (self ):
155
- cached_resp = Mock (headers = {"ETag" : "jfd9094r808" , "Content-Length" : 100 })
155
+ cached_resp = Mock (headers = {"ETag" : "jfd9094r808" , "Content-Length" : 100 }, status = 200 )
156
156
self .c .cache = DictCache ({self .url : cached_resp })
157
157
resp = self .req ({})
158
158
assert not resp
@@ -179,7 +179,7 @@ def test_cache_request_not_in_cache(self):
179
179
180
180
def test_cache_request_fresh_max_age (self ):
181
181
now = time .strftime (TIME_FMT , time .gmtime ())
182
- resp = Mock (headers = {"cache-control" : "max-age=3600" , "date" : now })
182
+ resp = Mock (headers = {"cache-control" : "max-age=3600" , "date" : now }, status = 200 )
183
183
184
184
cache = DictCache ({self .url : resp })
185
185
self .c .cache = cache
@@ -189,7 +189,7 @@ def test_cache_request_fresh_max_age(self):
189
189
def test_cache_request_unfresh_max_age (self ):
190
190
earlier = time .time () - 3700 # epoch - 1h01m40s
191
191
now = time .strftime (TIME_FMT , time .gmtime (earlier ))
192
- resp = Mock (headers = {"cache-control" : "max-age=3600" , "date" : now })
192
+ resp = Mock (headers = {"cache-control" : "max-age=3600" , "date" : now }, status = 200 )
193
193
self .c .cache = DictCache ({self .url : resp })
194
194
r = self .req ({})
195
195
assert not r
@@ -198,7 +198,7 @@ def test_cache_request_fresh_expires(self):
198
198
later = time .time () + 86400 # GMT + 1 day
199
199
expires = time .strftime (TIME_FMT , time .gmtime (later ))
200
200
now = time .strftime (TIME_FMT , time .gmtime ())
201
- resp = Mock (headers = {"expires" : expires , "date" : now })
201
+ resp = Mock (headers = {"expires" : expires , "date" : now }, status = 200 )
202
202
cache = DictCache ({self .url : resp })
203
203
self .c .cache = cache
204
204
r = self .req ({})
@@ -208,7 +208,7 @@ def test_cache_request_unfresh_expires(self):
208
208
sooner = time .time () - 86400 # GMT - 1 day
209
209
expires = time .strftime (TIME_FMT , time .gmtime (sooner ))
210
210
now = time .strftime (TIME_FMT , time .gmtime ())
211
- resp = Mock (headers = {"expires" : expires , "date" : now })
211
+ resp = Mock (headers = {"expires" : expires , "date" : now }, status = 200 )
212
212
cache = DictCache ({self .url : resp })
213
213
self .c .cache = cache
214
214
r = self .req ({})
@@ -217,7 +217,7 @@ def test_cache_request_unfresh_expires(self):
217
217
def test_cached_request_with_bad_max_age_headers_not_returned (self ):
218
218
now = time .strftime (TIME_FMT , time .gmtime ())
219
219
# Not a valid header; this would be from a misconfigured server
220
- resp = Mock (headers = {"cache-control" : "max-age=xxx" , "date" : now })
220
+ resp = Mock (headers = {"cache-control" : "max-age=xxx" , "date" : now }, status = 200 )
221
221
222
222
self .c .cache = DictCache ({self .url : resp })
223
223
0 commit comments