예제 #1
0
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'}
예제 #2
0
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]'
예제 #3
0
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')
예제 #4
0
def test_nmcli_when_failed_with_unspecified():
    run = DummySubprocessRunner(return_code=1)
    s = SystemCommand(run)

    with pytest.raises(UnspecifiedException):
        s.nmcli('connection')
예제 #5
0
def test_nmcli_when_failed_with_not_exist():
    run = DummySubprocessRunner(return_code=10)
    s = SystemCommand(run)

    with pytest.raises(NotExistException):
        s.nmcli('connection')
예제 #6
0
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')
예제 #7
0
def test_nmcli_when_failed_with_connection_delete():
    run = DummySubprocessRunner(return_code=7)
    s = SystemCommand(run)

    with pytest.raises(ConnectionDeleteFailedException):
        s.nmcli('connection')
예제 #8
0
def test_nmcli_when_failed_with_disconnect_device():
    run = DummySubprocessRunner(return_code=6)
    s = SystemCommand(run)

    with pytest.raises(DisconnectDeviceFailedException):
        s.nmcli('connection')
예제 #9
0
def test_nmcli_when_failed_with_timeout_expired():
    run = DummySubprocessRunner(return_code=3)
    s = SystemCommand(run)

    with pytest.raises(TimeoutExpiredException):
        s.nmcli('connection')
예제 #10
0
def test_nmcli_when_failed_with_invalid_user_input():
    run = DummySubprocessRunner(return_code=2)
    s = SystemCommand(run)

    with pytest.raises(InvalidUserInputException):
        s.nmcli('connection')
예제 #11
0
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']
예제 #12
0
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']
예제 #13
0
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']