10000 chore: add detail error message for not supported type of `Point.fiel… · flycomte/influxdb-client-python@be6760d · GitHub
[go: up one dir, main page]

Skip to content

Commit be6760d

Browse files
authored
chore: add detail error message for not supported type of Point.field (influxdata#241)
1 parent e26e7b0 commit be6760d

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
### Features
44
1. [#237](https://github.com/influxdata/influxdb-client-python/pull/237): Use kwargs to pass query parameters into API list call - useful for the ability to use pagination.
5+
1. [#241](https://github.com/influxdata/influxdb-client-python/pull/241): Add detail error message for not supported type of `Point.field`
56

67
## 1.17.0 [2021-04-30]
78

influxdb_client/client/write/point.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def _append_fields(fields):
165165
elif isinstance(value, str):
166166
_return.append(f'{_escape_key(field)}="{_escape_string(value)}"')
167167
else:
168-
raise ValueError()
168+
raise ValueError(f'Type: "{type(value)}" of field: "{field}" is not supported.')
169169

170170
return f"{','.join(_return)}"
171171

tests/test_point.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,16 @@ def test_points_from_different_timezones(self):
369369
point_hk = Point.measurement("h2o").field("val", 1).time(time_in_hk)
370370
self.assertEqual(point_utc.to_line_protocol(), point_hk.to_line_protocol())
371371

372+
def test_unsupported_field_type(self):
373+
with self.assertRaises(ValueError) as ve:
374+
Point.measurement("h2o") \
375+
.tag("location", "europe") \
376+
.field("level", UTC) \
377+
.to_line_protocol()
378+
exception = ve.exception
379+
380+
self.assertEqual('Type: "<class \'pytz.UTC\'>" of field: "level" is not supported.', f'{exception}')
381+
372382

373383
if __name__ == '__main__':
374384
unittest.main()

0 commit comments

Comments
 (0)
0