Esempio n. 1
0
 def test_get_data_db_client_dispatcher_not_influxdb(self, mock_parser):
     mock_parser.ConfigParser().get.return_value = 'file'
     # reset exception to avoid
     # TypeError: catching classes that do not inherit from BaseException
     mock_parser.NoOptionError = ConfigParser.NoOptionError
     try:
         influx.get_data_db_client()
     except Exception as e:
         self.assertIsInstance(e, RuntimeError)
Esempio n. 2
0
    def test_get_data_db_client_parsing_error(self, mock_parser,
                                              mock_get_client):
        _mock_parser = mock.Mock()
        mock_parser.return_value = _mock_parser
        mock_parser.NoOptionError = configparser.NoOptionError
        mock_get_client.side_effect = configparser.NoOptionError(
            'option', 'section')
        with self.assertRaises(configparser.NoOptionError):
            influx.get_data_db_client()

        _mock_parser.read.assert_called_once_with(constants.CONF_FILE)
        mock_get_client.assert_called_once_with(_mock_parser)
Esempio n. 3
0
    def test_get_data_db_client(self, mock_parser, mock_get_client):
        _mock_parser = mock.Mock()
        mock_parser.return_value = _mock_parser

        self.assertEqual('fake_client', influx.get_data_db_client())
        _mock_parser.read.assert_called_once_with(constants.CONF_FILE)
        mock_get_client.assert_called_once_with(_mock_parser)
Esempio n. 4
0
def _config_influxdb():
    try:
        client = influx.get_data_db_client()
        client.create_user(config.USER, config.PASSWORD, config.DATABASE)
        client.create_database(config.DATABASE)
        logger.info('Success to config influxDB')
    except Exception as e:
        logger.debug('Failed to config influxDB: %s', e)
Esempio n. 5
0
 def _config_influxdb(self):
     try:
         client = influx.get_data_db_client()
         client.create_user(consts.INFLUXDB_USER, consts.INFLUXDB_PASS,
                            consts.INFLUXDB_DB_NAME)
         client.create_database(consts.INFLUXDB_DB_NAME)
         LOG.info('Success to config influxDB')
     except HTTPError:
         LOG.exception('Config influxdb failed')
Esempio n. 6
0
def _config_influxdb():
    try:
        client = influx.get_data_db_client()
        client.create_user(consts.INFLUXDB_USER, consts.INFLUXDB_PASS,
                           consts.INFLUXDB_DB_NAME)
        client.create_database(consts.INFLUXDB_DB_NAME)
        logger.info('Success to config influxDB')
    except Exception as e:
        logger.debug('Failed to config influxDB: %s', e)
Esempio n. 7
0
 def _config_influxdb(self):
     try:
         client = influx.get_data_db_client()
         client.create_user(consts.INFLUXDB_USER,
                            consts.INFLUXDB_PASS,
                            consts.INFLUXDB_DB_NAME)
         client.create_database(consts.INFLUXDB_DB_NAME)
         LOG.info('Success to config influxDB')
     except HTTPError:
         LOG.exception('Config influxdb failed')