refactor!: drop run_device_action; the media controls are methods (0.2.0)
CI / test (3.10) (push) Successful in 2m20s
CI / test (3.11) (push) Successful in 27s
CI / test (3.12) (push) Successful in 30s
CI / test (3.10) (pull_request) Successful in 2m19s
CI / test (3.11) (pull_request) Successful in 27s
CI / test (3.12) (pull_request) Successful in 29s
CI / test (3.10) (push) Successful in 2m20s
CI / test (3.11) (push) Successful in 27s
CI / test (3.12) (push) Successful in 30s
CI / test (3.10) (pull_request) Successful in 2m19s
CI / test (3.11) (pull_request) Successful in 27s
CI / test (3.12) (pull_request) Successful in 29s
run_device_action dispatched play, pause, stop, next/previous track,
set_volume:N and toggle_mute by string and returned
{success, action, message} instead of the DeviceActionResultDict its
contract names. The typed methods it called (play(), set_volume(), ...)
are the interface; napalm-device-types deprecates run_device_action.
BREAKING CHANGE: run_device_action is removed.
Closes #3
This commit is contained in:
1 parent
95ef8fad42
commit
06dbcf4b83
3 files changed
+7
-85
No files matched your search
+6
-32
@@ -171,37 +171,11 @@ class TestSonosDriver:
|
||||
assert zone["model_name"] == "Sonos One"
|
||||
assert zone["ip_address"] == "192.168.1.100"
|
||||
|
||||
def test_run_device_action_play(self):
|
||||
result = self.driver.run_device_action("play")
|
||||
assert result["success"] is True
|
||||
assert result["action"] == "play"
|
||||
def test_the_media_controls_are_methods_not_a_string_dispatch(self):
|
||||
"""run_device_action returned another shape than its contract and is gone;
|
||||
play(), set_volume() and the others are called directly (netOrk #1105)."""
|
||||
assert not hasattr(type(self.driver), "run_device_action")
|
||||
self.driver.play()
|
||||
self.driver.set_volume(42)
|
||||
self.mock_device.play.assert_called_once()
|
||||
|
||||
def test_run_device_action_pause(self):
|
||||
result = self.driver.run_device_action("pause")
|
||||
assert result["success"] is True
|
||||
self.mock_device.pause.assert_called_once()
|
||||
|
||||
def test_run_device_action_stop(self):
|
||||
result = self.driver.run_device_action("stop")
|
||||
assert result["success"] is True
|
||||
self.mock_device.stop.assert_called_once()
|
||||
|
||||
def test_run_device_action_set_volume(self):
|
||||
result = self.driver.run_device_action("set_volume:42")
|
||||
assert result["success"] is True
|
||||
assert self.mock_device.volume == 42
|
||||
|
||||
def test_run_device_action_set_volume_invalid(self):
|
||||
result = self.driver.run_device_action("set_volume:abc")
|
||||
assert result["success"] is False
|
||||
|
||||
def test_run_device_action_toggle_mute(self):
|
||||
result = self.driver.run_device_action("toggle_mute")
|
||||
assert result["success"] is True
|
||||
assert self.mock_device.mute is True
|
||||
|
||||
def test_run_device_action_unknown(self):
|
||||
result = self.driver.run_device_action("foobar")
|
||||
assert result["success"] is False
|
||||
assert "Unknown" in result["message"]
|
||||
Reference in new issue
Block a user