Skip to content

Commit

Permalink
Expose device types supported by Bond as constants
Browse files Browse the repository at this point in the history
  • Loading branch information
prystupa committed Jul 21, 2020
1 parent a16ee4b commit 683272c
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 1 deletion.
1 change: 1 addition & 0 deletions bond_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

from .bond import Bond
from .action import Action, Direction
from .device_type import DeviceType
29 changes: 29 additions & 0 deletions bond_api/device_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
"""Bond Device type enumeration."""


class DeviceType:
"""Bond Device type enumeration."""
CEILING_FAN = "CF"
MOTORIZED_SHADES = "MS"
FIREPLACE = "FP"
GENERIC_DEVICE = "GX"

@staticmethod
def is_fan(device_type: str) -> bool:
"""Checks if specified device type is a fan."""
return device_type == DeviceType.CEILING_FAN

@staticmethod
def is_shades(device_type: str) -> bool:
"""Checks if specified device type is shades."""
return device_type == DeviceType.MOTORIZED_SHADES

@staticmethod
def is_fireplace(device_type: str) -> bool:
"""Checks if specified device type is fireplace."""
return device_type == DeviceType.FIREPLACE

@staticmethod
def is_generic(device_type: str) -> bool:
"""Checks if specified device type is generic."""
return device_type == DeviceType.GENERIC_DEVICE
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

setup(
name="bond_api",
version="0.1.0",
version="0.1.2",
packages=find_packages(),

author="Eugene Prystupa",
Expand Down
15 changes: 15 additions & 0 deletions tests/test_device_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from bond_api.device_type import DeviceType


def test_compare_device_types():
assert DeviceType.CEILING_FAN == "CF"
assert DeviceType.is_fan("CF")

assert DeviceType.MOTORIZED_SHADES == "MS"
assert DeviceType.is_shades("MS")

assert DeviceType.FIREPLACE == "FP"
assert DeviceType.is_fireplace("FP")

assert DeviceType.GENERIC_DEVICE == "GX"
assert DeviceType.is_generic("GX")

0 comments on commit 683272c

Please sign in to comment.