Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

beta: Update more tests #421

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 24 additions & 21 deletions custom_components/keymaster/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,23 @@

import asyncio
import base64
from collections.abc import Callable, Mapping
from dataclasses import fields, is_dataclass
from datetime import datetime, time as dt_time, timedelta
import functools
import json
import logging
import os
from collections.abc import Callable, Mapping
from dataclasses import fields, is_dataclass
from datetime import datetime
from datetime import time as dt_time
from datetime import timedelta
from typing import Any, Type, Union, get_args, get_origin

from zwave_js_server.const.command_class.lock import ATTR_IN_USE, ATTR_USERCODE
from zwave_js_server.exceptions import BaseZwaveJSServerError, FailedZWaveCommand
from zwave_js_server.model.node import Node as ZwaveJSNode
from zwave_js_server.util.lock import (
clear_usercode,
get_usercode_from_node,
get_usercodes,
set_usercode,
)

from homeassistant.components.lock.const import DOMAIN as LOCK_DOMAIN, LockState
from homeassistant.components.lock.const import DOMAIN as LOCK_DOMAIN
from homeassistant.components.lock.const import LockState
from homeassistant.components.zwave_js import ZWAVE_JS_NOTIFICATION_EVENT
from homeassistant.components.zwave_js.const import (
ATTR_PARAMETERS,
DATA_CLIENT as ZWAVE_JS_DATA_CLIENT,
DOMAIN as ZWAVE_JS_DOMAIN,
)
from homeassistant.components.zwave_js.const import ATTR_PARAMETERS
from homeassistant.components.zwave_js.const import DATA_CLIENT as ZWAVE_JS_DATA_CLIENT
from homeassistant.components.zwave_js.const import DOMAIN as ZWAVE_JS_DOMAIN
from homeassistant.const import (
ATTR_DEVICE_ID,
ATTR_ENTITY_ID,
Expand All @@ -44,10 +35,21 @@
STATE_UNKNOWN,
)
from homeassistant.core import CoreState, Event, EventStateChangedData, HomeAssistant
from homeassistant.helpers import device_registry as dr, entity_registry as er
from homeassistant.helpers import device_registry as dr
from homeassistant.helpers import entity_registry as er
from homeassistant.helpers.event import async_call_later, async_track_state_change_event
from homeassistant.helpers.update_coordinator import DataUpdateCoordinator
from homeassistant.util import dt as dt_util, slugify
from homeassistant.util import dt as dt_util
from homeassistant.util import slugify
from zwave_js_server.const.command_class.lock import ATTR_IN_USE, ATTR_USERCODE
from zwave_js_server.exceptions import BaseZwaveJSServerError, FailedZWaveCommand
from zwave_js_server.model.node import Node as ZwaveJSNode
from zwave_js_server.util.lock import (
clear_usercode,
get_usercode_from_node,
get_usercodes,
set_usercode,
)

from .const import (
ACCESS_CONTROL,
Expand Down Expand Up @@ -1054,6 +1056,7 @@ async def _update_door_and_lock_state(
isinstance(kmlock.door_sensor_entity_id, str)
and kmlock.door_sensor_entity_id
and kmlock.door_sensor_entity_id != DEFAULT_DOOR_SENSOR
and self.hass.states.get(kmlock.door_sensor_entity_id)
):
door_state: str = self.hass.states.get(
kmlock.door_sensor_entity_id
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ log_level = "DEBUG" # Set the logging level to DEBUG
asyncio_mode = "auto"
asyncio_default_fixture_loop_scope = "function"
timeout = 30
addopts = "-vv --cov=custom_components/keymaster --cov-report=xml"
addopts = "-rA --cov=custom_components/keymaster --cov-report=xml"

[tool.ruff]
required-version = ">=0.8.0"
Expand Down
7 changes: 3 additions & 4 deletions tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import asyncio
from datetime import datetime
import functools as ft
import os
from pathlib import Path
import time
from unittest.mock import patch

Expand All @@ -15,9 +15,8 @@

def load_fixture(filename):
"""Load a fixture."""
path = os.path.join(os.path.dirname(__file__), "json", filename)
with open(path, encoding="utf-8") as fptr:
return fptr.read()
path = Path(__file__).parent / "json" / filename
return path.read_text(encoding="utf-8")


def async_capture_events(hass, event_name):
Expand Down
Loading
Loading