Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def light(raw):
return Device(raw).light_control.lights[0]
def test_binary_division():
dev_ws = Device(LIGHT_WS).light_control.lights[0]
dev_color = Device(LIGHT_CWS).light_control.lights[0]
assert dev_ws.dimmer == 254
assert dev_ws.color_temp == 400
assert dev_color.hex_color == 'f1e0b5'
assert dev_color.xy_color == (30015, 26870)
from pytradfri.device import Device
from devices import (
LIGHT_W, LIGHT_WS, LIGHT_CWS, LIGHT_PHILIPS, REMOTE_CONTROL,
MOTION_SENSOR, OUTLET, BLIND)
@pytest.fixture
def device():
return Device(LIGHT_WS)
input_devices = (
("comment", "device"),
[
("Remote control", Device(REMOTE_CONTROL)),
("Motion sensor", Device(MOTION_SENSOR)),
]
)
output_devices = (
("comment", "device"),
[
("White fixed color bulb", Device(LIGHT_W)),
("White spectrum bulb", Device(LIGHT_WS)),
("Full color bulb", Device(LIGHT_CWS)),
("Philips Hue bulb", Device(LIGHT_PHILIPS)),
]
)
wall_plugs = (
("comment", "device"),
[
def test_socket_state_on(device):
if device.has_socket_control:
socket = Device(device.raw.copy()).socket_control.socket[0]
socket.raw[ATTR_DEVICE_STATE] = 1
assert socket.state is True
def test_light_state_mangled(device):
light = Device(device.raw.copy()).light_control.lights[0]
light.raw[ATTR_DEVICE_STATE] = "RandomString"
assert light.state is False
def device():
return Device(LIGHT_WS)
input_devices = (
("comment", "device"),
[
("Remote control", Device(REMOTE_CONTROL)),
("Motion sensor", Device(MOTION_SENSOR)),
]
)
output_devices = (
("comment", "device"),
[
("White fixed color bulb", Device(LIGHT_W)),
("White spectrum bulb", Device(LIGHT_WS)),
("Full color bulb", Device(LIGHT_CWS)),
("Philips Hue bulb", Device(LIGHT_PHILIPS)),
]
)
wall_plugs = (
("comment", "device"),
[
("Wall plug", Device(OUTLET))
]
)
roller_blinds = (
("comment", "device"),
[
def test_has_light_control_false(device):
dev = Device(device.raw.copy())
dev.raw[ATTR_LIGHT_CONTROL] = {}
assert dev.has_light_control is False
def process_result(result):
return Device(result)