Skip to content

Commit

Permalink
ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
gjohansson-ST committed Jul 27, 2023
1 parent ac72eb8 commit aea969b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
6 changes: 3 additions & 3 deletions tests/components/trafikverket_camera/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from homeassistant.components.trafikverket_camera.const import DOMAIN
from homeassistant.config_entries import SOURCE_USER
from homeassistant.core import HomeAssistant
from homeassistant.util import dt
from homeassistant.util import dt as dt_util

from . import ENTRY_CONFIG

Expand Down Expand Up @@ -61,8 +61,8 @@ def fixture_get_camera() -> CameraInfo:
direction="180",
fullsizephoto=True,
location="Test location",
modified=datetime(2022, 4, 4, 4, 4, 4, tzinfo=dt.UTC),
phototime=datetime(2022, 4, 4, 4, 4, 4, tzinfo=dt.UTC),
modified=datetime(2022, 4, 4, 4, 4, 4, tzinfo=dt_util.UTC),
phototime=datetime(2022, 4, 4, 4, 4, 4, tzinfo=dt_util.UTC),
photourl="https://www.testurl.com/test_photo.jpg",
status="Running",
camera_type="Road",
Expand Down
11 changes: 4 additions & 7 deletions tests/components/trafikverket_camera/test_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
from unittest.mock import patch

import pytest
from pytest import MonkeyPatch
from pytrafikverket.trafikverket_camera import CameraInfo

from homeassistant.components.camera import async_get_image
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError
from homeassistant.util import dt
from homeassistant.util import dt as dt_util

from tests.common import async_fire_time_changed
from tests.test_util.aiohttp import AiohttpClientMocker
Expand All @@ -21,7 +20,7 @@
async def test_camera(
hass: HomeAssistant,
load_int: ConfigEntry,
monkeypatch: MonkeyPatch,
monkeypatch: pytest.MonkeyPatch,
aioclient_mock: AiohttpClientMocker,
get_camera: CameraInfo,
) -> None:
Expand All @@ -46,7 +45,7 @@ async def test_camera(
)
async_fire_time_changed(
hass,
dt.utcnow() + timedelta(minutes=6),
dt_util.utcnow() + timedelta(minutes=6),
)
await hass.async_block_till_done()

Expand All @@ -65,16 +64,14 @@ async def test_camera(
"https://www.testurl.com/test_photo.jpg?type=fullsize",
status=404,
)
print(get_camera)

with patch(
"homeassistant.components.trafikverket_camera.coordinator.TrafikverketCamera.async_get_camera",
return_value=get_camera,
):

async_fire_time_changed(
hass,
dt.utcnow() + timedelta(minutes=6),
dt_util.utcnow() + timedelta(minutes=6),
)
await hass.async_block_till_done()

Expand Down
4 changes: 2 additions & 2 deletions tests/components/trafikverket_camera/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async def test_form(hass: HomeAssistant) -> None:


@pytest.mark.parametrize(
"error_message,base_error",
("error_message", "base_error"),
[
(
"Source: Security, message: Invalid authentication",
Expand Down Expand Up @@ -141,7 +141,7 @@ async def test_reauth_flow(hass: HomeAssistant) -> None:


@pytest.mark.parametrize(
"sideeffect,p_error",
("sideeffect", "p_error"),
[
(
"Source: Security, message: Invalid authentication",
Expand Down
2 changes: 1 addition & 1 deletion tests/components/trafikverket_camera/test_coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ async def test_coordinator(


@pytest.mark.parametrize(
"sideeffect,p_error,entry_state",
("sideeffect", "p_error", "entry_state"),
[
(
ValueError("Source: Security, message: Invalid authentication"),
Expand Down

0 comments on commit aea969b

Please sign in to comment.