def test_get_config_non_whitelist(testhue): unwhitelisted_name = 'woogyboogy_nowhitelist' assert unwhitelisted_name not in testhue.get_config()['whitelist'] myhue = Hue.discover_one(unwhitelisted_name) conf = myhue.get_config() # We only get a minimal config when not whitelisted assert conf.keys() == ['swversion', 'name']
def test_create_user(testhue): testhue.activate_link_button() myhue = Hue.discover_one('PythonHueClientTest', 'PythonHueClientTests') myhue.create_user() conf = myhue.get_config() # we got the full config values assert 'whitelist' in conf myhue.delete_user() with pytest.raises(Exception): # Our user is invalid, so we can't do this myhue.deactivate_link_button()
def test_autocreate_user(testhue): testhue.activate_link_button() # Let the device create a user myhue = Hue.discover_one(devicetype='PythonHueClientTests') assert len(myhue.create_user()) > 10 assert myhue.devicetype == 'PythonHueClientTests' conf = myhue.get_config() # we got the full config values assert 'whitelist' in conf myhue.delete_user() # And now this user is no longer whitelisted with pytest.raises(Exception): myhue.deactivate_link_button()
#!/usr/bin/python from random import randint from time import sleep from hue import Hue myhue = Hue.discover_one('ExampleScript') lights = myhue.get_lights() for light in lights: light.put_state(on=True, transitiontime=10) try: interval = 5 while True: for light in lights: light.put_state(hue=randint(0, 65535), sat=randint(200, 255), bri=randint(200, 255), # Transition is an integer in steps of 100ms transitiontime=int(interval * 10)) sleep(interval/len(lights)) except KeyboardInterrupt: for light in lights: light.put_state(on=False, transitiontime=10)
from hue import Hue new_hue = Hue.discover_one('BasePythonHueClientTestUser', 'PythonHueClientTests') try: result = new_hue.create_user() except Exception: raw_input('Press the link button now, then press enter.') result = new_hue.create_user() print "User %s successfully added. Tests should run now." % result
def test_user_length(): with pytest.raises(Exception): myhue = Hue.discover_one('tooshort', 'PythonHueClientTests')
def test_arg_devicetype(): myhue = Hue.discover_one() assert myhue.devicetype == 'PythonHueClientTests' myhue = Hue.discover_one(devicetype='PythonHueTestClient2') assert myhue.devicetype == 'PythonHueTestClient2'
def testhue(request): return Hue.discover_one('BasePythonHueClientTestUser')