def test_set_lang(): run = DummySubprocessRunner(stdout=b'test') s = SystemCommand(run) s.set_lang('C.UTF-8') assert s.nmcli('connection') == 'test' assert run.passed_args == ['sudo', 'nmcli', 'connection'] assert run.passed_env == {'LANG': 'C.UTF-8'}
def test_nmcli_when_failed_with_unspecified(): run = DummySubprocessRunner(return_code=1, stderr=b'error') s = SystemCommand(run) with pytest.raises(UnspecifiedException) as e: s.nmcli('connection') assert str( e.value) == 'Unknown or unspecified error [code:1, detail:error]'
def test_nmcli_when_failed_with_scanning_not_allowed(): run = DummySubprocessRunner( return_code=1, stderr= b'Error: Scanning not allowed immediately following previous scan.') s = SystemCommand(run) with pytest.raises(ScanningNotAllowedException): s.nmcli('connection')
def test_nmcli_when_failed_with_unspecified(): run = DummySubprocessRunner(return_code=1) s = SystemCommand(run) with pytest.raises(UnspecifiedException): s.nmcli('connection')
def test_nmcli_when_failed_with_not_exist(): run = DummySubprocessRunner(return_code=10) s = SystemCommand(run) with pytest.raises(NotExistException): s.nmcli('connection')
def test_nmcli_when_failed_with_network_manager_not_running(): run = DummySubprocessRunner(return_code=8) s = SystemCommand(run) with pytest.raises(NetworkManagerNotRunningException): s.nmcli('connection')
def test_nmcli_when_failed_with_connection_delete(): run = DummySubprocessRunner(return_code=7) s = SystemCommand(run) with pytest.raises(ConnectionDeleteFailedException): s.nmcli('connection')
def test_nmcli_when_failed_with_disconnect_device(): run = DummySubprocessRunner(return_code=6) s = SystemCommand(run) with pytest.raises(DisconnectDeviceFailedException): s.nmcli('connection')
def test_nmcli_when_failed_with_timeout_expired(): run = DummySubprocessRunner(return_code=3) s = SystemCommand(run) with pytest.raises(TimeoutExpiredException): s.nmcli('connection')
def test_nmcli_when_failed_with_invalid_user_input(): run = DummySubprocessRunner(return_code=2) s = SystemCommand(run) with pytest.raises(InvalidUserInputException): s.nmcli('connection')
def test_nmcli_when_successed_with_list_args(): run = DummySubprocessRunner(stdout=b'test') s = SystemCommand(run) assert s.nmcli(['device', 'wifi']) == 'test' assert run.passed_args == ['sudo', 'nmcli', 'device', 'wifi']
def test_nmcli_when_successed(): run = DummySubprocessRunner(stdout=b'test') s = SystemCommand(run) assert s.nmcli('connection') == 'test' assert run.passed_args == ['sudo', 'nmcli', 'connection']
def test_disable_use_sudo(): run = DummySubprocessRunner(stdout=b'test') s = SystemCommand(run) s.disable_use_sudo() assert s.nmcli('connection') == 'test' assert run.passed_args == ['nmcli', 'connection']