def test_get_list_with_sort(self): now = self.now yesterday = now - datetime.timedelta(days=1) yesterday = datetimeutil.date_to_string(yesterday) report = Report(config=self.config) base_params = { 'signature': 'sig1', 'from_date': yesterday, 'to_date': now, } res = report.get_list(**base_params) # by default it's sorted by date_processed eq_(res['hits'], sorted(res['hits'], key=lambda x: x['date_processed'])) # now sort by 'reason' res = report.get_list(**dict(base_params, sort='reason')) eq_(res['hits'], sorted(res['hits'], key=lambda x: x['reason'])) res = report.get_list(**dict(base_params, sort='reason', reverse=True)) # be default it's sorted by date_processed eq_(res['hits'], sorted(res['hits'], key=lambda x: x['reason'], reverse=True)) assert_raises(BadArgumentError, report.get_list, **dict(base_params, sort='neverheardof'))
def test_get_list_with_sort(self): now = self.now yesterday = now - datetime.timedelta(days=1) yesterday = datetimeutil.date_to_string(yesterday) report = Report(config=self.config) base_params = { 'signature': 'sig1', 'from_date': yesterday, 'to_date': now, } res = report.get_list(**base_params) # by default it's sorted by date_processed eq_( res['hits'], sorted(res['hits'], key=lambda x: x['date_processed']) ) # now sort by 'reason' res = report.get_list(**dict(base_params, sort='reason')) eq_( res['hits'], sorted(res['hits'], key=lambda x: x['reason']) ) res = report.get_list(**dict( base_params, sort='reason', reverse=True )) # be default it's sorted by date_processed eq_( res['hits'], sorted(res['hits'], key=lambda x: x['reason'], reverse=True) ) assert_raises( BadArgumentError, report.get_list, **dict( base_params, sort='neverheardof' ) )
def test_get_list_with_raw_crash(self): now = self.now yesterday = now - datetime.timedelta(days=1) #yesterday = datetimeutil.date_to_string(yesterday) report = Report(config=self.config) base_params = { 'signature': 'sig1', 'from_date': yesterday, 'to_date': now, 'include_raw_crash': True } # Basic test res = report.get_list(**base_params) eq_(res['total'], 5) eq_(len(res['hits']), 5) duplicates_map = dict( (x['uuid'], x['duplicate_of']) for x in res['hits'] if x['duplicate_of'] ) eq_( duplicates_map['60597bdc-5dbe-4409-6b38-4309c0130828'], '60597bdc-5dbe-4409-6b38-4309c0130833' ) # two of them should have a raw crash eq_( len([x for x in res['hits'] if x['raw_crash'] is not None]), 2 ) # the other 3 it's None eq_( len([x for x in res['hits'] if x['raw_crash'] is None]), 3 ) # the two reports with raw crashes are known by the fixtures hits = [x for x in res['hits'] if x['raw_crash'] is not None] hit1, = [x for x in hits if x['reason'] == 'STACK_OVERFLOW'] eq_(hit1['raw_crash'], {'foo': 'bar'}) hit2, = [x for x in hits if x['reason'] == 'SIGFAULT'] eq_(hit2['raw_crash'], {'Name': 'Peter'}) # Test with products and versions params = dict( base_params, products='WaterWolf', versions='WaterWolf:2.0', ) res = report.get_list(**params) eq_(res['total'], 1) eq_(len(res['hits']), 1) hit, = res['hits'] eq_(hit['raw_crash'], {u'Name': u'Peter'}) params = dict( base_params, products='WaterWolf', versions=['WaterWolf:1.0', 'WaterWolf:3.0'], os='win', build_ids='20001212010203', reasons='STACK_OVERFLOW', ) res = report.get_list(**params) eq_(res['total'], 2) eq_(len(res['hits']), 2) hit1, hit2 = res['hits'] eq_(hit1['raw_crash'], None) eq_(hit2['raw_crash'], None) # Test with os, build_ids and reasons params = dict( base_params, products='WaterWolf', versions=['WaterWolf:1.0', 'WaterWolf:3.0'], os='win', build_ids='20001212010203', reasons='STACK_OVERFLOW', ) res = report.get_list(**params) eq_(res['total'], 2) eq_(len(res['hits']), 2) # Test plugins params = dict( base_params, report_process='plugin', plugin_in='filename', plugin_terms='NPSWF', plugin_search_mode='contains', ) res = report.get_list(**params) eq_(res['total'], 1) eq_(len(res['hits']), 1)
def test_get_list(self): now = self.now yesterday = now - datetime.timedelta(days=1) yesterday = datetimeutil.date_to_string(yesterday) report = Report(config=self.config) base_params = { 'signature': 'sig1', 'from_date': yesterday, 'to_date': now, } # Basic test res = report.get_list(**base_params) eq_(res['total'], 5) eq_(len(res['hits']), 5) duplicates_map = dict( (x['uuid'], x['duplicate_of']) for x in res['hits'] if x['duplicate_of'] ) eq_( duplicates_map['60597bdc-5dbe-4409-6b38-4309c0130828'], '60597bdc-5dbe-4409-6b38-4309c0130833' ) # Test with products and versions params = dict( base_params, products='WaterWolf', versions='WaterWolf:2.0', ) res = report.get_list(**params) eq_(res['total'], 1) # Test with os, build_ids and reasons params = dict( base_params, products='WaterWolf', versions=['WaterWolf:1.0', 'WaterWolf:3.0'], os='win', build_ids='20001212010203', reasons='STACK_OVERFLOW', ) res = report.get_list(**params) eq_(res['total'], 2) res_expected = { 'hits': [ { 'hangid': None, 'product': 'WaterWolf', 'os_name': 'Windows NT', 'uuid': '60597bdc-5dbe-4409-6b38-4309c0130831', 'cpu_info': None, 'url': None, 'last_crash': None, 'date_processed': yesterday, 'cpu_name': None, 'uptime': None, 'release_channel': 'Release', 'process_type': 'browser', 'os_version': None, 'reason': 'STACK_OVERFLOW', 'version': '1.0', 'build': '20001212010203', 'install_age': None, 'signature': 'sig1', 'install_time': None, 'duplicate_of': None, 'address': None, 'user_comments': None }, { 'hangid': None, 'product': 'WaterWolf', 'os_name': 'Windows NT', 'uuid': '60597bdc-5dbe-4409-6b38-4309c0130834', 'cpu_info': None, 'url': None, 'last_crash': None, 'date_processed': yesterday, 'cpu_name': None, 'uptime': None, 'release_channel': 'Release', 'process_type': 'plugin', 'os_version': None, 'reason': 'STACK_OVERFLOW', 'version': '3.0', 'build': '20001212010203', 'install_age': None, 'signature': 'sig1', 'install_time': None, 'duplicate_of': None, 'address': None, 'user_comments': None } ], 'total': 2 } eq_(res, res_expected) # Test with a signature with strange characters params = dict( base_params, signature='this/is+a=C|signature', ) res = report.get_list(**params) eq_(res['total'], 1) res_expected = { 'hits': [{ 'hangid': None, 'product': 'WindBear', 'os_name': 'Linux', 'uuid': '60597bdc-5dbe-4409-6b38-4309c0130837', 'cpu_info': None, 'url': None, 'last_crash': None, 'date_processed': yesterday, 'cpu_name': None, 'uptime': None, 'release_channel': 'Release', 'process_type': 'browser', 'os_version': None, 'reason': 'STACK_OVERFLOW', 'version': '1.0', 'build': '20001212010203', 'install_age': None, 'signature': 'this/is+a=C|signature', 'install_time': None, 'duplicate_of': None, 'address': None, 'user_comments': None }], 'total': 1 } eq_(res, res_expected) # Test plugins params = dict( base_params, report_process='plugin', plugin_in='filename', plugin_terms='NPSWF', plugin_search_mode='contains', ) res = report.get_list(**params) eq_(res['total'], 1) # Test plugins with 'starts_with' search mode params = dict( base_params, report_process='plugin', plugin_in='name', plugin_terms='Flash', plugin_search_mode='starts_with', ) res = report.get_list(**params) eq_(res['total'], 1)
def test_get_list_with_raw_crash(self): now = self.now yesterday = now - datetime.timedelta(days=1) report = Report(config=self.config) base_params = { 'signature': 'sig1', 'from_date': yesterday, 'to_date': now, 'include_raw_crash': True } # Basic test res = report.get_list(**base_params) eq_(res['total'], 5) eq_(len(res['hits']), 5) duplicates_map = dict((x['uuid'], x['duplicate_of']) for x in res['hits'] if x['duplicate_of']) eq_(duplicates_map['60597bdc-5dbe-4409-6b38-4309c0130828'], '60597bdc-5dbe-4409-6b38-4309c0130833') # two of them should have a raw crash eq_(len([x for x in res['hits'] if x['raw_crash'] is not None]), 2) # the other 3 it's None eq_(len([x for x in res['hits'] if x['raw_crash'] is None]), 3) # the two reports with raw crashes are known by the fixtures hits = [x for x in res['hits'] if x['raw_crash'] is not None] hit1, = [x for x in hits if x['reason'] == 'STACK_OVERFLOW'] eq_(hit1['raw_crash'], {'foo': 'bar'}) hit2, = [x for x in hits if x['reason'] == 'SIGFAULT'] eq_(hit2['raw_crash'], {'Name': 'Peter'}) # Test with products and versions params = dict( base_params, products='WaterWolf', versions='WaterWolf:2.0', ) res = report.get_list(**params) eq_(res['total'], 1) eq_(len(res['hits']), 1) hit, = res['hits'] eq_(hit['raw_crash'], {u'Name': u'Peter'}) params = dict( base_params, products='WaterWolf', versions=['WaterWolf:1.0', 'WaterWolf:3.0'], os='win', build_ids='20001212010203', reasons='STACK_OVERFLOW', ) res = report.get_list(**params) eq_(res['total'], 2) eq_(len(res['hits']), 2) hit1, hit2 = res['hits'] eq_(hit1['raw_crash'], None) eq_(hit2['raw_crash'], None) # Test with os, build_ids and reasons params = dict( base_params, products='WaterWolf', versions=['WaterWolf:1.0', 'WaterWolf:3.0'], os='win', build_ids='20001212010203', reasons='STACK_OVERFLOW', ) res = report.get_list(**params) eq_(res['total'], 2) eq_(len(res['hits']), 2) # Test plugins params = dict( base_params, report_process='plugin', plugin_in='filename', plugin_terms='NPSWF', plugin_search_mode='contains', ) res = report.get_list(**params) eq_(res['total'], 1) eq_(len(res['hits']), 1)
def test_get_list(self): now = self.now yesterday = now - datetime.timedelta(days=1) yesterday = datetimeutil.date_to_string(yesterday) report = Report(config=self.config) base_params = { 'signature': 'sig1', 'from_date': yesterday, 'to_date': now, } # Basic test res = report.get_list(**base_params) eq_(res['total'], 5) eq_(len(res['hits']), 5) duplicates_map = dict((x['uuid'], x['duplicate_of']) for x in res['hits'] if x['duplicate_of']) eq_(duplicates_map['60597bdc-5dbe-4409-6b38-4309c0130828'], '60597bdc-5dbe-4409-6b38-4309c0130833') # Test with products and versions params = dict( base_params, products='WaterWolf', versions='WaterWolf:2.0', ) res = report.get_list(**params) eq_(res['total'], 1) # Test with os, build_ids and reasons params = dict( base_params, products='WaterWolf', versions=['WaterWolf:1.0', 'WaterWolf:3.0'], os='win', build_ids='20001212010203', reasons='STACK_OVERFLOW', ) res = report.get_list(**params) eq_(res['total'], 2) res_expected = { 'hits': [{ 'hangid': None, 'product': 'WaterWolf', 'os_name': 'Windows NT', 'uuid': '60597bdc-5dbe-4409-6b38-4309c0130831', 'cpu_info': None, 'url': None, 'last_crash': None, 'date_processed': yesterday, 'cpu_name': None, 'uptime': None, 'release_channel': 'Release', 'process_type': 'browser', 'os_version': None, 'reason': 'STACK_OVERFLOW', 'version': '1.0', 'build': '20001212010203', 'install_age': None, 'signature': 'sig1', 'install_time': None, 'duplicate_of': None, 'address': None, 'user_comments': None }, { 'hangid': None, 'product': 'WaterWolf', 'os_name': 'Windows NT', 'uuid': '60597bdc-5dbe-4409-6b38-4309c0130834', 'cpu_info': None, 'url': None, 'last_crash': None, 'date_processed': yesterday, 'cpu_name': None, 'uptime': None, 'release_channel': 'Release', 'process_type': 'plugin', 'os_version': None, 'reason': 'STACK_OVERFLOW', 'version': '3.0', 'build': '20001212010203', 'install_age': None, 'signature': 'sig1', 'install_time': None, 'duplicate_of': None, 'address': None, 'user_comments': None }], 'total': 2 } eq_(res, res_expected) # Test with a signature with strange characters params = dict( base_params, signature='this/is+a=C|signature', ) res = report.get_list(**params) eq_(res['total'], 1) res_expected = { 'hits': [{ 'hangid': None, 'product': 'WindBear', 'os_name': 'Linux', 'uuid': '60597bdc-5dbe-4409-6b38-4309c0130837', 'cpu_info': None, 'url': None, 'last_crash': None, 'date_processed': yesterday, 'cpu_name': None, 'uptime': None, 'release_channel': 'Release', 'process_type': 'browser', 'os_version': None, 'reason': 'STACK_OVERFLOW', 'version': '1.0', 'build': '20001212010203', 'install_age': None, 'signature': 'this/is+a=C|signature', 'install_time': None, 'duplicate_of': None, 'address': None, 'user_comments': None }], 'total': 1 } eq_(res, res_expected) # Test plugins params = dict( base_params, report_process='plugin', plugin_in='filename', plugin_terms='NPSWF', plugin_search_mode='contains', ) res = report.get_list(**params) eq_(res['total'], 1) # Test plugins with 'starts_with' search mode params = dict( base_params, report_process='plugin', plugin_in='name', plugin_terms='Flash', plugin_search_mode='starts_with', ) res = report.get_list(**params) eq_(res['total'], 1)
def test_get_list(self): now = self.now yesterday = now - datetime.timedelta(days=1) yesterday = datetimeutil.date_to_string(yesterday) report = Report(config=self.config) # Test 1 params = { 'signature': 'sig1' } res = report.get_list(**params) self.assertEqual(res['total'], 5) # Test 2 params = { 'signature': 'sig1', 'products': 'WaterWolf', 'versions': 'WaterWolf:2.0' } res = report.get_list(**params) self.assertEqual(res['total'], 1) # Test 3 params = { 'signature': 'sig1', 'products': 'WaterWolf', 'versions': ['WaterWolf:1.0', 'WaterWolf:3.0'], 'os': 'win', 'build_ids': '20001212010203', 'reasons': 'STACK_OVERFLOW' } res = report.get_list(**params) self.assertEqual(res['total'], 2) res_expected = { 'hits': [ { 'hangid': None, 'product': 'WaterWolf', 'os_name': 'Windows NT', 'uuid': '4', 'cpu_info': None, 'url': None, 'last_crash': None, 'date_processed': yesterday, 'cpu_name': None, 'uptime': None, 'process_type': 'browser', 'os_version': None, 'reason': 'STACK_OVERFLOW', 'version': '1.0', 'build': '20001212010203', 'install_age': None, 'signature': 'sig1', 'install_time': None, 'duplicate_of': None, 'address': None, 'user_comments': None }, { 'hangid': None, 'product': 'WaterWolf', 'os_name': 'Windows NT', 'uuid': '7', 'cpu_info': None, 'url': None, 'last_crash': None, 'date_processed': yesterday, 'cpu_name': None, 'uptime': None, 'process_type': 'plugin', 'os_version': None, 'reason': 'STACK_OVERFLOW', 'version': '3.0', 'build': '20001212010203', 'install_age': None, 'signature': 'sig1', 'install_time': None, 'duplicate_of': None, 'address': None, 'user_comments': None } ], 'total': 2 } self.assertEqual(res, res_expected) # Test 5 params = { 'signature': 'this/is+a=C|signature' } res = report.get_list(**params) self.assertEqual(res['total'], 1) res_expected = { 'hits': [{ 'hangid': None, 'product': 'WindBear', 'os_name': 'Linux', 'uuid': '10', 'cpu_info': None, 'url': None, 'last_crash': None, 'date_processed': yesterday, 'cpu_name': None, 'uptime': None, 'process_type': 'browser', 'os_version': None, 'reason': 'STACK_OVERFLOW', 'version': '1.0', 'build': '20001212010203', 'install_age': None, 'signature': 'this/is+a=C|signature', 'install_time': None, 'duplicate_of': None, 'address': None, 'user_comments': None }], 'total': 1 } self.assertEqual(res, res_expected) # Test 6: plugins params = { 'signature': 'sig1', 'report_process': 'plugin', 'plugin_in': 'filename', 'plugin_terms': 'NPSWF', 'plugin_search_mode': 'contains', } res = report.get_list(**params) self.assertEqual(res['total'], 1) # Test 7: plugins params = { 'signature': 'sig1', 'report_process': 'plugin', 'plugin_in': 'name', 'plugin_terms': 'Flash', 'plugin_search_mode': 'starts_with', } res = report.get_list(**params) self.assertEqual(res['total'], 1)
def test_get_list(self): now = datetimeutil.utc_now() yesterday = now - datetime.timedelta(days=1) yesterday = datetimeutil.date_to_string(yesterday) report = Report(config=self.config) # Test 1 params = {'signature': 'sig1'} res = report.get_list(**params) self.assertEqual(res['total'], 5) # Test 2 params = { 'signature': 'sig1', 'products': 'WaterWolf', 'versions': 'WaterWolf:2.0' } res = report.get_list(**params) self.assertEqual(res['total'], 1) # Test 3 params = { 'signature': 'sig1', 'products': 'WaterWolf', 'versions': ['WaterWolf:1.0', 'WaterWolf:3.0'], 'os': 'win', 'build_ids': '20001212010203', 'reasons': 'STACK_OVERFLOW' } res = report.get_list(**params) self.assertEqual(res['total'], 2) res_expected = { 'hits': [{ 'hangid': None, 'product': 'WaterWolf', 'os_name': 'Windows NT', 'uuid': '4', 'cpu_info': None, 'url': None, 'last_crash': None, 'date_processed': yesterday, 'cpu_name': None, 'uptime': None, 'process_type': 'browser', 'os_version': None, 'reason': 'STACK_OVERFLOW', 'version': '1.0', 'build': '20001212010203', 'install_age': None, 'signature': 'sig1', 'install_time': None, 'duplicate_of': None, 'address': None, 'user_comments': None }, { 'hangid': None, 'product': 'WaterWolf', 'os_name': 'Windows NT', 'uuid': '7', 'cpu_info': None, 'url': None, 'last_crash': None, 'date_processed': yesterday, 'cpu_name': None, 'uptime': None, 'process_type': 'plugin', 'os_version': None, 'reason': 'STACK_OVERFLOW', 'version': '3.0', 'build': '20001212010203', 'install_age': None, 'signature': 'sig1', 'install_time': None, 'duplicate_of': None, 'address': None, 'user_comments': None }], 'total': 2 } self.assertEqual(res, res_expected) # Test 5 params = {'signature': 'this/is+a=C|signature'} res = report.get_list(**params) self.assertEqual(res['total'], 1) res_expected = { 'hits': [{ 'hangid': None, 'product': 'WindBear', 'os_name': 'Linux', 'uuid': '10', 'cpu_info': None, 'url': None, 'last_crash': None, 'date_processed': yesterday, 'cpu_name': None, 'uptime': None, 'process_type': 'browser', 'os_version': None, 'reason': 'STACK_OVERFLOW', 'version': '1.0', 'build': '20001212010203', 'install_age': None, 'signature': 'this/is+a=C|signature', 'install_time': None, 'duplicate_of': None, 'address': None, 'user_comments': None }], 'total': 1 } self.assertEqual(res, res_expected) # Test 6: plugins params = { 'signature': 'sig1', 'report_process': 'plugin', 'plugin_in': 'filename', 'plugin_terms': 'NPSWF', 'plugin_search_mode': 'contains', } res = report.get_list(**params) self.assertEqual(res['total'], 1) # Test 7: plugins params = { 'signature': 'sig1', 'report_process': 'plugin', 'plugin_in': 'name', 'plugin_terms': 'Flash', 'plugin_search_mode': 'starts_with', } res = report.get_list(**params) self.assertEqual(res['total'], 1)