Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
curl -Os https://uploader.codecov.io/latest/linux/codecov
curl -Os https://uploader.codecov.io/latest/linux/codecov.SHA256SUM
curl -Os https://uploader.codecov.io/latest/linux/codecov.SHA256SUM.sig
curl -s https://keybase.io/codecovsecurity/pgp_keys.asc | gpg --no-default-keyring --keyring trustedkeys.gpg --import
curl -fsSL https://uploader.codecov.io/verification.gpg | gpg --no-default-keyring --keyring trustedkeys.gpg --import
gpgv codecov.SHA256SUM.sig codecov.SHA256SUM
shasum -a 256 -c codecov.SHA256SUM
chmod +x ./codecov
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
'pytest-timeout>=2.1.0',
'httpretty==1.0.5',
'psutil>=5.6.3',
'aioresponses>=0.7.3',
'aioresponses==0.7.3',
'sphinx==1.8.5',
'sphinx_rtd_theme',
'jinja2>=3.1.4'
Expand Down
69 changes: 39 additions & 30 deletions tests/test_InfluxDBClientAsync.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import asyncio
import sys

import dateutil.parser
import logging
import math
Expand All @@ -12,7 +14,10 @@
import pandas
import pytest
import warnings
from aioresponses import aioresponses

if sys.version_info < (3, 10):
from aioresponses import aioresponses


from influxdb_client import Point, WritePrecision, BucketsService, OrganizationsService, Organizations
from influxdb_client.client.exceptions import InfluxDBError
Expand Down Expand Up @@ -429,13 +434,15 @@ async def test_username_password_authorization(self):
debug=True)
await self.client.query_api().query("buckets()", "my-org")

@async_test
@aioresponses()
async def test_init_without_token(self, mocked):
mocked.post('http://localhost/api/v2/query?org=my-org', status=200, body='')
await self.client.close()
self.client = InfluxDBClientAsync("http://localhost")
await self.client.query_api().query("buckets()", "my-org")

if sys.version_info < (3, 10):
@async_test
@aioresponses()
async def test_init_without_token(self, mocked):
mocked.post('http://localhost/api/v2/query?org=my-org', status=200, body='')
await self.client.close()
self.client = InfluxDBClientAsync("http://localhost")
await self.client.query_api().query("buckets()", "my-org")

@async_test
async def test_redacted_auth_header(self):
Expand Down Expand Up @@ -465,12 +472,13 @@ async def test_query_and_debug(self):
results = await buckets_service.get_buckets_async()
self.assertIn("my-bucket", list(map(lambda bucket: bucket.name, results.buckets)))

@async_test
@aioresponses()
async def test_parse_csv_with_new_lines_in_column(self, mocked):
await self.client.close()
self.client = InfluxDBClientAsync("http://localhost")
mocked.post('http://localhost/api/v2/query?org=my-org', status=200, body='''#datatype,string,long,dateTime:RFC3339
if sys.version_info < (3, 10):
@async_test
@aioresponses()
async def test_parse_csv_with_new_lines_in_column(self, mocked):
await self.client.close()
self.client = InfluxDBClientAsync("http://localhost")
mocked.post('http://localhost/api/v2/query?org=my-org', status=200, body='''#datatype,string,long,dateTime:RFC3339
#group,false,false,false
#default,_result,,
,result,table,_time
Expand Down Expand Up @@ -499,13 +507,13 @@ async def test_parse_csv_with_new_lines_in_column(self, mocked):
,,1,profiler/operator,*universe.schemaMutationTransformation,keep2,4,1875,42042,64209,16052.25
,,1,profiler/operator,*universe.limitTransformation,limit3,3,1333,38750,47874,15958''')

records = []
await self.client\
.query_api(QueryOptions(profilers=["operator", "query"],
records = []
await self.client\
.query_api(QueryOptions(profilers=["operator", "query"],
profiler_callback=lambda record: records.append(record))) \
.query("buckets()", "my-org")
.query("buckets()", "my-org")

self.assertEqual(4, len(records))
self.assertEqual(4, len(records))

@async_test
async def test_query_exception_propagation(self):
Expand Down Expand Up @@ -534,24 +542,25 @@ async def test_write_exception_propagation(self):
self.assertTrue(re.compile("^v.*").match(headers.get("X-Influxdb-Version")))
self.assertEqual("OSS", headers.get("X-Influxdb-Build"))

@async_test
@aioresponses()
async def test_parse_utf8_two_bytes_character(self, mocked):
await self.client.close()
self.client = InfluxDBClientAsync("http://localhost")
if sys.version_info < (3, 10):
@async_test
@aioresponses()
async def test_parse_utf8_two_bytes_character(self, mocked):
await self.client.close()
self.client = InfluxDBClientAsync("http://localhost")

body = '''#group,false,false,false,false,true,true,true
body = '''#group,false,false,false,false,true,true,true
#datatype,string,long,dateTime:RFC3339,string,string,string,string
#default,_result,,,,,,
,result,table,_time,_value,_field,_measurement,type
'''
for i in range(1000):
body += f",,0,2022-10-13T12:28:31.{i}Z,ÂÂÂ,value,async,error\n"
for i in range(1000):
body += f",,0,2022-10-13T12:28:31.{i}Z,ÂÂÂ,value,async,error\n"

mocked.post('http://localhost/api/v2/query?org=my-org', status=200, body=body)
mocked.post('http://localhost/api/v2/query?org=my-org', status=200, body=body)

data_frame = await self.client.query_api().query_data_frame("from()", "my-org")
self.assertEqual(1000, len(data_frame))
data_frame = await self.client.query_api().query_data_frame("from()", "my-org")
self.assertEqual(1000, len(data_frame))

@async_test
async def test_management_apis(self):
Expand Down
Loading