From 0a8ec5a8f76d3c300c19d3efbad082c4f6c43764 Mon Sep 17 00:00:00 2001 From: Jakub Bednar Date: Thu, 2 May 2024 09:53:19 +0200 Subject: [PATCH 1/4] refactor: to `timezone` specific `datetime` helpers to avoid use deprecated functions --- influxdb_client_3/write_client/client/write/point.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/influxdb_client_3/write_client/client/write/point.py b/influxdb_client_3/write_client/client/write/point.py index e65aee6..bc7211d 100644 --- a/influxdb_client_3/write_client/client/write/point.py +++ b/influxdb_client_3/write_client/client/write/point.py @@ -10,7 +10,7 @@ from influxdb_client_3.write_client.client.util.date_utils import get_date_helper from influxdb_client_3.write_client.domain.write_precision import WritePrecision -EPOCH = datetime.utcfromtimestamp(0).replace(tzinfo=timezone.utc) +EPOCH = datetime.fromtimestamp(0, tz=timezone.utc) DEFAULT_WRITE_PRECISION = WritePrecision.NS From 3b476ebea2641ecbab419fb247a54a6917db034e Mon Sep 17 00:00:00 2001 From: Jakub Bednar Date: Thu, 2 May 2024 09:54:22 +0200 Subject: [PATCH 2/4] docs: update CHANGELOG.md --- CHANGELOG.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 770386b..b7d3e0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,12 @@ ## 0.5.0 [unreleased] +### Bug Fixes + +1. [#86](https://github.com/InfluxCommunity/influxdb3-python/pull/86): Refactor to `timezone` specific `datetime` helpers to avoid use deprecated functions + ### Others -- [#84](https://github.com/InfluxCommunity/influxdb3-python/pull/84): Enable packaging type information - `py.typed` +1. [#84](https://github.com/InfluxCommunity/influxdb3-python/pull/84): Enable packaging type information - `py.typed` ## 0.4.0 [2024-04-17] From ededc00fe88ee824525a3a3827ad814822dd1162 Mon Sep 17 00:00:00 2001 From: Jakub Bednar Date: Thu, 2 May 2024 09:59:27 +0200 Subject: [PATCH 3/4] chore: add test --- tests/test_point.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 tests/test_point.py diff --git a/tests/test_point.py b/tests/test_point.py new file mode 100644 index 0000000..ea59ffd --- /dev/null +++ b/tests/test_point.py @@ -0,0 +1,10 @@ +import datetime +import unittest + +from influxdb_client_3.write_client.client.write.point import EPOCH + + +class TestPoint(unittest.TestCase): + + def test_epoch(self): + self.assertEqual(EPOCH, datetime.datetime(1970, 1, 1, 0, 0, tzinfo=datetime.timezone.utc)) From 124917e3e8f3290e3b057db7cea628c0f87fd0ba Mon Sep 17 00:00:00 2001 From: Jakub Bednar Date: Thu, 2 May 2024 10:17:25 +0200 Subject: [PATCH 4/4] chore: add test --- tests/test_point.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/test_point.py b/tests/test_point.py index ea59ffd..1559b62 100644 --- a/tests/test_point.py +++ b/tests/test_point.py @@ -1,10 +1,14 @@ import datetime import unittest -from influxdb_client_3.write_client.client.write.point import EPOCH +from influxdb_client_3.write_client.client.write.point import EPOCH, Point class TestPoint(unittest.TestCase): def test_epoch(self): self.assertEqual(EPOCH, datetime.datetime(1970, 1, 1, 0, 0, tzinfo=datetime.timezone.utc)) + + def test_point(self): + point = Point.measurement("h2o").tag("location", "europe").field("level", 2.2).time(1_000_000) + self.assertEqual('h2o,location=europe level=2.2 1000000', point.to_line_protocol())