Skip to content

Commit

Permalink
fix linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
marcolivierarsenault authored and cashew22 committed Dec 9, 2023
1 parent ba891f6 commit 6b427c4
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
7 changes: 5 additions & 2 deletions custom_components/moonraker/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
from dataclasses import dataclass

from homeassistant.components.binary_sensor import (
BinarySensorDeviceClass, BinarySensorEntity, BinarySensorEntityDescription)
BinarySensorDeviceClass,
BinarySensorEntity,
BinarySensorEntityDescription,
)

from .const import DOMAIN, METHODS
from .entity import BaseMoonrakerEntity
Expand Down Expand Up @@ -57,7 +60,7 @@ async def async_setup_optional_binary_sensors(coordinator, entry, async_add_enti


async def async_setup_update_binary_sensors(coordinator, entry, async_add_entities):
"""Setup Machine Update binary sensor"""
"""Set Machine Update binary sensor."""

desc = MoonrakerBinarySensorDescription(
key="update_available",
Expand Down
13 changes: 8 additions & 5 deletions custom_components/moonraker/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
from dataclasses import dataclass
from datetime import datetime, timedelta, timezone

from homeassistant.components.sensor import (SensorDeviceClass, SensorEntity,
SensorEntityDescription,
SensorStateClass)
from homeassistant.const import (PERCENTAGE, UnitOfLength, UnitOfTemperature,
UnitOfTime)
from homeassistant.components.sensor import (
SensorDeviceClass,
SensorEntity,
SensorEntityDescription,
SensorStateClass,
)
from homeassistant.const import PERCENTAGE, UnitOfLength, UnitOfTemperature, UnitOfTime
from homeassistant.core import callback

from .const import DOMAIN, METHODS, PRINTERSTATES, PRINTSTATES
Expand Down Expand Up @@ -487,6 +489,7 @@ async def _machine_update_updater(coordinator):


async def async_setup_machine_update_sensors(coordinator, entry, async_add_entities):
"""Test update available."""
machine_status = await coordinator.async_fetch_data(METHODS.MACHINE_UPDATE_STATUS)
if machine_status.get("error"):
return
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ def get_power_devices_fixture():

@pytest.fixture(name="get_machine_update_status")
def get_machine_update_status_fixture():
"""Get Machine Update Status fixture"""
"""Get Machine Update Status fixture."""
return {
"version_info": {
"system": {"package_count": 8},
Expand Down
4 changes: 4 additions & 0 deletions tests/test_binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ async def test_runout_filament_sensor_off(hass, get_data):


async def test_update_available(hass):
"""Test update available."""
config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG, entry_id="test")
config_entry.add_to_hass(hass)
assert await async_setup_entry(hass, config_entry)
Expand All @@ -106,6 +107,7 @@ async def test_update_available(hass):


async def test_update_available_system(hass, get_machine_update_status):
"""Test update available."""
get_machine_update_status["version_info"]["crownest"]["version"] = "v4.1.1-1"
config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG, entry_id="test")
config_entry.add_to_hass(hass)
Expand All @@ -132,6 +134,7 @@ async def test_update_available_system(hass, get_machine_update_status):


async def test_update_available_component(hass, get_machine_update_status):
"""Test update available."""
get_machine_update_status["version_info"]["system"]["package_count"] = 0
config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG, entry_id="test")
config_entry.add_to_hass(hass)
Expand All @@ -158,6 +161,7 @@ async def test_update_available_component(hass, get_machine_update_status):


async def test_update_available_no_update(hass, get_machine_update_status):
"""Test update available."""
get_machine_update_status["version_info"]["system"]["package_count"] = 0
get_machine_update_status["version_info"]["crownest"]["version"] = "v4.1.1-1"
config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG, entry_id="test")
Expand Down
1 change: 1 addition & 0 deletions tests/test_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ async def test_disabled_sensors(
sensor,
value,
):
"""Test."""
config_entry = MockConfigEntry(domain=DOMAIN, data=MOCK_CONFIG, entry_id="test")
config_entry.add_to_hass(hass)
assert await async_setup_entry(hass, config_entry)
Expand Down

0 comments on commit 6b427c4

Please sign in to comment.