@@ -189,17 +189,49 @@ def test_custom_robots_txt(self, storage_mock):
189
189
def test_directory_indexes (self , storage_mock ):
190
190
self .project .versions .update (active = True , built = True )
191
191
storage_mock ()().exists .return_value = True
192
- storage_mock ()().open ().read .return_value = 'foo'
193
192
# Confirm we've serving from storage for the `index-exists/index.html` file
194
193
response = self .client .get (
195
194
reverse ('serve_error_404' , kwargs = {'proxito_path' : '/en/latest/index-exists' }),
196
195
HTTP_HOST = 'project.readthedocs.io' ,
197
196
)
198
197
self .assertEqual (
199
- response .content , b'foo'
198
+ response .status_code , 302
200
199
)
201
200
self .assertEqual (
202
- response .status_code , 200
201
+ response ['location' ], '/en/latest/index-exists/' ,
202
+ )
203
+
204
+ @mock .patch ('readthedocs.proxito.views.get_storage_class' )
205
+ def test_directory_indexes_readme_serving (self , storage_mock ):
206
+ self .project .versions .update (active = True , built = True )
207
+
208
+ storage_mock ()().exists .side_effect = [False , True ]
209
+ # Confirm we've serving from storage for the `index-exists/index.html` file
210
+ response = self .client .get (
211
+ reverse ('serve_error_404' , kwargs = {'proxito_path' : '/en/latest/readme-exists' }),
212
+ HTTP_HOST = 'project.readthedocs.io' ,
213
+ )
214
+ self .assertEqual (
215
+ response .status_code , 302
216
+ )
217
+ self .assertEqual (
218
+ response ['location' ], '/en/latest/readme-exists/README.html' ,
219
+ )
220
+
221
+ @mock .patch ('readthedocs.proxito.views.get_storage_class' )
222
+ def test_directory_indexes_get_args (self , storage_mock ):
223
+ self .project .versions .update (active = True , built = True )
224
+ storage_mock ()().exists .return_value = True
225
+ # Confirm we've serving from storage for the `index-exists/index.html` file
226
+ response = self .client .get (
227
+ reverse ('serve_error_404' , kwargs = {'proxito_path' : '/en/latest/index-exists?foo=bar' }),
228
+ HTTP_HOST = 'project.readthedocs.io' ,
229
+ )
230
+ self .assertEqual (
231
+ response .status_code , 302
232
+ )
233
+ self .assertEqual (
234
+ response ['location' ], '/en/latest/index-exists/?foo=bar' ,
203
235
)
204
236
205
237
@mock .patch ('readthedocs.proxito.views.get_storage_class' )
0 commit comments