# Path: cozify/hub.py
# def devices(*, capabilities=None, and_filter=False, **kwargs):
# def device_reachable(device_id, **kwargs):
# def device_exists(device_id, devs=None, state=None, **kwargs):
# def device_eligible(device_id, capability_filter, devs=None, state=None, **kwargs):
# def device_toggle(device_id, **kwargs):
# def device_state_replace(device_id, state, **kwargs):
# def device_on(device_id, **kwargs):
# def device_off(device_id, **kwargs):
# def light_temperature(device_id, temperature=2700, transition=0, **kwargs):
# def light_color(device_id, hue, saturation=1.0, transition=0, **kwargs):
# def light_brightness(device_id, brightness, transition=0, **kwargs):
# def remote(hub_id, new_state=None):
# def autoremote(hub_id, new_state=None):
# def tz(**kwargs):
# def ping(autorefresh=True, **kwargs):
# def name(hub_id):
# def host(hub_id):
# def token(hub_id, new_token=None):
# def hub_id(hub_name):
# def exists(hub_id):
# def default():
# def _getAttr(hub_id, attr, default=None, boolean=False):
# def _setAttr(hub_id, attr, value, commit=True):
# def _get_id(**kwargs):
# def _fill_kwargs(kwargs):
# def _clean_state(state):
# def _in_range(value, low, high, description='undefined'):
# def getDevices(**kwargs):  # pragma: no cover
# def getDefaultHub():  # pragma: no cover
# def getHubId(hub_name):  # pragma: no cover
# 
# Path: cozify/multisensor.py
# def getMultisensorData(data):  # pragma: no cover
# 
# Path: cozify/test/debug.py

# 
# Path: cozify/Error.py
# class APIError(Exception):
#     """Error raised for non-200 API return codes
# 
#     Args:
#         status_code(int): HTTP status code returned by the API
#         message(str): Potential error message returned by the API
#     
#     Attributes:
#         status_code(int): HTTP status code returned by the API
#         message(str): Potential error message returned by the API
#     """
# 
#     def __init__(self, status_code, message):
#         self.status_code = status_code
#         self.message = message
# 
#     def __str__(self):
#         return 'API error, {code}: {message}'.format(code=self.status_code, message=self.message)
# 
# class ConnectionError(ConnectionError):
#     """Error raised for connection level failures,
#     such as a lost internet connection.
# 
#     Args:
#         message(str): Potential error message returned by the requests library
# 
#     Attributes:
#         message(str): Potential error message returned by the requests library
#     """
# 
#     def __init__(self, message):
#         self.message = message
# 
#     def __str__(self):
#         return 'Connection error: {}'.format(self.message)


import pytest
from cozify import hub, multisensor
from cozify.test import debug
from cozify.test.fixtures import *
from cozify.Error import APIError, ConnectionError
@pytest.mark.logic
def test_hub_autoremote_set(tmp_hub):
    assert hub.autoremote(tmp_hub.id, True) == True
    assert hub.autoremote(tmp_hub.id) == True
    assert hub.autoremote(tmp_hub.id, False) == False
    assert hub.autoremote(tmp_hub.id) == False


@pytest.mark.logic
def test_hub_id_to_name(tmp_hub):
    assert hub.name(tmp_hub.id) == tmp_hub.name


@pytest.mark.logic
def test_hub_name_to_id(tmp_hub):
    assert hub.hub_id(tmp_hub.name) == tmp_hub.id


@pytest.mark.logic
def test_hub_attr(tmp_hub):
    with pytest.raises(AttributeError):
        hub._setAttr('deadbeef', 'nop', 'deadbeef')
    hub._setAttr(tmp_hub.id, 'testkey', 'deadbeef')
    assert hub._getAttr(tmp_hub.id, 'testkey') == 'deadbeef'


@pytest.mark.live
def test_multisensor(live_hub):
    assert hub.ping()
    data = hub.devices()

