Skip to content

Commit

Permalink
ci
Browse files Browse the repository at this point in the history
  • Loading branch information
spacemanspiff2007 committed Jan 16, 2025
1 parent c7c7c15 commit 8a67f49
Show file tree
Hide file tree
Showing 16 changed files with 35 additions and 31 deletions.
8 changes: 5 additions & 3 deletions run/conf_testing/rules/openhab/test_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,19 @@
# ----------------------------------------------------------------------------------------------------------------------
import time

from HABApp.openhab.events import ItemCommandEvent, ItemCommandEventFilter
from HABAppTests import (
EventWaiter,
ItemWaiter,
OpenhabTmpItem,
TestBaseRule,
get_openhab_test_states,
get_openhab_item_names,
get_random_name, get_openhab_test_commands, EventWaiter,
get_openhab_test_commands,
get_openhab_test_states,
get_random_name,
)

import HABApp
from HABApp.openhab.events import ItemCommandEventFilter


class TestOpenhabInterface(TestBaseRule):
Expand Down
1 change: 0 additions & 1 deletion run/conf_testing/rules/openhab/test_item_events.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import time

from HABAppTests import (
EventWaiter,
Expand Down
10 changes: 6 additions & 4 deletions run/conf_testing/rules/openhab/test_item_funcs.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import dataclasses
import logging

from HABApp.core.types import HSB
from HABAppTests import ItemWaiter, OpenhabTmpItem, TestBaseRule, get_openhab_test_states, get_openhab_item_names, get_openhab_test_commands
from HABAppTests import (
ItemWaiter,
OpenhabTmpItem,
TestBaseRule,
)

from HABApp.core.types import HSB
from HABApp.openhab.items import (
ColorItem,
ContactItem,
DimmerItem,
ImageItem,
LocationItem,
NumberItem,
OpenhabItem,
RollershutterItem,
Expand Down
1 change: 1 addition & 0 deletions src/HABApp/core/errors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Any as _Any

from typing_extensions import Self as _Self

from HABApp.core.const.hints import HasNameAttr as _HasNameAttr
Expand Down
1 change: 0 additions & 1 deletion src/HABApp/core/items/item_color.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,3 @@ def get_create_item(cls, name: str,
if not isinstance(item, cls):
raise WrongItemTypeError.from_item(item, cls)
return item

2 changes: 1 addition & 1 deletion src/HABApp/openhab/connection/plugins/load_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from HABApp.openhab.connection.connection import OpenhabConnection, OpenhabContext
from HABApp.openhab.connection.handler import map_null_str
from HABApp.openhab.connection.handler.func_async import async_get_all_items_state, async_get_items, async_get_things
from HABApp.openhab.definitions import QuantityValue, QuantityType
from HABApp.openhab.definitions import QuantityType
from HABApp.openhab.item_to_reg import (
add_thing_to_registry,
add_to_registry,
Expand Down
2 changes: 1 addition & 1 deletion src/HABApp/openhab/items/color_item.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from collections.abc import Mapping
from typing import TYPE_CHECKING, Final, overload, override
from typing import TYPE_CHECKING, Final, override

from HABApp.core.errors import InvalidItemValueError, ItemValueIsNoneError
from HABApp.core.types import HSB, RGB
Expand Down
1 change: 1 addition & 0 deletions src/HABApp/openhab/items/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from HABApp.openhab.definitions import OnOffType, UpDownType
from HABApp.openhab.interface_sync import send_command


ON: Final = OnOffType.ON
OFF: Final = OnOffType.OFF
UP: Final = UpDownType.UP
Expand Down
6 changes: 3 additions & 3 deletions tests/test_openhab/test_items/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@


class ValueCollector:
def __init__(self):
def __init__(self) -> None:
self.values = []

def __call__(self, name, value):
def __call__(self, name, value) -> None:
self.values.append(value)

def assert_called_with(self, *values, clear=True):
def assert_called_with(self, *values, clear=True) -> None:
if len(values) == 1 and len(self.values) == 1:
assert self.values[0] == values[0]

Expand Down
2 changes: 1 addition & 1 deletion tests/test_openhab/test_items/test__converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from HABApp.openhab.items._converter import ValueToOh


def test_converter():
def test_converter() -> None:
a = ValueToOh('Asdf', UnDefType)
b = a.add_type('Sdfg', DecimalType)

Expand Down
6 changes: 2 additions & 4 deletions tests/test_openhab/test_items/test_commands.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import typing

import pytest

from HABApp import __version__
from HABApp.core.types import HSB
from HABApp.openhab.definitions import OnOffValue, OpenClosedValue, UpDownValue, OpenClosedType, UpDownType
from HABApp.openhab.items import ContactItem, ColorItem
from HABApp.openhab.definitions import OnOffValue, OpenClosedType, UpDownType, UpDownValue
from HABApp.openhab.items import ColorItem, ContactItem
from HABApp.openhab.items.commands import OnOffCommand, UpDownCommand
from HABApp.openhab.map_items import _items as item_dict

Expand Down
2 changes: 1 addition & 1 deletion tests/test_openhab/test_items/test_dimmer.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_dimmer_set_value() -> None:
DimmerItem('item_name').set_value('asdf')


def test_switch_post_update(posted_updates):
def test_switch_post_update(posted_updates) -> None:
sw = DimmerItem('')

sw.oh_post_update('ON')
Expand Down
2 changes: 1 addition & 1 deletion tests/test_openhab/test_items/test_switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def test_switch_set_value() -> None:
SwitchItem('item_name').set_value('asdf')


def test_switch_post_update(posted_updates):
def test_switch_post_update(posted_updates) -> None:
sw = SwitchItem('')

sw.oh_post_update('ON')
Expand Down
4 changes: 2 additions & 2 deletions tests/test_openhab/test_items/test_tuple_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def test_call_set_value() -> None:
assert call.value == ('a', 'b')


def test_call_post_update(posted_updates):
def test_call_post_update(posted_updates) -> None:
call = CallItem('my_call_item')

call.oh_post_update('asdf')
Expand Down Expand Up @@ -59,7 +59,7 @@ def test_location_set_value() -> None:
assert call.value == (1, 2, 3.3)


def test_location_post_update(posted_updates):
def test_location_post_update(posted_updates) -> None:
call = LocationItem('my_call_item')

call.oh_post_update((132, 456))
Expand Down
16 changes: 9 additions & 7 deletions tests/test_openhab/test_types.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import itertools
from datetime import datetime
from inspect import signature
from typing import Final, Literal
from typing import Final

import pytest
from sphinx.util.inspect import isclass
from whenever import SystemDateTime

from HABApp.core.types import HSB, RGB
from HABApp.openhab.definitions import OpenHABDataType, RefreshType, UnDefType
from HABApp.openhab.definitions import OpenHABDataType, UnDefType
from HABApp.openhab.definitions import types as types_module
from HABApp.openhab.definitions.types import (
DateTimeType,
Expand All @@ -17,12 +17,14 @@
PercentType,
PointType,
QuantityType,
RawType,
RestrictedOpenHABDataType,
StringListType,
StringType, RawType,
StringType,
)
from tests.helpers.inspect import get_module_classes


ALL_TYPES: Final = tuple(
cls for n in dir(types_module)
if isclass(cls := getattr(types_module, n)) and issubclass(cls, OpenHABDataType) and cls is not OpenHABDataType
Expand All @@ -35,7 +37,7 @@


@pytest.mark.parametrize('cls', (c for c in RESTRICTED_TYPES if c is not UnDefType))
def test_restricted_types(cls: type[RestrictedOpenHABDataType]):
def test_restricted_types(cls: type[RestrictedOpenHABDataType]) -> None:
for value in cls.get_allowed_values():
assert cls.from_oh_str(value) == value
assert cls.to_oh_str(value) == value
Expand All @@ -50,14 +52,14 @@ def test_restricted_types(cls: type[RestrictedOpenHABDataType]):
assert return_annotation in annotations


def test_undef_type():
def test_undef_type() -> None:
for value in UnDefType.get_allowed_values():
assert UnDefType.from_oh_str(value) is None
assert UnDefType.to_oh_str(None) == UnDefType.NULL


@pytest.mark.parametrize('cls', RESTRICTED_TYPES)
def test_restricted_types_invalid(cls: type[RestrictedOpenHABDataType]):
def test_restricted_types_invalid(cls: type[RestrictedOpenHABDataType]) -> None:
# Error if we get the wrong value
with pytest.raises(ValueError) as e:
cls.from_oh_str('asdf')
Expand Down Expand Up @@ -343,7 +345,7 @@ def test_str_type_invalid() -> None:
# Module constants
# ----------------------------------------------------------------------------------------------------------------------

def test_all_types():
def test_all_types() -> None:
classes = get_module_classes(
types_module, subclass=(OpenHABDataType, RestrictedOpenHABDataType), include_subclass=False)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_openhab/test_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from tests.helpers.inspect import get_module_classes


def test_all_values():
def test_all_values() -> None:
classes = get_module_classes(
values_module, subclass=ComplexOhValue, include_subclass=False)

Expand Down

0 comments on commit 8a67f49

Please sign in to comment.