1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 04:50:05 +00:00

Fix Datadog boolean metrics (#37273)

Explicitly cast boolean metrics to integers
This commit is contained in:
Rick Sherman
2020-07-05 12:50:51 -05:00
committed by GitHub
parent 992793295c
commit b56f4bd9f8
2 changed files with 4 additions and 2 deletions

View File

@@ -134,7 +134,7 @@ class TestDatadog(unittest.TestCase):
valid = {"1": 1, "1.0": 1.0, STATE_ON: 1, STATE_OFF: 0}
attributes = {"elevation": 3.2, "temperature": 5.0}
attributes = {"elevation": 3.2, "temperature": 5.0, "up": True, "down": False}
for in_, out in valid.items():
state = mock.MagicMock(
@@ -145,9 +145,10 @@ class TestDatadog(unittest.TestCase):
)
handler_method(mock.MagicMock(data={"new_state": state}))
assert mock_client.gauge.call_count == 3
assert mock_client.gauge.call_count == 5
for attribute, value in attributes.items():
value = int(value) if isinstance(value, bool) else value
mock_client.gauge.assert_has_calls(
[
mock.call(