# Path: cozify/config.py
# def _initXDG():
# def stateWrite(tmpstate=None):
# def setStatePath(filepath=_initXDG(), copy_current=False):
# def dump_state():
# def _initState(state_file):
# 
# 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


import os, pytest, tempfile, datetime
import hashlib, json
from absl import logging
from mbtest.server import MountebankServer
from cozify import config, hub
from . import fixtures_devices as dev
    from cozify import cloud
    from cozify import cloud
    from cozify import hub
    configfile, configpath = tempfile.mkstemp(suffix='live_cloud')
    config.setStatePath()  # assume default path will contain live config
    config.setStatePath(configpath, copy_current=True)
    yield cloud
    config.setStatePath()
    os.remove(configpath)


@pytest.fixture(scope="session")
def mock_server():
    if 'MBTEST_HOST' in os.environ:
        host = os.environ['MBTEST_HOST']
    else:
        host = 'localhost'
    return MountebankServer(port=2525, host=host)


@pytest.fixture
def tmp_hub(tmp_cloud):
    with Tmp_hub(tmp_cloud) as hub_obj:
        print('Tmp hub state for testing:')
        config.dump_state()
        yield hub_obj


@pytest.fixture()
def live_hub():
    config.setStatePath()  # we assume the default config will be "live"
    configfile, configpath = tempfile.mkstemp(suffix='live_hub')
    config.setStatePath(configpath, copy_current=True)

# Path: cozify/config.py
# def _initXDG():
# def stateWrite(tmpstate=None):
# def setStatePath(filepath=_initXDG(), copy_current=False):
# def dump_state():
# def _initState(state_file):
# 
# 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/test/fixtures.py
import os, pytest, tempfile, datetime
import hashlib, json
from absl import logging
from mbtest.server import MountebankServer
from cozify import config, hub
from . import fixtures_devices as dev
    from cozify import cloud
    from cozify import cloud
    from cozify import hub

    configfile, configpath = tempfile.mkstemp(suffix='live_cloud')
    config.setStatePath()  # assume default path will contain live config
    config.setStatePath(configpath, copy_current=True)
    yield cloud
    config.setStatePath()
    os.remove(configpath)


@pytest.fixture(scope="session")
def mock_server():
    if 'MBTEST_HOST' in os.environ:
        host = os.environ['MBTEST_HOST']
    else:
        host = 'localhost'
    return MountebankServer(port=2525, host=host)


@pytest.fixture
def tmp_hub(tmp_cloud):
    with Tmp_hub(tmp_cloud) as hub_obj:
        print('Tmp hub state for testing:')
        config.dump_state()
        yield hub_obj


@pytest.fixture()
def live_hub():
    config.setStatePath()  # we assume the default config will be "live"
    configfile, configpath = tempfile.mkstemp(suffix='live_hub')
    config.setStatePath(configpath, copy_current=True)

    assert hub.ping()