Skip to content

fix: write a dictionary-style object without tags #235

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 27, 2021
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
1. [#222](https://github.com/influxdata/influxdb-client-python/pull/222): Pass configured timeout to HTTP client
1. [#218](https://github.com/influxdata/influxdb-client-python/pull/218): Support for `with .. as ..` statement
1. [#232](https://github.com/influxdata/influxdb-client-python/pull/232): Specify package requirements in `setup.py`
1. [#235](https://github.com/influxdata/influxdb-client-python/pull/235): Write a dictionary-style object without tags

## 1.16.0 [2021-04-01]

Expand Down
1 change: 1 addition & 0 deletions influxdb_client/client/write_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,7 @@ def _append_default_tag(self, key, val, record):
elif isinstance(record, Point):
record.tag(key, val)
elif isinstance(record, dict):
record.setdefault("tags", {})
record.get("tags")[key] = val
elif isinstance(record, Iterable):
for item in record:
Expand Down
13 changes: 13 additions & 0 deletions tests/test_WriteApi.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,19 @@ def test_writes_asynchronous_without_retry(self):
self.assertEqual("Service Unavailable", exception.reason)
self.assertEqual(1, len(httpretty.httpretty.latest_requests))

def test_writes_default_tags_dict_without_tag(self):
httpretty.register_uri(httpretty.POST, uri="http://localhost/api/v2/write", status=204)

point_settings = PointSettings(**{"id": "132-987-655", "customer": "California Miner"})
self.write_client = self.influxdb_client.write_api(write_options=SYNCHRONOUS,
point_settings=point_settings)

self.write_client.write("my-bucket", "my-org", {"measurement": "h2o", "fields": {"level": 1.0}, "time": 1})

requests = httpretty.httpretty.latest_requests
self.assertEqual(1, len(requests))
self.assertEqual("h2o,customer=California\\ Miner,id=132-987-655 level=1 1", requests[0].parsed_body)


class AsynchronousWriteTest(BaseTest):

Expand Down