@@ -67,7 +67,7 @@ def test_search_project_filter_language(self, client, project):
67
67
68
68
@pytest .mark .django_db
69
69
@pytest .mark .search
70
- class TestElasticSearch (object ):
70
+ class TestPageSearch (object ):
71
71
url = reverse ('search' )
72
72
73
73
def _get_search_result (self , url , client , search_params ):
@@ -80,13 +80,31 @@ def _get_search_result(self, url, client, search_params):
80
80
81
81
@pytest .mark .parametrize ('data_type' , ['content' , 'headers' , 'title' ])
82
82
@pytest .mark .parametrize ('page_num' , [0 , 1 ])
83
- def test_search_by_file_content (self , client , project , data_type , page_num ):
83
+ def test_file_search (self , client , project , data_type , page_num ):
84
84
query = get_search_query_from_project_file (project_slug = project .slug , page_num = page_num ,
85
85
data_type = data_type )
86
86
87
87
result , _ = self ._get_search_result (url = self .url , client = client ,
88
88
search_params = {'q' : query , 'type' : 'file' })
89
- assert len (result ) == 1 , ("failed" + query )
89
+ assert len (result ) == 1
90
+ assert query in result .text ()
91
+
92
+ @pytest .mark .parametrize ('case' , ['upper' , 'lower' , 'title' ])
93
+ def test_file_search_case_insensitive (self , client , project , case ):
94
+ """Check File search is case insensitive
95
+
96
+ It tests with uppercase, lowercase and camelcase
97
+ """
98
+ query = get_search_query_from_project_file (project_slug = project .slug )\
99
+
100
+ cased_query = getattr (query , case )
101
+
102
+ result , _ = self ._get_search_result (url = self .url , client = client ,
103
+ search_params = {'q' : cased_query (), 'type' : 'file' })
104
+
105
+ assert len (result ) == 1
106
+ # Check the actual text is in the result, not the cased one
107
+ assert query in result .text ()
90
108
91
109
def test_file_search_show_projects (self , client , all_projects ):
92
110
"""Test that search result page shows list of projects while searching for files"""
0 commit comments