From 4377572e2d84d696bd2ba11311198330c91df5c2 Mon Sep 17 00:00:00 2001 From: NguyenHoangSon96 Date: Sat, 11 Apr 2026 09:31:27 +0700 Subject: [PATCH] test: fix parser and redirect test case --- influxdb_client/client/flux_csv_parser.py | 10 ++++++++++ tests/test_WriteApi.py | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/influxdb_client/client/flux_csv_parser.py b/influxdb_client/client/flux_csv_parser.py index 99e68094..6d8fa76c 100644 --- a/influxdb_client/client/flux_csv_parser.py +++ b/influxdb_client/client/flux_csv_parser.py @@ -251,6 +251,16 @@ def _prepare_data_frame(self): # We have to create temporary DataFrame because we want to preserve default column values _temp_df = pd.DataFrame(self._data_frame_values) + # This is for backward compatibles reason + # In newer Pandas versions 'string' type will be 'str', in older versions 'string' type will be 'object' + # In newer Pandas versions 'time' will be 'datetime64[us, UTC]', in older versions 'time' + # will be 'datetime64[ns, UTC]' + for column in _temp_df.columns: + if _temp_df[column].dtype.name == 'str': + _temp_df[column] = _temp_df[column].astype(object) + if _temp_df[column].dtype.name == 'datetime64[us, UTC]': + _temp_df[column] = _temp_df[column].astype('datetime64[ns, UTC]') + self._data_frame_values = [] # Custom DataFrame index diff --git a/tests/test_WriteApi.py b/tests/test_WriteApi.py index b2cc7ca7..73832db6 100644 --- a/tests/test_WriteApi.py +++ b/tests/test_WriteApi.py @@ -532,7 +532,8 @@ def test_redirect(self): Retry.DEFAULT.remove_headers_on_redirect = Retry.DEFAULT_REMOVE_HEADERS_ON_REDIRECT self.influxdb_client.close() - self.influxdb_client = InfluxDBClient(url="http://localhost", token="my-token", org="my-org") + retries = Retry(redirect=1, remove_headers_on_redirect=[]) + self.influxdb_client = InfluxDBClient(url="http://localhost", token="my-token", org="my-org", retries=retries) httpretty.register_uri(httpretty.POST, uri="http://localhost2/api/v2/write", status=204) httpretty.register_uri(httpretty.POST, uri="http://localhost/api/v2/write", status=301,