mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 17:57:11 +00:00
Move imports to top for seventeentrack (#29264)
* Move imports to top for seventeentrack * Updated patch target path in test_sensor.py
This commit is contained in:
parent
9927f6c17d
commit
22225cea4d
@ -1,7 +1,9 @@
|
|||||||
"""Support for package tracking sensors from 17track.net."""
|
"""Support for package tracking sensors from 17track.net."""
|
||||||
import logging
|
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from py17track import Client as SeventeenTrackClient
|
||||||
|
from py17track.errors import SeventeenTrackError
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
from homeassistant.components.sensor import PLATFORM_SCHEMA
|
||||||
@ -61,12 +63,10 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
|||||||
|
|
||||||
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
|
async def async_setup_platform(hass, config, async_add_entities, discovery_info=None):
|
||||||
"""Configure the platform and add the sensors."""
|
"""Configure the platform and add the sensors."""
|
||||||
from py17track import Client
|
|
||||||
from py17track.errors import SeventeenTrackError
|
|
||||||
|
|
||||||
websession = aiohttp_client.async_get_clientsession(hass)
|
websession = aiohttp_client.async_get_clientsession(hass)
|
||||||
|
|
||||||
client = Client(websession)
|
client = SeventeenTrackClient(websession)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
login_result = await client.profile.login(
|
login_result = await client.profile.login(
|
||||||
@ -290,7 +290,6 @@ class SeventeenTrackData:
|
|||||||
|
|
||||||
async def _async_update(self):
|
async def _async_update(self):
|
||||||
"""Get updated data from 17track.net."""
|
"""Get updated data from 17track.net."""
|
||||||
from py17track.errors import SeventeenTrackError
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
packages = await self._client.profile.packages(
|
packages = await self._client.profile.packages(
|
||||||
|
@ -119,7 +119,10 @@ def fixture_mock_py17track():
|
|||||||
@pytest.fixture(autouse=True, name="mock_client")
|
@pytest.fixture(autouse=True, name="mock_client")
|
||||||
def fixture_mock_client(mock_py17track):
|
def fixture_mock_client(mock_py17track):
|
||||||
"""Mock py17track client."""
|
"""Mock py17track client."""
|
||||||
with mock.patch("py17track.Client", new=ClientMock):
|
with mock.patch(
|
||||||
|
"homeassistant.components.seventeentrack.sensor.SeventeenTrackClient",
|
||||||
|
new=ClientMock,
|
||||||
|
):
|
||||||
yield
|
yield
|
||||||
ProfileMock.reset()
|
ProfileMock.reset()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user