Пример #1
0
def test_invalid_output_format(client):
    with pytest.raises(ValueError) as e:
        client.output = utils.random_string()
    logger.error(e)
    if pd is None:
        with pytest.raises(ValueError) as e:
            client.output = 'dataframe'
        logger.error(e)
Пример #2
0
async def test_invalid_data_write_dataframe(client):
    with pytest.raises(ValueError) as e:
        # Non-DatetimeIndex DataFrame
        await client.write(utils.random_dataframe().reset_index(), measurement='foo')
    logger.error(e)

    with pytest.raises(ValueError) as e:
        # DataFrame write without specifying measurement
        await client.write(utils.random_dataframe())
    logger.error(e)
Пример #3
0
async def test_invalid_data_write(client):
    with pytest.raises(InfluxDBWriteError) as e:
        # Plain invalid data
        await client.write(utils.random_string())
    logger.error(e)

    with pytest.raises(ValueError) as e:
        # Pass function as input data
        await client.write(utils.random_string)
    logger.error(e)

    with pytest.raises(ValueError) as e:
        # Measurement missing
        point = utils.random_point()
        point.pop('measurement')
        await client.write(point)
    logger.error(e)
Пример #4
0
async def test_statement_error(client):
    with pytest.raises(InfluxDBError) as e:
        await client.query('SELECT * FROM my_measurement', db='fake_db')
    logger.error(e)
Пример #5
0
async def test_invalid_query(client):
    with pytest.raises(InfluxDBError) as e:
        await client.query('NOT A VALID QUERY')
    logger.error(e)
Пример #6
0
def test_no_default_database_warning():
    with pytest.warns(UserWarning) as e:
        _ = InfluxDBClient(db=None)
    logger.error(e)
Пример #7
0
def test_invalid_client_mode():
    with pytest.raises(ValueError) as e:
        _ = InfluxDBClient(db='mytestdb', mode=utils.random_string())
    logger.error(e)
Пример #8
0
async def test_chunked_query_error(client):
    with pytest.raises(InfluxDBError) as e:
        resp = await client.query('INVALID QUERY', chunked=True, chunk_size=10)
        _ = [i async for i in resp]
    logger.error(e)
Пример #9
0
def test_chunked_dataframe(df_client):
    with pytest.raises(ValueError) as e:
        _ = df_client.query('SELECT * FROM foo', chunked=True)
    logger.error(e)
Пример #10
0
def test_invalid_timestamp_parsing2():
    with pytest.raises(ValueError) as e:
        _serialize_timestamp({'time': 'foo'})
    logger.error(e)
Пример #11
0
async def test_async_chunked_dataframe(df_client):
    df_client.mode = 'async'
    with pytest.raises(ValueError) as e:
        _ = await df_client.query('SELECT * FROM foo', chunked=True)
    logger.error(e)
    df_client.mode = 'blocking'