# Path: cozify/hub.py
# def devices(*, capabilities=None, and_filter=False, **kwargs):
# def device_reachable(device_id, **kwargs):
# def device_exists(device_id, devs=None, state=None, **kwargs):
# def device_eligible(device_id, capability_filter, devs=None, state=None, **kwargs):
# def device_toggle(device_id, **kwargs):
# def device_state_replace(device_id, state, **kwargs):
# def device_on(device_id, **kwargs):
# def device_off(device_id, **kwargs):
# def light_temperature(device_id, temperature=2700, transition=0, **kwargs):
# def light_color(device_id, hue, saturation=1.0, transition=0, **kwargs):
# def light_brightness(device_id, brightness, transition=0, **kwargs):
# def remote(hub_id, new_state=None):
# def autoremote(hub_id, new_state=None):
# def tz(**kwargs):
# def ping(autorefresh=True, **kwargs):
# def name(hub_id):
# def host(hub_id):
# def token(hub_id, new_token=None):
# def hub_id(hub_name):
# def exists(hub_id):
# def default():
# def _getAttr(hub_id, attr, default=None, boolean=False):
# def _setAttr(hub_id, attr, value, commit=True):
# def _get_id(**kwargs):
# def _fill_kwargs(kwargs):
# def _clean_state(state):
# def _in_range(value, low, high, description='undefined'):
# def getDevices(**kwargs):  # pragma: no cover
# def getDefaultHub():  # pragma: no cover
# def getHubId(hub_name):  # pragma: no cover
# 
# Path: cozify/multisensor.py
# def getMultisensorData(data):  # pragma: no cover
# 
# Path: cozify/test/debug.py

# 
# Path: cozify/Error.py
# class APIError(Exception):
#     """Error raised for non-200 API return codes
# 
#     Args:
#         status_code(int): HTTP status code returned by the API
#         message(str): Potential error message returned by the API
#     
#     Attributes:
#         status_code(int): HTTP status code returned by the API
#         message(str): Potential error message returned by the API
#     """
# 
#     def __init__(self, status_code, message):
#         self.status_code = status_code
#         self.message = message
# 
#     def __str__(self):
#         return 'API error, {code}: {message}'.format(code=self.status_code, message=self.message)
# 
# class ConnectionError(ConnectionError):
#     """Error raised for connection level failures,
#     such as a lost internet connection.
# 
#     Args:
#         message(str): Potential error message returned by the requests library
# 
#     Attributes:
#         message(str): Potential error message returned by the requests library
#     """
# 
#     def __init__(self, message):
#         self.message = message
# 
#     def __str__(self):
#         return 'Connection error: {}'.format(self.message)


# Path: cozify/test/test_hub.py
import pytest
from cozify import hub, multisensor
from cozify.test import debug
from cozify.test.fixtures import *
from cozify.Error import APIError, ConnectionError

@pytest.mark.logic
def test_hub_autoremote_set(tmp_hub):
    assert hub.autoremote(tmp_hub.id, True) == True
    assert hub.autoremote(tmp_hub.id) == True
    assert hub.autoremote(tmp_hub.id, False) == False
    assert hub.autoremote(tmp_hub.id) == False


@pytest.mark.logic
def test_hub_id_to_name(tmp_hub):
    assert hub.name(tmp_hub.id) == tmp_hub.name


@pytest.mark.logic
def test_hub_name_to_id(tmp_hub):
    assert hub.hub_id(tmp_hub.name) == tmp_hub.id


@pytest.mark.logic
def test_hub_attr(tmp_hub):
    with pytest.raises(AttributeError):
        hub._setAttr('deadbeef', 'nop', 'deadbeef')
    hub._setAttr(tmp_hub.id, 'testkey', 'deadbeef')
    assert hub._getAttr(tmp_hub.id, 'testkey') == 'deadbeef'


@pytest.mark.live
def test_multisensor(live_hub):
    assert hub.ping()
    data = hub.devices()

    print(multisensor.getMultisensorData(data))