Skip to content

Commit 4377572

Browse files
test: fix parser and redirect test case
1 parent fb5d3f2 commit 4377572

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

influxdb_client/client/flux_csv_parser.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,16 @@ def _prepare_data_frame(self):
251251

252252
# We have to create temporary DataFrame because we want to preserve default column values
253253
_temp_df = pd.DataFrame(self._data_frame_values)
254+
# This is for backward compatibles reason
255+
# In newer Pandas versions 'string' type will be 'str', in older versions 'string' type will be 'object'
256+
# In newer Pandas versions 'time' will be 'datetime64[us, UTC]', in older versions 'time'
257+
# will be 'datetime64[ns, UTC]'
258+
for column in _temp_df.columns:
259+
if _temp_df[column].dtype.name == 'str':
260+
_temp_df[column] = _temp_df[column].astype(object)
261+
if _temp_df[column].dtype.name == 'datetime64[us, UTC]':
262+
_temp_df[column] = _temp_df[column].astype('datetime64[ns, UTC]')
263+
254264
self._data_frame_values = []
255265

256266
# Custom DataFrame index

tests/test_WriteApi.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,8 @@ def test_redirect(self):
532532
Retry.DEFAULT.remove_headers_on_redirect = Retry.DEFAULT_REMOVE_HEADERS_ON_REDIRECT
533533
self.influxdb_client.close()
534534

535-
self.influxdb_client = InfluxDBClient(url="http://localhost", token="my-token", org="my-org")
535+
retries = Retry(redirect=1, remove_headers_on_redirect=[])
536+
self.influxdb_client = InfluxDBClient(url="http://localhost", token="my-token", org="my-org", retries=retries)
536537

537538
httpretty.register_uri(httpretty.POST, uri="http://localhost2/api/v2/write", status=204)
538539
httpretty.register_uri(httpretty.POST, uri="http://localhost/api/v2/write", status=301,

0 commit comments

Comments
 (0)