8
8
9
9
from readthedocs .builds .constants import LATEST
10
10
from readthedocs .builds .models import Version
11
- from readthedocs .projects .models import Project
11
+ from readthedocs .projects .models import Project , HTMLFile
12
12
from readthedocs .search .tests .utils import get_search_query_from_project_file
13
13
14
14
@@ -72,7 +72,7 @@ def _get_search_result(self, url, client, search_params):
72
72
assert resp .status_code == 200
73
73
74
74
page = pq (resp .content )
75
- result = page .find ('.module-list-wrapper .module -item' )
75
+ result = page .find ('.module-list-wrapper .search-result -item' )
76
76
return result , page
77
77
78
78
@pytest .mark .parametrize ('data_type' , ['content' , 'headers' , 'title' ])
@@ -92,16 +92,26 @@ def test_file_search_case_insensitive(self, client, project, case):
92
92
93
93
It tests with uppercase, lowercase and camelcase
94
94
"""
95
- query = get_search_query_from_project_file (project_slug = project .slug )\
95
+ query_text = get_search_query_from_project_file (project_slug = project .slug )
96
96
97
- cased_query = getattr (query , case )
97
+ cased_query = getattr (query_text , case )
98
+ query = cased_query ()
98
99
99
100
result , _ = self ._get_search_result (url = self .url , client = client ,
100
- search_params = {'q' : cased_query () , 'type' : 'file' })
101
+ search_params = {'q' : query , 'type' : 'file' })
101
102
102
103
assert len (result ) == 1
103
104
# Check the actual text is in the result, not the cased one
104
- assert query in result .text ()
105
+ assert query_text in result .text ()
106
+
107
+ def test_page_search_not_return_removed_page (self , client , project ):
108
+ """Check removed page are not in the search index"""
109
+ query = get_search_query_from_project_file (project_slug = project .slug )
110
+ # Delete all the HTML files of the project
111
+ p = HTMLFile .objects .filter (project = project ).delete ()
112
+ result , _ = self ._get_search_result (url = self .url , client = client ,
113
+ search_params = {'q' : query , 'type' : 'file' })
114
+ assert len (result ) == 0
105
115
106
116
def test_file_search_show_projects (self , client , all_projects ):
107
117
"""Test that search result page shows list of projects while searching for files"""
0 commit comments