Skip to content

Commit

Permalink
Add test for async_on_webrtc_candidate
Browse files Browse the repository at this point in the history
  • Loading branch information
felipecrs committed Nov 27, 2024
1 parent 4bcf827 commit 9ae6665
Showing 1 changed file with 36 additions and 2 deletions.
38 changes: 36 additions & 2 deletions tests/test_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,13 @@ async def test_frigate_camera_setup(
assert image
assert image.content == b"data-277"

client = await hass_ws_client(hass)

aioclient_mock.post(
"http://example.com/api/go2rtc/webrtc?src=front_door",
json={"type": "answer", "sdp": "return_sdp"},
)
client = await hass_ws_client(hass)

await client.send_json(
{
"id": 5,
Expand Down Expand Up @@ -123,6 +125,21 @@ async def test_frigate_camera_setup(
"answer": "return_sdp",
}

await client.send_json(
{
"id": 6,
"type": "camera/webrtc/candidate",
"entity_id": TEST_CAMERA_FRONT_DOOR_ENTITY_ID,
"session_id": "session_id",
"candidate": "candidate",
}
)

response = await client.receive_json()
assert response["id"] == 6
assert response["type"] == TYPE_RESULT
assert response["success"]


async def test_frigate_camera_setup_birdseye(
hass: HomeAssistant,
Expand Down Expand Up @@ -156,11 +173,13 @@ async def test_frigate_camera_setup_birdseye(
assert image
assert image.content == b"data-299"

client = await hass_ws_client(hass)

aioclient_mock.post(
"http://example.com/api/go2rtc/webrtc?src=birdseye",
json={"type": "answer", "sdp": "return_sdp"},
)
client = await hass_ws_client(hass)

await client.send_json(
{
"id": 5,
Expand Down Expand Up @@ -190,6 +209,21 @@ async def test_frigate_camera_setup_birdseye(
"answer": "return_sdp",
}

await client.send_json(
{
"id": 6,
"type": "camera/webrtc/candidate",
"entity_id": TEST_CAMERA_BIRDSEYE_ENTITY_ID,
"session_id": "session_id",
"candidate": "candidate",
}
)

response = await client.receive_json()
assert response["id"] == 6
assert response["type"] == TYPE_RESULT
assert response["success"]


async def test_frigate_extra_attributes(hass: HomeAssistant) -> None:
"""Test that frigate extra attributes are correct."""
Expand Down

0 comments on commit 9ae6665

Please sign in to comment.