Skip to content

Commit

Permalink
Fix broken tests/mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
ugyballoons committed Oct 8, 2024
1 parent a87a288 commit 1435948
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
15 changes: 10 additions & 5 deletions tests/handlers/api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,17 @@ async def test_get_api_location_camera_current_for_offline(
"""Test that api location camera current gives no events for offline
camera"""
client, app, mocker = mocked_client
location_name = "summit-usdf"
camera_name = "lsstcam"

response = await client.get(f"/rubintv/api/{location_name}/{camera_name}/current")
data = response.json()
assert data == {}
location_name = "summit-usdf"
location: Location | None = find_first(m.locations, "name", location_name)
assert location is not None
for camera in location.cameras:
if not camera.online:
response = await client.get(
f"/rubintv/api/{location_name}/{camera.name}/current"
)
data = response.json()
assert data == {}


@pytest.mark.asyncio
Expand Down
2 changes: 1 addition & 1 deletion tests/handlers/external_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ async def test_current_channels(

html = await response.aread()
parsed = BeautifulSoup(html, "html.parser")
if mocker.empty_channel[loc_cam] == seq_chan.name:
if mocker.empty_channel.get(loc_cam) == seq_chan.name:
assert parsed.select(".event-error")
assert not parsed.select(".event-info")
else:
Expand Down
2 changes: 1 addition & 1 deletion tests/mockdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def add_seq_objs(
empty_channel = ""
if include_empty_channel:
seq_chans = [chan.name for chan in camera.seq_channels()]
if seq_chans:
if seq_chans and len(seq_chans) > 1:
empty_channel = random.choice(seq_chans)

for channel in camera.channels:
Expand Down

0 comments on commit 1435948

Please sign in to comment.