@@ -152,7 +152,7 @@ def req(self, headers):
152152 return self .c .cached_request (mock_request )
153153
154154 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 )
156156 self .c .cache = DictCache ({self .url : cached_resp })
157157 resp = self .req ({})
158158 assert not resp
@@ -179,7 +179,7 @@ def test_cache_request_not_in_cache(self):
179179
180180 def test_cache_request_fresh_max_age (self ):
181181 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 )
183183
184184 cache = DictCache ({self .url : resp })
185185 self .c .cache = cache
@@ -189,7 +189,7 @@ def test_cache_request_fresh_max_age(self):
189189 def test_cache_request_unfresh_max_age (self ):
190190 earlier = time .time () - 3700 # epoch - 1h01m40s
191191 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 )
193193 self .c .cache = DictCache ({self .url : resp })
194194 r = self .req ({})
195195 assert not r
@@ -198,7 +198,7 @@ def test_cache_request_fresh_expires(self):
198198 later = time .time () + 86400 # GMT + 1 day
199199 expires = time .strftime (TIME_FMT , time .gmtime (later ))
200200 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 )
202202 cache = DictCache ({self .url : resp })
203203 self .c .cache = cache
204204 r = self .req ({})
@@ -208,7 +208,7 @@ def test_cache_request_unfresh_expires(self):
208208 sooner = time .time () - 86400 # GMT - 1 day
209209 expires = time .strftime (TIME_FMT , time .gmtime (sooner ))
210210 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 )
212212 cache = DictCache ({self .url : resp })
213213 self .c .cache = cache
214214 r = self .req ({})
@@ -217,7 +217,7 @@ def test_cache_request_unfresh_expires(self):
217217 def test_cached_request_with_bad_max_age_headers_not_returned (self ):
218218 now = time .strftime (TIME_FMT , time .gmtime ())
219219 # 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 )
221221
222222 self .c .cache = DictCache ({self .url : resp })
223223
0 commit comments