@@ -35,6 +35,11 @@ def setup_method(self, method):
35
35
# installed
36
36
self .url = reverse ('search_api' )
37
37
38
+ @pytest .fixture (autouse = True )
39
+ def setup_settings (self , settings ):
40
+ settings .PUBLIC_DOMAIN = 'readthedocs.io'
41
+ settings .USE_SUBDOMAIN = True
42
+
38
43
def get_search (self , api_client , search_params ):
39
44
return api_client .get (self .url , search_params )
40
45
@@ -260,7 +265,8 @@ def test_doc_search_subprojects(self, api_client, all_projects):
260
265
assert first_result ['project' ] == subproject .slug
261
266
# Check the link is the subproject document link
262
267
document_link = subproject .get_docs_url (version_slug = version .slug )
263
- assert document_link in first_result ['link' ]
268
+ link = first_result ['domain' ] + first_result ['path' ]
269
+ assert document_link in link
264
270
265
271
def test_doc_search_unexisting_project (self , api_client ):
266
272
project = 'notfound'
@@ -360,7 +366,7 @@ def test_search_correct_link_for_normal_page_html_projects(self, api_client, doc
360
366
361
367
result = resp .data ['results' ][0 ]
362
368
assert result ['project' ] == project .slug
363
- assert result ['link' ]. endswith ( ' en/latest/support.html')
369
+ assert result ['path' ] == '/ en/latest/support.html'
364
370
365
371
@pytest .mark .parametrize ('doctype' , [SPHINX , SPHINX_SINGLEHTML , MKDOCS_HTML ])
366
372
def test_search_correct_link_for_index_page_html_projects (self , api_client , doctype ):
@@ -378,7 +384,7 @@ def test_search_correct_link_for_index_page_html_projects(self, api_client, doct
378
384
379
385
result = resp .data ['results' ][0 ]
380
386
assert result ['project' ] == project .slug
381
- assert result ['link' ]. endswith ( ' en/latest/index.html')
387
+ assert result ['path' ] == '/ en/latest/index.html'
382
388
383
389
@pytest .mark .parametrize ('doctype' , [SPHINX , SPHINX_SINGLEHTML , MKDOCS_HTML ])
384
390
def test_search_correct_link_for_index_page_subdirectory_html_projects (self , api_client , doctype ):
@@ -396,7 +402,7 @@ def test_search_correct_link_for_index_page_subdirectory_html_projects(self, api
396
402
397
403
result = resp .data ['results' ][0 ]
398
404
assert result ['project' ] == project .slug
399
- assert result ['link' ]. endswith ( ' en/latest/guides/index.html')
405
+ assert result ['path' ] == '/ en/latest/guides/index.html'
400
406
401
407
@pytest .mark .parametrize ('doctype' , [SPHINX_HTMLDIR , MKDOCS ])
402
408
def test_search_correct_link_for_normal_page_htmldir_projects (self , api_client , doctype ):
@@ -414,7 +420,7 @@ def test_search_correct_link_for_normal_page_htmldir_projects(self, api_client,
414
420
415
421
result = resp .data ['results' ][0 ]
416
422
assert result ['project' ] == project .slug
417
- assert result ['link' ]. endswith ( ' en/latest/support.html')
423
+ assert result ['path' ] == '/ en/latest/support.html'
418
424
419
425
@pytest .mark .parametrize ('doctype' , [SPHINX_HTMLDIR , MKDOCS ])
420
426
def test_search_correct_link_for_index_page_htmldir_projects (self , api_client , doctype ):
@@ -432,7 +438,7 @@ def test_search_correct_link_for_index_page_htmldir_projects(self, api_client, d
432
438
433
439
result = resp .data ['results' ][0 ]
434
440
assert result ['project' ] == project .slug
435
- assert result ['link' ]. endswith ( ' en/latest/')
441
+ assert result ['path' ] == '/ en/latest/'
436
442
437
443
@pytest .mark .parametrize ('doctype' , [SPHINX_HTMLDIR , MKDOCS ])
438
444
def test_search_correct_link_for_index_page_subdirectory_htmldir_projects (self , api_client , doctype ):
@@ -450,7 +456,7 @@ def test_search_correct_link_for_index_page_subdirectory_htmldir_projects(self,
450
456
451
457
result = resp .data ['results' ][0 ]
452
458
assert result ['project' ] == project .slug
453
- assert result ['link' ]. endswith ( ' en/latest/guides/')
459
+ assert result ['path' ] == '/ en/latest/guides/'
454
460
455
461
def test_search_advanced_query_detection (self , api_client ):
456
462
project = Project .objects .get (slug = 'docs' )
@@ -519,8 +525,8 @@ def test_search_custom_ranking(self, api_client):
519
525
520
526
results = resp .data ['results' ]
521
527
assert len (results ) == 2
522
- assert results [0 ]['link' ]. endswith ( '/en/latest/index.html' )
523
- assert results [1 ]['link' ]. endswith ( '/en/latest/guides/index.html' )
528
+ assert results [0 ]['path' ] == '/en/latest/index.html'
529
+ assert results [1 ]['path' ] == '/en/latest/guides/index.html'
524
530
525
531
# Query with a higher rank over guides/index.html
526
532
page_guides .rank = 5
@@ -537,8 +543,8 @@ def test_search_custom_ranking(self, api_client):
537
543
538
544
results = resp .data ['results' ]
539
545
assert len (results ) == 2
540
- assert results [0 ]['link' ]. endswith ( '/en/latest/guides/index.html' )
541
- assert results [1 ]['link' ]. endswith ( '/en/latest/index.html' )
546
+ assert results [0 ]['path' ] == '/en/latest/guides/index.html'
547
+ assert results [1 ]['path' ] == '/en/latest/index.html'
542
548
543
549
# Query with a lower rank over index.html
544
550
page_index .rank = - 2
@@ -558,8 +564,8 @@ def test_search_custom_ranking(self, api_client):
558
564
559
565
results = resp .data ['results' ]
560
566
assert len (results ) == 2
561
- assert results [0 ]['link' ]. endswith ( '/en/latest/guides/index.html' )
562
- assert results [1 ]['link' ]. endswith ( '/en/latest/index.html' )
567
+ assert results [0 ]['path' ] == '/en/latest/guides/index.html'
568
+ assert results [1 ]['path' ] == '/en/latest/index.html'
563
569
564
570
# Query with a lower rank over index.html
565
571
page_index .rank = 3
@@ -579,8 +585,8 @@ def test_search_custom_ranking(self, api_client):
579
585
580
586
results = resp .data ['results' ]
581
587
assert len (results ) == 2
582
- assert results [0 ]['link' ]. endswith ( '/en/latest/guides/index.html' )
583
- assert results [1 ]['link' ]. endswith ( '/en/latest/index.html' )
588
+ assert results [0 ]['path' ] == '/en/latest/guides/index.html'
589
+ assert results [1 ]['path' ] == '/en/latest/index.html'
584
590
585
591
# Query with a same rank over guides/index.html and index.html
586
592
page_index .rank = - 10
@@ -600,8 +606,8 @@ def test_search_custom_ranking(self, api_client):
600
606
601
607
results = resp .data ['results' ]
602
608
assert len (results ) == 2
603
- assert results [0 ]['link' ]. endswith ( '/en/latest/index.html' )
604
- assert results [1 ]['link' ]. endswith ( '/en/latest/guides/index.html' )
609
+ assert results [0 ]['path' ] == '/en/latest/index.html'
610
+ assert results [1 ]['path' ] == '/en/latest/guides/index.html'
605
611
606
612
607
613
class TestDocumentSearch (BaseTestDocumentSearch ):
0 commit comments