def mocked_get(url, params, **options): assert 'supersearch' in url if 'supersearch/fields' in url: return Response(SUPERSEARCH_FIELDS_MOCKED_RESULTS) # Make sure a negative page does not lead to negative offset value. # But instead it is considered as the page 1 and thus is not added. ok_('_results_offset' not in params) hits = [] for i in range(140): hits.append({ "signature": "nsASDOMWindowEnumerator::GetNext()", "date": "2017-01-31T23:12:57", "uuid": i, "product": "WaterWolf", "version": "1.0", "platform": "Linux", "build_id": 888981 }) return Response({ "hits": hits, "facets": "", "total": len(hits) })
def mocked_get(url, **options): assert '/supersearch/' in url if '/supersearch/fields/' in url: return Response({ 'product': { 'name': 'product', 'namespace': 'processed_crash', 'in_database_name': 'product', 'query_type': 'enum', 'form_field_type': 'MultipleValueField', 'form_field_choices': None, 'permissions_needed': [], 'default_value': None, 'is_exposed': True, 'is_returned': True, 'is_mandatory': False, } }) if '/supersearch/missing_fields/' in url: return Response({ 'hits': [ 'field_a', 'namespace1.field_b', 'namespace2.subspace1.field_c', ], 'total': 3 })
def mocked_get(url, params, **options): assert 'supersearch' in url if 'supersearch/fields' in url: return Response(SUPERSEARCH_FIELDS_MOCKED_RESULTS) # Verify that all expected parameters are in the URL. ok_('product' in params) ok_('WaterWolf' in params['product']) ok_('NightTrain' in params['product']) ok_('address' in params) ok_('0x0' in params['address']) ok_('0xa' in params['address']) ok_('reason' in params) ok_('^hello' in params['reason']) ok_('$thanks' in params['reason']) ok_('java_stack_trace' in params) ok_('Exception' in params['java_stack_trace']) return Response({ "hits": [], "facets": "", "total": 0 })
def mocked_get(url, **params): if today.strftime('%Y%m%d') in url: return Response('Not found', 404) return Response(""" <a href="file.txt">file.txt</a> 2015-08-19 123 <a href="file2.txt">file2.txt</a> 2015-08-19 1 """)
def mocked_get(url, params, **options): assert 'supersearch' in url if 'supersearch/fields' in url: return Response(SUPERSEARCH_FIELDS_MOCKED_RESULTS) if '_facets' in params and 'url' in params['_facets']: facets = { "platform": [{ "term": "Linux", "count": 3 }], "url": [{ "term": "http://example.org", "count": 3 }] } else: facets = {"platform": [{"term": "Linux", "count": 3}]} return Response({ "hits": [{ "signature": "nsASDOMWindowEnumerator::GetNext()", "date": "2017-01-31T23:12:57", "uuid": "aaaaaaaaaaaaa1", "product": "WaterWolf", "version": "1.0", "platform": "Linux", "build_id": 888981, "email": "*****@*****.**", "url": "http://example.org", "exploitability": "high" }, { "signature": "mySignatureIsCool", "date": "2017-01-31T23:12:57", "uuid": "aaaaaaaaaaaaa2", "product": "WaterWolf", "version": "1.0", "platform": "Linux", "build_id": 888981, "email": "*****@*****.**", "url": "http://example.org", "exploitability": "low" }, { "signature": "mineIsCoolerThanYours", "date": "2017-01-31T23:12:57", "uuid": "aaaaaaaaaaaaa3", "product": "WaterWolf", "version": "1.0", "platform": "Linux", "build_id": None, "email": "*****@*****.**", "url": "http://example.org", "exploitability": "error" }], "facets": facets, "total": 3 })
def mocked_get(url, params, **options): assert 'supersearch' in url if 'supersearch/fields' in url: return Response(SUPERSEARCH_FIELDS_MOCKED_RESULTS) return Response()
def mocked_get(url, params, **options): assert 'supersearch' in url if 'supersearch/fields' in url: return Response(SUPERSEARCH_FIELDS_MOCKED_RESULTS) assert '_columns' in params ok_('signature' in params) eq_(params['signature'], ['=' + DUMB_SIGNATURE]) ok_('user_comments' in params) eq_(params['user_comments'], ['!__null__']) if 'product' in params: return SuperSearchResponse( { "hits": [{ "date": "2017-01-31T23:12:57", "uuid": "aaaaaaaaaaaaa1", "product": "WaterWolf", "version": "1.0", "platform": "Linux", "user_comments": "hello there people!", "useragent_locale": "locale1" }, { "date": "2017-01-31T23:12:57", "uuid": "aaaaaaaaaaaaa2", "product": "WaterWolf", "version": "1.0", "platform": "Linux", "user_comments": "I love Mozilla", "useragent_locale": "locale2" }, { "date": "2017-01-31T23:12:57", "uuid": "aaaaaaaaaaaaa3", "product": "WaterWolf", "version": "1.0", "platform": "Linux", "user_comments": "this product is awesome", "useragent_locale": "locale3" }, { "date": "2017-01-31T23:12:57", "uuid": "aaaaaaaaaaaaa4", "product": "WaterWolf", "version": "1.0", "platform": "Linux", "user_comments": "WaterWolf Y U SO GOOD?", "useragent_locale": "locale4" }], "total": 4 }, columns=params['_columns']) return Response({"hits": [], "total": 0})
def mocked_get(url, **options): attempts.append(url) if len(attempts) == 1: return Response('Not found Stuff', status_code=400) if len(attempts) == 2: return Response('Forbidden Stuff', status_code=403) if len(attempts) == 3: return Response('Bad Stuff', status_code=500) if len(attempts) == 4: return Response('Someone elses Bad Stuff', status_code=502)
def mocked_get(url, params, **options): assert 'supersearch' in url if 'supersearch/fields' in url: return Response(SUPERSEARCH_FIELDS_MOCKED_RESULTS) ok_('signature' in params) eq_(params['signature'], '=' + DUMB_SIGNATURE) if 'product' in params: return Response({ "hits": [ { "date": "2017-01-31T23:12:57", "uuid": "aaaaaaaaaaaaa1", "product": "WaterWolf", "version": "1.0", "platform": "Linux", "build_id": 888981 }, { "date": "2017-01-31T23:12:57", "uuid": "aaaaaaaaaaaaa2", "product": "WaterWolf", "version": "1.0", "platform": "Linux", "build_id": 888981 }, { "date": "2017-01-31T23:12:57", "uuid": "aaaaaaaaaaaaa3", "product": "WaterWolf", "version": "1.0", "platform": "Linux", "build_id": None }, { "date": "2017-01-31T23:12:57", "uuid": "aaaaaaaaaaaaa4", "product": "WaterWolf", "version": "1.0", "platform": "Linux", "build_id": None } ], "total": 4 }) return Response({"hits": [], "total": 0})
def mocked_get(url, params, **options): assert '/correlations' in url ok_('report_type' in params) eq_('core-counts', params['report_type']) # 'null' is a perfectly valid JSON response return Response('null')
def mocked_get(url, **options): assert '/supersearch/fields/' in url return Response({ 'signature': { 'name': 'signature', 'namespace': 'processed_crash', 'in_database_name': 'signature', 'query_type': 'str', 'form_field_type': 'StringField', 'form_field_choices': None, 'permissions_needed': [], 'default_value': None, 'is_exposed': True, 'is_returned': True, 'is_mandatory': False, }, 'platform': { 'name': 'platform', 'namespace': 'processed_crash', 'in_database_name': 'platform', 'query_type': 'enum', 'form_field_type': 'MultipleValueField', 'form_field_choices': None, 'permissions_needed': [], 'default_value': None, 'is_exposed': True, 'is_returned': True, 'is_mandatory': False, } })
def mocked_get(url, **options): if '/crontabber_state/' in url: return Response(""" { "state": { "automatic-emails": { "next_run": "2013-04-01T22:20:01+00:00", "first_run": "2013-03-15T16:25:01+00:00", "depends_on": [], "last_run": "2013-04-01T21:20:01+00:00", "last_success": "2013-04-01T20:25:01+00:00", "error_count": 0, "last_error": {} }, "ftpscraper": { "next_run": "2013-04-01T22:20:09+00:00", "first_run": "2013-03-07T07:05:51+00:00", "depends_on": [], "last_run": "2013-04-01T21:20:09+00:00", "last_success": "2013-04-01T21:05:51+00:00", "error_count": 0, "last_error": {} } } } """) raise NotImplementedError(url)
def mocked_post(**options): assert 'bugs' in options['url'], options['url'] return Response(""" {"hits": [], "total": 0 } """)
def mocked_get(url, **options): if '/products/builds/' in url: return Response(""" [ { "product": "Firefox", "repository": "dev", "buildid": 20120625000001, "beta_number": null, "platform": "Mac OS X", "version": "19.0", "date": "2012-06-25", "build_type": "Nightly" }, { "product": "Firefox", "repository": "dev", "buildid": 20120625000003, "beta_number": null, "platform": "BeOS", "version": "5.0a1", "date": "2012-06-25", "build_type": "Beta" } ] """) raise NotImplementedError(url)
def mocked_get(url, **options): if 'signaturesummary' in url: ok_('/report_type/uptime/' in url) ok_('/signature/one%20%26%20two/' in url) ok_('/start_date/2012-01-01/' in url) ok_('/end_date/2013-01-01/' in url) return Response(""" [ { "version_string": "12.0", "percentage": "48.440", "report_count": 52311, "product_name": "Firefox", "category": "XXX" }, { "version_string": "13.0b4", "percentage": "9.244", "report_count": 9983, "product_name": "Firefox", "category": "YYY" } ] """) raise NotImplementedError(url)
def mocked_get(url, **options): if '/crontabber_state/' in url: return Response(""" { "state": { "automatic-emails": { "next_run": "2013-04-01 22:20:01.736562", "first_run": "2013-03-15 16:25:01.411345", "depends_on": [], "last_run": "2013-04-01 21:20:01.736562", "last_success": "2013-04-01 20:25:01.411369", "error_count": 0, "last_error": {} }, "ftpscraper": { "next_run": "2013-04-01 22:20:09.909384", "first_run": "2013-03-07 07:05:51.650177", "depends_on": [], "last_run": "2013-04-01 21:20:09.909384", "last_success": "2013-04-01 21:05:51.650191", "error_count": 0, "last_error": {} } }, "last_updated": "2013-04-01T21:45:02+00:00" } """) raise NotImplementedError(url)
def mocked_get(url, **options): if 'crashes/daily' in url: return Response(""" { "hits": { "Firefox:19.0": { "2012-10-08": { "product": "Firefox", "adu": 30000, "crash_hadu": 71.099999999999994, "version": "19.0", "report_count": 2133, "date": "2012-10-08" }, "2012-10-02": { "product": "Firefox", "adu": 30000, "crash_hadu": 77.299999999999997, "version": "19.0", "report_count": 2319, "date": "2012-10-02" } } } } """) raise NotImplementedError(url)
def mocked_get(url, **options): if 'crashes/daily' in url: # note that the test below sends in a string as # '2012-1-1' which is valid but lacks the leading # zeros. Because the date is converted to a datetime.date # object and serialized back we'll get it here in this # full format. ok_('from_date/2012-01-01' in url) return Response(""" { "hits": { "Firefox:19.0": { "2012-10-08": { "product": "Firefox", "adu": 30000, "crash_hadu": 71.099999999999994, "version": "19.0", "report_count": 2133, "date": "2012-10-08" }, "2012-10-02": { "product": "Firefox", "adu": 30000, "crash_hadu": 77.299999999999997, "version": "19.0", "report_count": 2319, "date": "2012-10-02" } } } } """) raise NotImplementedError(url)
def mocked_get(url, **options): if 'report/list/' in url: ok_('products/Firefox%2BThunderbird/' in url) ok_('versions/11%2B12/' in url) ok_('build_ids/XYZ/' in url) ok_('signature/one%20%26%20two/' in url) ok_('os/OSX%2BWINDOWS/' in url) ok_('from/2012-01-01T00%3A00%3A00' in url) ok_('to/2013-01-01T00%3A00%3A00' in url) return Response(""" { "hits": [ { "user_comments": null, "address": "0xdeadbeef" }, { "user_comments": null, "address": "0xdeadbeef" } ], "total": 2 } """) raise NotImplementedError(url)
def mocked_get(url, **options): assert 'supersearch' in url # Make sure a negative page does not lead to negative offset value. ok_('_results_offset/-100' not in url) # But instead it is considered as the page 1 and thus is not added. ok_('_results_offset' not in url) hits = [] for i in range(140): hits.append(""" { "signature": "nsASDOMWindowEnumerator::GetNext()", "date": "2017-01-31T23:12:57", "uuid": "%s", "product": "WaterWolf", "version": "1.0", "platform": "Linux", "build_id": 888981 } """ % i) return Response("""{ "hits": [ %s ], "facets": "", "total": %s } """ % (','.join(hits), len(hits)))
def mocked_get(url, params, **options): assert 'supersearch' in url if 'supersearch/fields' in url: return Response(SUPERSEARCH_FIELDS_MOCKED_RESULTS) assert '_columns' in params if '_results_offset' in params: hits_range = range(100, 140) else: hits_range = range(100) hits = [] for i in hits_range: hits.append({ "date": "2017-01-31T23:12:57", "uuid": i, "user_comments": "hi", }) return SuperSearchResponse({ "hits": hits, "total": 140 }, columns=params['_columns'])
def mocked_get(url, **options): recently = timezone.now().isoformat() assert '/crontabber_state/' in url return Response({ 'state': { 'job1': { 'error_count': 1, 'depends_on': [], 'last_run': recently, }, 'job2': { 'error_count': 0, 'depends_on': ['job1'], 'last_run': recently, }, 'job3': { 'error_count': 0, 'depends_on': ['job2'], 'last_run': recently, }, 'job1b': { 'error_count': 0, 'depends_on': [], 'last_run': recently, }, } })
def mocked_get(url, params, **options): assert '/skiplist' in url if ( 'category' in params and 'suffix' == params['category'] and 'rule' in params and 'Bar' == params['rule'] ): return Response(""" { "hits": [ {"category": "suffix", "rule": "Bar"} ], "total": 1 } """) elif 'category' in params and 'suffix' == params['category']: return Response(""" { "hits": [ {"category": "suffix", "rule": "Bar"}, {"category": "suffix", "rule": "Foo"} ], "total": 2 } """) elif 'rule' in params and 'Bar' == params['rule']: return Response(""" { "hits": [ {"category": "prefix", "rule": "Bar"}, {"category": "suffix", "rule": "Bar"} ], "total": 2 } """) else: return Response(""" { "hits": [ {"category": "prefix", "rule": "Bar"}, {"category": "prefix", "rule": "Foo"}, {"category": "suffix", "rule": "Bar"}, {"category": "suffix", "rule": "Foo"} ], "total": 4 } """)
def mocked_get(url, params, **options): if '/graphics_devices' in url: ok_(len(params['vendor_hex']) <= 50) ok_(len(params['adapter_hex']) <= 50) return Response({'hits': [], 'total': 0}) raise NotImplementedError(url)
def mocked_get(url, **options): return Response(""" { "hits": [{"guess": "work"}], "total": 1 } """) raise NotImplementedError(url)
def mocked_get(url, params, **options): if '/supersearch/fields' in url: return Response(SUPERSEARCH_FIELDS_MOCKED_RESULTS) if '/supersearch' in url: ok_('_return_query' in params) ok_('signature' in params) eq_(params['signature'], ['nsA']) return Response({ "query": { "query": None }, "indices": ["socorro200000", "socorro200001"] }) raise NotImplementedError(url)
def mocked_post(url, **options): assert '/releases/release/' in url, url data = options['data'] eq_(data['product'], 'WaterCat') eq_(data['version'], '19.0') eq_(data['beta_number'], 1) eq_(data['throttle'], 0) return Response(True)
def mocked_get(url, **options): assert 'correlations/report_type' in url return Response(""" { "reason": "EXC_BAD_ACCESS / KERN_INVALID_ADDRESS", "count": 13, "load": "36% (4/11) vs. 26% (47/180) amd64 with 2 cores" } """)
def mocked_get(url, **options): assert 'correlations/signatures' in url return Response(""" { "hits": ["FakeSignature1", "FakeSignature2"], "total": 2 } """)
def mocked_delete(url, params, **options): assert '/skiplist' in url, url ok_('category' in params) eq_('suffix', params['category']) ok_('rule' in params) eq_('Foo', params['rule']) return Response("true")