[fix] resolve query_parts regression

This commit is contained in:
Adam Tauber 2020-10-26 13:33:40 +01:00
parent 0a44fa8bb7
commit 2aef38c3b9
2 changed files with 15 additions and 14 deletions

View File

@ -59,8 +59,6 @@ class RawTextQuery:
# part does only contain spaces, skip # part does only contain spaces, skip
if query_part.isspace()\ if query_part.isspace()\
or query_part == '': or query_part == '':
searx_query_part = True
self.query_parts.append(query_part)
continue continue
# this force the timeout # this force the timeout
@ -147,8 +145,9 @@ class RawTextQuery:
self.specific = True self.specific = True
# append query part to query_part list # append query part to query_part list
if searx_query_part:
self.query_parts.append(query_part) self.query_parts.append(query_part)
if not searx_query_part: else:
self.user_query_parts.append(query_part) self.user_query_parts.append(query_part)
def changeQuery(self, query): def changeQuery(self, query):
@ -160,4 +159,4 @@ class RawTextQuery:
def getFullQuery(self): def getFullQuery(self):
# get full querry including whitespaces # get full querry including whitespaces
return ''.join(self.query_parts) return '{0} {1}'.format(''.join(self.query_parts), self.getQuery()).strip()

View File

@ -9,7 +9,8 @@ class TestQuery(SearxTestCase):
query = RawTextQuery(query_text, []) query = RawTextQuery(query_text, [])
self.assertEqual(query.getFullQuery(), query_text) self.assertEqual(query.getFullQuery(), query_text)
self.assertEqual(len(query.query_parts), 3) self.assertEqual(len(query.query_parts), 0)
self.assertEqual(len(query.user_query_parts), 2)
self.assertEqual(len(query.languages), 0) self.assertEqual(len(query.languages), 0)
self.assertFalse(query.specific) self.assertFalse(query.specific)
@ -20,7 +21,7 @@ class TestQuery(SearxTestCase):
query = RawTextQuery(full_query, []) query = RawTextQuery(full_query, [])
self.assertEqual(query.getFullQuery(), full_query) self.assertEqual(query.getFullQuery(), full_query)
self.assertEqual(len(query.query_parts), 5) self.assertEqual(len(query.query_parts), 1)
self.assertEqual(len(query.languages), 1) self.assertEqual(len(query.languages), 1)
self.assertIn(language, query.languages) self.assertIn(language, query.languages)
self.assertFalse(query.specific) self.assertFalse(query.specific)
@ -32,7 +33,7 @@ class TestQuery(SearxTestCase):
query = RawTextQuery(full_query, []) query = RawTextQuery(full_query, [])
self.assertEqual(query.getFullQuery(), full_query) self.assertEqual(query.getFullQuery(), full_query)
self.assertEqual(len(query.query_parts), 5) self.assertEqual(len(query.query_parts), 1)
self.assertIn('en', query.languages) self.assertIn('en', query.languages)
self.assertFalse(query.specific) self.assertFalse(query.specific)
@ -43,7 +44,7 @@ class TestQuery(SearxTestCase):
query = RawTextQuery(full_query, []) query = RawTextQuery(full_query, [])
self.assertEqual(query.getFullQuery(), full_query) self.assertEqual(query.getFullQuery(), full_query)
self.assertEqual(len(query.query_parts), 5) self.assertEqual(len(query.query_parts), 1)
self.assertIn('all', query.languages) self.assertIn('all', query.languages)
self.assertFalse(query.specific) self.assertFalse(query.specific)
@ -54,7 +55,7 @@ class TestQuery(SearxTestCase):
query = RawTextQuery(full_query, []) query = RawTextQuery(full_query, [])
self.assertEqual(query.getFullQuery(), full_query) self.assertEqual(query.getFullQuery(), full_query)
self.assertEqual(len(query.query_parts), 5) self.assertEqual(len(query.query_parts), 0)
self.assertEqual(len(query.languages), 0) self.assertEqual(len(query.languages), 0)
self.assertFalse(query.specific) self.assertFalse(query.specific)
@ -63,7 +64,7 @@ class TestQuery(SearxTestCase):
query = RawTextQuery(query_text, []) query = RawTextQuery(query_text, [])
self.assertEqual(query.getFullQuery(), query_text) self.assertEqual(query.getFullQuery(), query_text)
self.assertEqual(len(query.query_parts), 5) self.assertEqual(len(query.query_parts), 1)
self.assertEqual(query.timeout_limit, 3) self.assertEqual(query.timeout_limit, 3)
self.assertFalse(query.specific) self.assertFalse(query.specific)
@ -72,7 +73,7 @@ class TestQuery(SearxTestCase):
query = RawTextQuery(query_text, []) query = RawTextQuery(query_text, [])
self.assertEqual(query.getFullQuery(), query_text) self.assertEqual(query.getFullQuery(), query_text)
self.assertEqual(len(query.query_parts), 5) self.assertEqual(len(query.query_parts), 1)
self.assertEqual(query.timeout_limit, 0.35) self.assertEqual(query.timeout_limit, 0.35)
self.assertFalse(query.specific) self.assertFalse(query.specific)
@ -81,7 +82,7 @@ class TestQuery(SearxTestCase):
query = RawTextQuery(query_text, []) query = RawTextQuery(query_text, [])
self.assertEqual(query.getFullQuery(), query_text) self.assertEqual(query.getFullQuery(), query_text)
self.assertEqual(len(query.query_parts), 5) self.assertEqual(len(query.query_parts), 1)
self.assertEqual(query.timeout_limit, 3.5) self.assertEqual(query.timeout_limit, 3.5)
self.assertFalse(query.specific) self.assertFalse(query.specific)
@ -91,6 +92,7 @@ class TestQuery(SearxTestCase):
query = RawTextQuery(query_text, []) query = RawTextQuery(query_text, [])
self.assertEqual(query.getFullQuery(), query_text) self.assertEqual(query.getFullQuery(), query_text)
self.assertEqual(len(query.query_parts), 5) self.assertEqual(len(query.query_parts), 0)
self.assertEqual(query.getQuery(), query_text)
self.assertEqual(query.timeout_limit, None) self.assertEqual(query.timeout_limit, None)
self.assertFalse(query.specific) self.assertFalse(query.specific)