Skip to content

Commit

Permalink
feat: library bump to handle cash prices reporting 0 as unavailable (
Browse files Browse the repository at this point in the history
…#111)

* feat: library bump to handle cash prices reporting `0` as unavailable

* formatting
  • Loading branch information
firstof9 authored Oct 30, 2024
1 parent 5362253 commit 8c078cb
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion custom_components/gasbuddy/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"import_executor": true,
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/firstof9/ha-gasbuddy/issues",
"requirements": ["py-gasbuddy==0.2.7"],
"requirements": ["py-gasbuddy==0.2.8"],
"version": "0.0.0-dev"
}

2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
py-gasbuddy==0.2.7
py-gasbuddy==0.2.8
1 change: 1 addition & 0 deletions tests/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"e85": {
"credit": "Owner",
"price": 2.83,
"cash_price": None,
"last_updated": "2024-09-27T18:12:09.837Z",
},
"e15": {
Expand Down
25 changes: 24 additions & 1 deletion tests/test_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ async def test_sensors(hass, mock_gasbuddy, entity_registry: er.EntityRegistry):
assert state.state == "3.35"


async def test_sensors_no_uom(hass, mock_gasbuddy):
async def test_sensors_no_uom(hass, mock_gasbuddy, entity_registry: er.EntityRegistry):
"""Test setup_entry."""
entry = MockConfigEntry(
domain=DOMAIN,
Expand Down Expand Up @@ -104,6 +104,29 @@ async def test_sensors_no_uom(hass, mock_gasbuddy):
assert state
assert state.state == "unknown"

# enable disabled sensor
entity_id = "sensor.gas_station_e85_cash"
entity_entry = entity_registry.async_get(entity_id)

assert entity_entry
assert entity_entry.disabled
assert entity_entry.disabled_by is er.RegistryEntryDisabler.INTEGRATION

updated_entry = entity_registry.async_update_entity(
entity_entry.entity_id, disabled_by=None
)
assert updated_entry != entity_entry
assert updated_entry.disabled is False

# reload the integration
assert await hass.config_entries.async_forward_entry_unload(entry, "sensor")
await hass.config_entries.async_forward_entry_setups(entry, ["sensor"])
await hass.async_block_till_done()

state = hass.states.get(entity_id)
assert state
assert state.state == "unknown"


async def test_sensors_cad(hass, mock_gasbuddy_cad, entity_registry: er.EntityRegistry):
"""Test setup_entry."""
Expand Down

0 comments on commit 8c078cb

Please sign in to comment.