def test_invalid_data_write(sync_client): with pytest.raises(InfluxDBError) as e: # Plain invalid data sync_client.write(utils.random_string()) logger.error(e) with pytest.raises(ValueError) as e: # Pass function as input data sync_client.write(utils.random_string) logger.error(e) with pytest.raises(ValueError) as e: # Measurement missing point = utils.random_point() point.pop('measurement') sync_client.write(point) logger.error(e) with pytest.raises(ValueError) as e: # Non-DatetimeIndex DataFrame sync_client.write(utils.random_dataframe().reset_index(), measurement='foo') logger.error(e) with pytest.raises(ValueError) as e: # DataFrame write without specifying measurement sync_client.write(utils.random_dataframe()) logger.error(e)
async def test_chunked_query_error(async_client): with pytest.raises(InfluxDBError) as e: resp = await async_client.query('INVALID QUERY', chunked=True, chunk_size=10) _ = [i async for i in resp] logger.error(e)
def test_invalid_output_format(sync_client): with pytest.raises(ValueError) as e: sync_client.output = utils.random_string() logger.error(e) if pd is None: with pytest.raises(ValueError) as e: sync_client.output = 'dataframe' logger.error(e)
def test_invalid_data_write_dataframe(sync_client): with pytest.raises(ValueError) as e: # Non-DatetimeIndex DataFrame sync_client.write(utils.random_dataframe().reset_index(), measurement='foo') logger.error(e) with pytest.raises(ValueError) as e: # DataFrame write without specifying measurement sync_client.write(utils.random_dataframe()) logger.error(e)
def test_invalid_data_write(sync_client): with pytest.raises(InfluxDBWriteError) as e: # Plain invalid data sync_client.write(utils.random_string()) logger.error(e) with pytest.raises(ValueError) as e: # Pass function as input data sync_client.write(utils.random_string) logger.error(e) with pytest.raises(ValueError) as e: # Measurement missing point = utils.random_point() point.pop('measurement') sync_client.write(point) logger.error(e)
def test_statement_error(sync_client): with pytest.raises(InfluxDBError) as e: sync_client.query('SELECT * FROM my_measurement', db='fake_db') logger.error(e)
def test_missing_kwargs(sync_client): with pytest.raises(ValueError) as e: sync_client.select_all() logger.error(e)
def test_invalid_query(sync_client): with pytest.raises(InfluxDBError) as e: sync_client.query('NOT A VALID QUERY') logger.error(e)
def test_no_default_database_warning(): with pytest.warns(UserWarning) as e: _ = InfluxDBClient(db=None) logger.error(e)
def test_invalid_client_mode(): with pytest.raises(ValueError) as e: _ = InfluxDBClient(db='mytestdb', mode=utils.random_string()) logger.error(e)
async def test_async_chunked_dataframe(df_client): df_client.mode = 'async' with pytest.raises(ValueError) as e: _ = await df_client.select_all('foo', chunked=True) # noqa: F841 logger.error(e) df_client.mode = 'blocking'
def test_chunked_dataframe(df_client): with pytest.raises(ValueError) as e: _ = df_client.select_all('foo', chunked=True) # noqa: F841 logger.error(e)
def test_invalid_timestamp_parsing2(): with pytest.raises(ValueError) as e: _parse_timestamp({'time': 'foo'}) logger.error(e)