Skip to content

Commit

Permalink
build(deps): bump websockets from 13.1 to 14.1 (#1395)
Browse files Browse the repository at this point in the history
* build(deps): bump websockets from 13.1 to 14.1

Bumps [websockets](https://github.com/python-websockets/websockets) from 13.1 to 14.1.
- [Release notes](https://github.com/python-websockets/websockets/releases)
- [Commits](python-websockets/websockets@13.1...14.1)

---
updated-dependencies:
- dependency-name: websockets
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>

* update for >14

* fix linting

* suppress close

* drop restriction

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: lbbrhzn <[email protected]>
Co-authored-by: drc38 <[email protected]>
  • Loading branch information
3 people authored Nov 25, 2024
1 parent 2e7a015 commit 1c62f40
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 42 deletions.
2 changes: 1 addition & 1 deletion custom_components/ocpp/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"issue_tracker": "https://github.com/lbbrhzn/ocpp/issues",
"requirements": [
"ocpp>=1.0.0",
"websockets>=12.0,<14"
"websockets>=12.0"
],
"version": "0.6.1"
}
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ colorlog==6.9.0
uv>=0.4
ruff==0.8.0
ocpp==1.0.0
websockets==13.1
websockets==14.1
jsonschema==4.23.0
pre-commit==4.0.1
pytest-homeassistant-custom-component==0.13.184
Expand Down
68 changes: 28 additions & 40 deletions tests/test_charge_point_v16.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,18 @@ async def test_services(hass, cs, socket_enabled):
await hass.async_block_till_done()

# no subprotocol
# NB each new config entry will trigger async_update_entry
# if the charger measurands differ from the config entry
# which causes the websocket server to close/restart with a
# ConnectionClosedOK exception, hence it needs to be passed/suppressed
async with websockets.connect(
"ws://127.0.0.1:9002/CP_1_nosub",
) as ws2:
# use a different id for debugging
cp2 = ChargePoint("CP_1_no_subprotocol", ws2)
with contextlib.suppress(asyncio.TimeoutError):
with contextlib.suppress(
asyncio.TimeoutError, websockets.exceptions.ConnectionClosedOK
):
await asyncio.wait_for(
asyncio.gather(
cp2.start(),
Expand Down Expand Up @@ -177,17 +183,8 @@ async def test_services(hass, cs, socket_enabled):
await asyncio.wait_for(
asyncio.gather(
cp.start(),
cp.send_boot_notification(),
cp.send_authorize(),
cp.send_heartbeat(),
cp.send_status_notification(),
cp.send_firmware_status(),
cp.send_data_transfer(),
cp.send_start_transaction(),
cp.send_stop_transaction(),
cp.send_meter_periodic_data(),
),
timeout=5,
timeout=3,
)
await ws.close()

Expand All @@ -204,17 +201,8 @@ async def test_services(hass, cs, socket_enabled):
await asyncio.wait_for(
asyncio.gather(
cp.start(),
cp.send_boot_notification(),
cp.send_authorize(),
cp.send_heartbeat(),
cp.send_status_notification(),
cp.send_firmware_status(),
cp.send_data_transfer(),
cp.send_start_transaction(),
cp.send_stop_transaction(),
cp.send_meter_periodic_data(),
),
timeout=5,
timeout=3,
)
await ws.close()

Expand All @@ -235,7 +223,7 @@ async def test_services(hass, cs, socket_enabled):
cp.start(),
cp.send_meter_periodic_data(),
),
timeout=5,
timeout=3,
)
# check if None
assert cs.get_metric("test_cpid", "Energy.Meter.Start") is None
Expand All @@ -247,7 +235,7 @@ async def test_services(hass, cs, socket_enabled):
cp.send_start_transaction(12344),
cp.send_meter_periodic_data(),
),
timeout=5,
timeout=3,
)
# save for reference the values for meter_start and transaction_id
saved_meter_start = int(cs.get_metric("test_cpid", "Energy.Meter.Start"))
Expand All @@ -261,7 +249,7 @@ async def test_services(hass, cs, socket_enabled):
asyncio.gather(
cp.send_meter_periodic_data(),
),
timeout=5,
timeout=3,
)
await ws.close()

Expand Down Expand Up @@ -423,9 +411,11 @@ async def test_services(hass, cs, socket_enabled):
"ws://127.0.0.1:9000/CP_1_error",
subprotocols=["ocpp1.6"],
) as ws:
cp = ChargePoint("CP_1_error", ws)
cp.accept = False
try:
with contextlib.suppress(
asyncio.TimeoutError, websockets.exceptions.ConnectionClosedOK
):
cp = ChargePoint("CP_1_error", ws)
cp.accept = False
await asyncio.wait_for(
asyncio.gather(
cp.start(),
Expand All @@ -437,23 +427,21 @@ async def test_services(hass, cs, socket_enabled):
),
timeout=3,
)
except TimeoutError:
pass
except websockets.exceptions.ConnectionClosedOK:
pass
await ws.close()

await asyncio.sleep(1)

# setting state no longer available with websockets >14
# test ping timeout, change cpid to start new connection
cs.settings.cpid = "CP_3_test"
async with websockets.connect(
"ws://127.0.0.1:9000/CP_3",
subprotocols=["ocpp1.6"],
) as ws:
cp = ChargePoint("CP_3_test", ws)
ws.state = 3 # CLOSED = 3
await asyncio.sleep(3)
await ws.close()
# cs.settings.cpid = "CP_3_test"
# async with websockets.connect(
# "ws://127.0.0.1:9000/CP_3",
# subprotocols=["ocpp1.6"],
# ) as ws:
# cp = ChargePoint("CP_3_test", ws)
# ws.state = 3 # CLOSED = 3
# await asyncio.sleep(3)
# await ws.close()

# test services when charger is unavailable
await asyncio.sleep(1)
Expand Down

0 comments on commit 1c62f40

Please sign in to comment.