Skip to content
Browse files

Merge pull request #318 from AdrianGaudebert/849897-plugin-query-type…

…-compat

Fixes bug 849897 - Fixed backward compatibility in search modes.
  • Loading branch information...
2 parents 5242b11 + 0ad3a3e commit de6fdeff7e4bc92004d4a6f2641046c62ac6012c @adngdb adngdb committed Apr 3, 2013
Showing with 43 additions and 15 deletions.
  1. +28 −0 crashstats/crashstats/tests/test_views.py
  2. +6 −14 crashstats/crashstats/views.py
  3. +9 −1 crashstats/settings/base.py
View
28 crashstats/crashstats/tests/test_views.py
@@ -1241,6 +1241,23 @@ def mocked_get(url, **options):
} """)
elif 'products/Thunderbird' in url:
return Response('{"hits": [], "total": 0}')
+ elif 'products/Camino' in url:
+ self.assertTrue('plugin_search_mode/is_exactly' in url)
+ return Response("""
+ {"hits": [
+ {
+ "count": 586,
+ "signature": "nsASDOMWindowEnumerator::GetNext()",
+ "numcontent": 0,
+ "is_windows": 586,
+ "is_linux": 0,
+ "numplugin": 0,
+ "is_mac": 0,
+ "numhang": 0
+ }],
+ "total": 1
+ }
+ """)
else:
return Response("""
{"hits": [
@@ -1367,6 +1384,17 @@ def mocked_get(url, **options):
ok_('table id="signatureList"' in response.content)
ok_('nsASDOMWindowEnumerator::GetNext()' in response.content)
+ # Test that old query types are changed
+ response = self.client.get(url, {
+ 'do_query': 1,
+ 'product': 'Camino',
+ 'plugin_query_type': 'exact'
+ })
+ eq_(response.status_code, 200)
+ ok_('<h2>Query Results</h2>' in response.content)
+ ok_('table id="signatureList"' in response.content)
+ ok_('nsASDOMWindowEnumerator::GetNext()' in response.content)
+
@mock.patch('requests.post')
@mock.patch('requests.get')
def test_query_summary(self, rget, rpost):
View
20 crashstats/crashstats/views.py
@@ -914,13 +914,8 @@ def report_list(request):
if form.cleaned_data['plugin_query_type']:
plugin_query_type = form.cleaned_data['plugin_query_type']
- # This is for backward compatibility with the PHP app.
- query_type_map = {
- 'exact': 'is_exactly',
- 'startswith': 'starts_with'
- }
- if (plugin_query_type in query_type_map):
- plugin_query_type = query_type_map[plugin_query_type]
+ if (plugin_query_type in settings.QUERY_TYPES_MAP):
+ plugin_query_type = settings.QUERY_TYPES_MAP[plugin_query_type]
else:
plugin_query_type = settings.QUERY_TYPES[0]
@@ -1166,6 +1161,8 @@ def query(request):
# report/index directly, without running a search.
if form.cleaned_data['query_type']:
query_type = form.cleaned_data['query_type']
+ if (query_type in settings.QUERY_TYPES_MAP):
+ query_type = settings.QUERY_TYPES_MAP[query_type]
else:
query_type = settings.QUERY_TYPES[0]
@@ -1229,13 +1226,8 @@ def query(request):
if form.cleaned_data['plugin_query_type']:
plugin_query_type = form.cleaned_data['plugin_query_type']
- # This is for backward compatibility with the PHP app.
- query_type_map = {
- 'exact': 'is_exactly',
- 'startswith': 'starts_with'
- }
- if (plugin_query_type in query_type_map):
- plugin_query_type = query_type_map[plugin_query_type]
+ if (plugin_query_type in settings.QUERY_TYPES_MAP):
+ plugin_query_type = settings.QUERY_TYPES_MAP[plugin_query_type]
else:
plugin_query_type = settings.QUERY_TYPES[0]
View
10 crashstats/settings/base.py
@@ -179,9 +179,17 @@
'contains',
'is_exactly',
'starts_with',
- 'simple'
+ 'simple',
+ 'exact', # for backward compatibility
+ 'startswith', # for backward compatibility
)
+# This is for backward compatibility with the PHP app.
+QUERY_TYPES_MAP = {
+ 'exact': 'is_exactly',
+ 'startswith': 'starts_with'
+}
+
# Maximum and default range of query that can be run in search
QUERY_RANGE_MAXIMUM_DAYS = 30
QUERY_RANGE_DEFAULT_DAYS = 14

0 comments on commit de6fdef

Please sign in to comment.
Something went wrong with that request. Please try again.