def test_all_daos(self):
        crash_data = ('bogusAppId', 'bogusErrorType', 'bogusCrashHash',
                      'bogusVersion', '2099-09-09', 8008)
        app_id, error_type, crash_hash, version, date, num_crashes = crash_data

        app_load_data = ('2099-09-09', '2107-01-05', 8008)
        start_date, end_date, num_app_loads = app_load_data
        self.verify_fails_on_nonexistent_db(crash_data, app_load_data)

        create_tables()

        self.assertEqual(0, CRErrorHistoryDAO.num_previously_known(app_id, error_type, crash_hash, version, date))
        CRErrorHistoryDAO.set_known_occurrences(app_id, error_type, crash_hash, version, date, num_crashes)
        self.assertEqual(num_crashes, CRErrorHistoryDAO.num_previously_known(app_id, error_type, crash_hash, version,
                                                                             date))
        self.assertEqual(0, CRErrorHistoryDAO.num_previously_known(app_id, error_type, crash_hash, 'bad', date))
        self.assertEqual(0, CRErrorHistoryDAO.num_previously_known(app_id, error_type, crash_hash, version, 'bad'))
        self.assertEqual(0, CRErrorHistoryDAO.num_previously_known(app_id, error_type, 'bad', version, date))
        self.assertEqual(0, CRErrorHistoryDAO.num_previously_known(app_id, 'bad', crash_hash, version, date))
        self.assertEqual(0, CRErrorHistoryDAO.num_previously_known('bad', error_type, crash_hash, version, date))

        self.assertEqual(0, CRAppLoadHistoryDAO.num_previously_known(app_id, start_date, end_date))
        CRAppLoadHistoryDAO.set_known_occurrences(app_id, start_date, end_date, num_app_loads)
        self.assertEqual(num_app_loads, CRAppLoadHistoryDAO.num_previously_known(app_id, start_date, end_date))
        self.assertEqual(0, CRAppLoadHistoryDAO.num_previously_known('bad', start_date, end_date))
        self.assertEqual(0, CRAppLoadHistoryDAO.num_previously_known(app_id, 'bad', end_date))
        self.assertEqual(0, CRAppLoadHistoryDAO.num_previously_known(app_id, start_date, 'bad'))
 def setUp(self):
     super(AppLoadsTestCase, self).setUp()
     create_tables()
 def setUp(self):
     super(CrashesTestCase, self).setUp()
     create_tables()
 def setUp(self):
     super(ExceptionsTestCase, self).setUp()
     create_tables()
    if re.match('^test$', args[0]):
        for tc in (HistoryTestCase, TransactionsTestCase, ExceptionsTestCase,
                   CrashesTestCase, PerformanceTestCase,
                   AppLoadsTestCase, CrittercismClientTestCase,
                   CrittercismModelsTestCase, EtlTestCase):
            suite = unittest.TestLoader().loadTestsFromTestCase(tc)
            unittest.TextTestRunner(verbosity=2).run(suite)
        exit()

    structured_args = {
        'mode': str(args[0]),
        'verbose': bool(len(all_args.flags.all_with('verbose'))),
    }

    create_tables()

    id_list = None
    if len(args) > 1:
        id_list = args[1:]
        puts(colored.blue('Ids: ') + id_list)
        structured_args['ids'] = id_list

    if structured_args['mode'] == 'upload':
        logging.getLogger().info('Beginning Upload app_ids=%s', id_list)
        nrc = NewRelicClient(NR_ACCOUNT_ID, NR_INSERT_KEY)
        for app_id in id_list:
            dispatcher = ETLDispatcher(nrc, app_id)
            dispatcher.handle_etl()

Exemple #6
0
        raise Exception('Invalid Input')

    if re.match('^test$', args[0]):
        for tc in (HistoryTestCase, TransactionsTestCase, ExceptionsTestCase,
                   CrashesTestCase, PerformanceTestCase, AppLoadsTestCase,
                   CrittercismClientTestCase, CrittercismModelsTestCase,
                   EtlTestCase):
            suite = unittest.TestLoader().loadTestsFromTestCase(tc)
            unittest.TextTestRunner(verbosity=2).run(suite)
        exit()

    structured_args = {
        'mode': str(args[0]),
        'verbose': bool(len(all_args.flags.all_with('verbose'))),
    }

    create_tables()

    id_list = None
    if len(args) > 1:
        id_list = args[1:]
        puts(colored.blue('Ids: ') + id_list)
        structured_args['ids'] = id_list

    if structured_args['mode'] == 'upload':
        logging.getLogger().info('Beginning Upload app_ids=%s', id_list)
        nrc = NewRelicClient(NR_ACCOUNT_ID, NR_INSERT_KEY)
        for app_id in id_list:
            dispatcher = ETLDispatcher(nrc, app_id)
            dispatcher.handle_etl()