diff --git a/.github/workflows/publish-dockerhub.yml b/.github/workflows/publish-dockerhub.yml index ba0e3688..5be60d74 100644 --- a/.github/workflows/publish-dockerhub.yml +++ b/.github/workflows/publish-dockerhub.yml @@ -29,9 +29,6 @@ jobs: with: version: latest - - name: Available platforms - run: echo ${{ steps.buildx.outputs.platforms }} - - name: Login to DockerHub uses: docker/login-action@v1 with: @@ -43,6 +40,7 @@ jobs: uses: docker/build-push-action@v2 with: push: true + platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 tags: | spacemanspiff2007/habapp:latest spacemanspiff2007/habapp:${{ steps.latest_version.outputs.latest_tag }} diff --git a/.github/workflows/publish-pypi.yml b/.github/workflows/publish-pypi.yml index e2b905f2..ef537cf5 100644 --- a/.github/workflows/publish-pypi.yml +++ b/.github/workflows/publish-pypi.yml @@ -30,4 +30,4 @@ jobs: uses: pypa/gh-action-pypi-publish@master with: user: __token__ - password: ${{ secrets.pypi_password }} + password: ${{ secrets.pypi_api_key }} diff --git a/.travis.yml b/.travis.yml index c550c6c5..d3f1039b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,10 +22,9 @@ jobs: python: 3.7 env: TOXENV=py37 -# Travis does not support -# - <<: *python_38 -# python: 3.9 -# env: TOXENV=py39 + - <<: *python_38 + python: 3.9 + env: TOXENV=py39 - <<: *python_38 stage: docs diff --git a/HABApp/__version__.py b/HABApp/__version__.py index b0615a6b..f98e3eef 100644 --- a/HABApp/__version__.py +++ b/HABApp/__version__.py @@ -1 +1 @@ -__version__ = '0.16.1' +__version__ = '0.16.2' diff --git a/HABApp/openhab/connection_handler/http_connection.py b/HABApp/openhab/connection_handler/http_connection.py index 2223f61a..c578c48a 100644 --- a/HABApp/openhab/connection_handler/http_connection.py +++ b/HABApp/openhab/connection_handler/http_connection.py @@ -238,10 +238,6 @@ async def start_sse_event_listener(): # cache so we don't have to look up every event call = ON_SSE_EVENT - options = {} - if HABApp.CONFIG.openhab.connection.user or HABApp.CONFIG.openhab.connection.password: - options['with_credentials'] = True - event_prefix = 'openhab' if not IS_OH2 else 'smarthome' async with sse_client.EventSource( @@ -251,7 +247,6 @@ async def start_sse_event_listener(): f'{event_prefix}/things/*/status,' # Thing status updates f'{event_prefix}/things/*/statuschanged' # Thing status changes , - option=options, session=HTTP_SESSION ) as event_source: async for event in event_source: diff --git a/HABApp/openhab/events/item_events.py b/HABApp/openhab/events/item_events.py index 8d7ee918..05be1107 100644 --- a/HABApp/openhab/events/item_events.py +++ b/HABApp/openhab/events/item_events.py @@ -65,7 +65,7 @@ def __repr__(self): class ItemAddedEvent(OpenhabEvent): - def __init__(self, name: str, type: str): + def __init__(self, name: str = '', type: str = ''): super().__init__() self.name: str = name @@ -83,7 +83,7 @@ def __repr__(self): class ItemUpdatedEvent(OpenhabEvent): - def __init__(self, name: str, type: str): + def __init__(self, name: str = '', type: str = ''): super().__init__() self.name: str = name diff --git a/requirements.txt b/requirements.txt index 8b10c4af..26d26456 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,11 +1,11 @@ aiohttp-sse-client==0.2.0 -aiohttp==3.7.1 +aiohttp==3.7.2 astral==2.2 bidict==0.21.2 -easyco==0.2.2 +easyco==0.2.3 paho-mqtt==1.5.1 -pydantic==1.6.1 -pytz==2020.1 +pydantic==1.7.2 +pytz==2020.4 stackprinter==0.2.5 tzlocal==2.1 voluptuous==0.12.0 diff --git a/tests/test_core/test_utilities.py b/tests/test_core/test_utilities.py index 83800e34..5c8e81cd 100644 --- a/tests/test_core/test_utilities.py +++ b/tests/test_core/test_utilities.py @@ -1,5 +1,4 @@ import asyncio -import sys import pytest @@ -46,14 +45,15 @@ async def b(): nonlocal exception try: await asyncio.sleep(200) - except Exception as e: + except BaseException as e: exception = e p = PendingFuture(b, 0) p.reset() - await asyncio.sleep(0.01) + await asyncio.sleep(0.05) p.reset() - await asyncio.sleep(0.01) - if sys.version_info[:2] != (3, 8): - assert isinstance(exception, asyncio.CancelledError) + await asyncio.sleep(0.05) p.cancel() + + assert exception is not None + assert isinstance(exception, asyncio.CancelledError) diff --git a/tests/test_openhab/test_events/test_from_dict.py b/tests/test_openhab/test_events/test_from_dict.py index cafe359c..06941eea 100644 --- a/tests/test_openhab/test_events/test_from_dict.py +++ b/tests/test_openhab/test_events/test_from_dict.py @@ -1,9 +1,10 @@ import datetime +import pytest from HABApp.openhab.events import ChannelTriggeredEvent, GroupItemStateChangedEvent, ItemAddedEvent, ItemCommandEvent, \ ItemStateChangedEvent, ItemStateEvent, ItemStatePredictedEvent, ItemUpdatedEvent, ThingConfigStatusInfoEvent, \ ThingStatusInfoChangedEvent, ThingStatusInfoEvent, ThingFirmwareStatusInfoEvent -from HABApp.openhab.map_events import get_event +from HABApp.openhab.map_events import get_event, EVENT_LIST def test_ItemStateEvent(): @@ -178,3 +179,10 @@ def test_thing_FirmwareStatusEvent(): event = get_event(data) assert isinstance(event, ThingFirmwareStatusInfoEvent) assert event.status == 'UNKNOWN' + + +@pytest.mark.parametrize('cls', [*EVENT_LIST]) +def test_event_has_name(cls): + # this test ensure that alle events have a name argument + c = cls('asdf') + assert c.name == 'asdf' diff --git a/tests/test_openhab/test_items/test_items.py b/tests/test_openhab/test_items/test_items.py new file mode 100644 index 00000000..820205e4 --- /dev/null +++ b/tests/test_openhab/test_items/test_items.py @@ -0,0 +1,14 @@ +import pytest + +import HABApp.openhab.items + + +@pytest.mark.parametrize('cls', [ + getattr(HABApp.openhab.items, i) for i in dir(HABApp.openhab.items) if i[0] != '_' and i[0].isupper() +]) +def test_item_has_name(cls): + # this test ensure that alle openhab items inherit from OpenhabItem + c = cls('asdf') + assert c.name == 'asdf' + if cls is not HABApp.openhab.items.Thing: + assert isinstance(c, HABApp.openhab.items.OpenhabItem)