Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 109 additions & 0 deletions tests/test_fritzhomedevicelightbulb.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,18 @@ def test_get_colors(self):
# fmt: on
assert colors == expected_colors

def test_get_colors_NonColorBulb(self):
self.mock.side_effect = [
Helper.response("lightbulb/device_Telekom_Magenta_NonColorBulb")
]

self.fritz.update_devices()
device = self.fritz.get_device_by_ain("12701 0072784")

temps = device.get_colors()
# No colors and no exception
assert temps == {}

def test_get_color_temps(self):
self.mock.side_effect = [
Helper.response("lightbulb/device_FritzDECT500_34_12_16")
Expand All @@ -197,6 +209,18 @@ def test_get_color_temps(self):
]
assert temps == expected_temps

def test_get_color_temps_NonColorBulb(self):
self.mock.side_effect = [
Helper.response("lightbulb/device_Telekom_Magenta_NonColorBulb")
]

self.fritz.update_devices()
device = self.fritz.get_device_by_ain("12701 0072784")

temps = device.get_color_temps()
# No color temps and no exception
assert temps == []

def test_set_color(self):
self.mock.side_effect = [
Helper.response("lightbulb/device_FritzDECT500_34_12_16"),
Expand All @@ -220,6 +244,28 @@ def test_set_color(self):
},
)

def test_set_color_temp(self):
self.mock.side_effect = [
Helper.response("lightbulb/device_FritzDECT500_34_12_16"),
"1",
]

self.fritz.update_devices()
device = self.fritz.get_device_by_ain("12345-1")

device.set_color_temp(3000, 0)

device._fritz._request.assert_called_with(
"http://10.0.0.1/webservices/homeautoswitch.lua",
{
"switchcmd": "setcolortemperature",
"sid": "0000001",
"temperature": 3000,
"duration": 0,
"ain": "12345-1",
},
)

def test_set_unmapped_color(self):
self.mock.side_effect = [
Helper.response("lightbulb/device_FritzDECT500_34_12_16"),
Expand All @@ -242,3 +288,66 @@ def test_set_unmapped_color(self):
"ain": "12345-1",
},
)

def test_set_state_off(self):
self.mock.side_effect = [
Helper.response("lightbulb/device_FritzDECT500_34_12_16"),
"1",
]

self.fritz.update_devices()
device = self.fritz.get_device_by_ain("12345-1")

device.set_state_off()

device._fritz._request.assert_called_with(
"http://10.0.0.1/webservices/homeautoswitch.lua",
{
"switchcmd": "setsimpleonoff",
"sid": "0000001",
"onoff": 0,
"ain": "12345-1",
},
)

def test_set_state_on(self):
self.mock.side_effect = [
Helper.response("lightbulb/device_FritzDECT500_34_12_16"),
"1",
]

self.fritz.update_devices()
device = self.fritz.get_device_by_ain("12345-1")

device.set_state_on()

device._fritz._request.assert_called_with(
"http://10.0.0.1/webservices/homeautoswitch.lua",
{
"switchcmd": "setsimpleonoff",
"sid": "0000001",
"onoff": 1,
"ain": "12345-1",
},
)

def test_set_state_toggle(self):
self.mock.side_effect = [
Helper.response("lightbulb/device_FritzDECT500_34_12_16"),
"1",
]

self.fritz.update_devices()
device = self.fritz.get_device_by_ain("12345-1")

device.set_state_toggle()

device._fritz._request.assert_called_with(
"http://10.0.0.1/webservices/homeautoswitch.lua",
{
"switchcmd": "setsimpleonoff",
"sid": "0000001",
"onoff": 2,
"ain": "12345-1",
},
)
Loading