influxdata / influxdb-client-python

InfluxDB 2.0 python client
https://influxdb-client.readthedocs.io/en/stable/
MIT License
706 stars 185 forks source link

`class Point` doesn't support equality comparison #623

Closed hf-kklein closed 8 months ago

hf-kklein commented 8 months ago

Specifications

Code sample to reproduce problem

def test_point_equality():
    point_a = (
        Point("asd")
        .tag("foo", "bar")
        .field("value", 123.45)
        .time(datetime(2023, 12, 19, 13, 27, 42, 215000, tzinfo=timezone.utc))
    )

    point_b = (
        Point("asd")
        .tag("foo", "bar")
        .field("value", 123.45)
        .time(datetime(2023, 12, 19, 13, 27, 42, 215000, tzinfo=timezone.utc))
    )

    assert point_a == point_b

Expected behavior

Points with equal measurement_name, tags, fields and datetime shall be equal using the == comparison.

Actual behavior

they are not equal:

  assert point_a == point_b

E assert <influxdb_client.client.write.point.Point object at 0x0000022C05D11110> == <influxdb_client.client.write.point.Point object at 0x0000022C05D11150>

But

assert point_a.to_line_protocol() == point_b.to_line_protocol()

is fulfilled.

Additional info

Maybe I'm missing a key concept here why points are not equatable but line protocols are?

bednar commented 8 months ago

HI @hf-kklein,

thanks for using our client and report this issue.

Is this something you would be willing to help with? All PR is welcome and we will be happy to review your submission.

Regards

hf-kklein commented 8 months ago

will open a PR and report back.

bednar commented 8 months ago

@hf-kklein thanks a lot

hf-kklein commented 8 months ago

@bednar #625 . Sorry for the repetitive test cases. Didn't know how to properly parametrize the tests with only the stdlib unittest lib.

bednar commented 8 months ago

@hf-kklein it's ok