1234567891011121314151617181920212223242526272829303132333435 |
- import unittest.mock
- import pytest
- import intertechno_cc1101._cli
- # pylint: disable=protected-access
- @pytest.mark.parametrize(
- ("argv", "address", "button_index", "turn_on"),
- (
- (["-a", "12345678", "-1"], 12345678, 0, True),
- (["-a", "12345678", "-0"], 12345678, 0, False),
- (["--address", "12345678", "--turn-on"], 12345678, 0, True),
- (["-a", "12345678", "--turn-off"], 12345678, 0, False),
- (["-a", "12345678", "-b", "7", "-1"], 12345678, 7, True),
- ),
- )
- def test__main(argv, address, button_index, turn_on):
- with unittest.mock.patch(
- "intertechno_cc1101.RemoteControl"
- ) as remote_control_class_mock, unittest.mock.patch("sys.argv", [""] + argv):
- intertechno_cc1101._cli._main()
- remote_control_class_mock.assert_called_once_with(address=address)
- if turn_on:
- remote_control_class_mock().turn_on.assert_called_once_with(
- button_index=button_index
- )
- remote_control_class_mock().turn_off.assert_not_called()
- else:
- remote_control_class_mock().turn_off.assert_called_once_with(
- button_index=button_index
- )
- remote_control_class_mock().turn_on.assert_not_called()
|