Skip to content

Commit

Permalink
Adding better code coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
vangorra committed Dec 20, 2020
1 parent d2469cf commit b904ccd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 19 deletions.
21 changes: 3 additions & 18 deletions gogogate2_api/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,7 @@ class TagException(Exception):

def __init__(self, tag: str, message: str) -> None:
super().__init__(message)
self._tag: Final = tag

@property
def tag(self) -> str:
"""Get the tag."""
return self._tag
self.tag: Final = tag


class TagNotFoundException(TagException):
Expand All @@ -59,18 +54,8 @@ def __init__(self, value: Any, expected: Type[GenericType]):
super().__init__(
'Expected of "%s" to be "%s" but was "%s."' % (value, expected, type(value))
)
self._value: Final = value
self._expected: Final = expected

@property
def value(self) -> Any:
"""Get value."""
return self._value

@property
def expected(self) -> Type[GenericType]:
"""Get expected type."""
return self._expected
self.value: Final = value
self.expected: Final = expected


def enforce_type(value: Any, expected: Type[GenericType]) -> GenericType:
Expand Down
6 changes: 5 additions & 1 deletion tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
get_configured_doors,
int_or_raise,
str_or_raise,
get_configured_door_by_id,
)
import pytest
from typing_extensions import Final
Expand Down Expand Up @@ -64,7 +65,7 @@ def test_enum_or_raise() -> None:
assert exinfo.value.expected == DoorStatus


def test_get_enabled_doors() -> None:
def test_get_configured_doors() -> None:
"""Test get configurd doors."""
response: Final = GogoGate2InfoResponse(
user="user1",
Expand Down Expand Up @@ -122,4 +123,7 @@ def test_get_enabled_doors() -> None:
wifi=Wifi(SSID="", linkquality="", signal=""),
)

assert get_configured_door_by_id(1, response) == response.door1
assert not get_configured_door_by_id(2, response)
assert get_configured_door_by_id(3, response) == response.door3
assert get_configured_doors(response) == (response.door1, response.door3)

0 comments on commit b904ccd

Please sign in to comment.