@@ -284,6 +284,51 @@ def test_get_url_status__local_page(plugin):
284
284
set (), files ) == 0
285
285
286
286
287
+ def test_get_url_status__local_page_with_directory_urls (plugin ):
288
+ index_page = Mock (spec = Page , markdown = '# Heading\n Content' )
289
+ page1_page = Mock (spec = Page , markdown = '# Page One\n ## Sub Heading\n Content' )
290
+ special_char_page = Mock (spec = Page , markdown = '# Heading éèà\n ## Sub Heading éèà\n Content' )
291
+ mock_files = Files ([
292
+ Mock (spec = File , src_path = 'index.md' , dest_path = 'index/index.html' ,
293
+ dest_uri = 'index/index.html' , url = 'index/' , src_uri = 'index.md' ,
294
+ page = index_page ),
295
+ Mock (spec = File , src_path = 'page1.md' , dest_path = 'page1/index.html' ,
296
+ dest_uri = 'page1/index.html' , url = 'page1/' , src_uri = 'page1.md' ,
297
+ page = page1_page ),
298
+ Mock (spec = File , src_path = 'Dir éèà/éèà.md' , dest_path = 'Dir éèà/éèà/index.html' ,
299
+ dest_uri = 'Dir éèà/éèà/index.html' ,
300
+ url = 'Dir%20%C3%A9%C3%A8%C3%A0/%C3%A9%C3%A8%C3%A0/' ,
301
+ src_uri = 'Dir éèà/éèà.md' , page = special_char_page ),
302
+ Mock (spec = File , src_path = 'Dir éèà/page1.md' , dest_path = 'Dir éèà/page1/index.html' ,
303
+ dest_uri = 'Dir éèà/page1/index.html' ,
304
+ url = 'Dir%20%C3%A9%C3%A8%C3%A0/page1/' ,
305
+ src_uri = 'Dir%20%C3%A9%C3%A8%C3%A0/page1.md' ,
306
+ page = special_char_page ),
307
+ ])
308
+ files = {}
309
+ files .update ({os .path .normpath (file .url ): file for file in mock_files })
310
+ files .update ({file .src_uri : file for file in mock_files })
311
+
312
+ assert plugin .get_url_status ('../index/' , 'page1.md' , set (), files ) == 0
313
+ assert plugin .get_url_status ('../index/#heading' , 'page1.md' , set (), files ) == 0
314
+ assert plugin .get_url_status ('../index/#bad-heading' , 'page1.md' , set (), files ) == 404
315
+
316
+ assert plugin .get_url_status ('../page1/' , 'page1.md' , set (), files ) == 0
317
+ assert plugin .get_url_status ('../page1/#sub-heading' , 'page1.md' , set (), files ) == 0
318
+ assert plugin .get_url_status ('../page1/#heading' , 'page1.md' , set (), files ) == 404
319
+
320
+ assert plugin .get_url_status ('../page2/' , 'page1.md' , set (), files ) == 404
321
+ assert plugin .get_url_status ('../page2/#heading' , 'page1.md' , set (), files ) == 404
322
+
323
+ assert plugin .get_url_status (
324
+ '../Dir%20%C3%A9%C3%A8%C3%A0/%C3%A9%C3%A8%C3%A0/#sub-heading-eea' ,
325
+ 'page1.md' , set (), files ) == 0
326
+ assert plugin .get_url_status (
327
+ '../%C3%A9%C3%A8%C3%A0/#sub-heading-eea' ,
328
+ 'Dir%20%C3%A9%C3%A8%C3%A0/page1.md' ,
329
+ set (), files ) == 0
330
+
331
+
287
332
def test_get_url_status__non_markdown_page (plugin ):
288
333
index_page = Mock (spec = Page , markdown = '# Heading\n Content' )
289
334
mock_files = Files ([
@@ -293,6 +338,9 @@ def test_get_url_status__non_markdown_page(plugin):
293
338
Mock (spec = File , src_path = 'drawing.svg' , dest_path = 'drawing.svg' ,
294
339
dest_uri = 'index.html' , url = 'drawing.svg' , src_uri = 'drawing.svg' ,
295
340
page = None ),
341
+ Mock (spec = File , src_path = 'page.html' , dest_path = 'page.html' ,
342
+ dest_uri = 'page.html' , url = 'page.html' , src_uri = 'page.html' ,
343
+ page = None ),
296
344
])
297
345
files = {}
298
346
files .update ({os .path .normpath (file .url ): file for file in mock_files })
@@ -302,6 +350,9 @@ def test_get_url_status__non_markdown_page(plugin):
302
350
assert plugin .get_url_status ('/drawing.svg' , 'index.md' , set (), files ) == 0
303
351
assert plugin .get_url_status ('not-existing.svg' , 'index.md' , set (), files ) == 404
304
352
353
+ assert plugin .get_url_status ('page.html' , 'index.md' , set (), files ) == 0
354
+ assert plugin .get_url_status ('page.html#heading' , 'index.md' , set (), files ) == 0 # no validation for non-markdown pages
355
+
305
356
306
357
def test_get_url_status__local_page_nested (plugin ):
307
358
index_page = Mock (spec = Page , markdown = '# Heading\n Content' )
0 commit comments