Print a message on successful login
This commit is contained in:
parent
612497abb1
commit
05f4d7955b
@ -73,6 +73,7 @@ def login(host):
|
|||||||
username = input('Username: ')
|
username = input('Username: ')
|
||||||
password = getpass.getpass()
|
password = getpass.getpass()
|
||||||
spoc.login(host, username, password)
|
spoc.login(host, username, password)
|
||||||
|
print('Login OK')
|
||||||
|
|
||||||
def prune():
|
def prune():
|
||||||
spoc.prune()
|
spoc.prune()
|
||||||
|
@ -165,12 +165,27 @@ def test_stop_all(stop_all):
|
|||||||
@patch('builtins.input', return_value='someuser')
|
@patch('builtins.input', return_value='someuser')
|
||||||
@patch('getpass.getpass', return_value='somepass')
|
@patch('getpass.getpass', return_value='somepass')
|
||||||
@patch('spoc.login')
|
@patch('spoc.login')
|
||||||
def test_login(login, getpass, nput):
|
def test_login(login, getpass, nput, capsys):
|
||||||
spoc_cli.login('somehost')
|
spoc_cli.login('somehost')
|
||||||
|
|
||||||
nput.assert_called_once_with('Username: ')
|
nput.assert_called_once_with('Username: ')
|
||||||
getpass.assert_called_once()
|
getpass.assert_called_once()
|
||||||
login.assert_called_once_with('somehost', 'someuser', 'somepass')
|
login.assert_called_once_with('somehost', 'someuser', 'somepass')
|
||||||
|
captured = capsys.readouterr()
|
||||||
|
assert captured.out == 'Login OK\n'
|
||||||
|
|
||||||
|
@patch('builtins.input', return_value='someuser')
|
||||||
|
@patch('getpass.getpass', return_value='somepass')
|
||||||
|
@patch('spoc.login', side_effect=requests.ConnectTimeout())
|
||||||
|
def test_login_bad(login, getpass, nput, capsys):
|
||||||
|
with pytest.raises(requests.ConnectTimeout):
|
||||||
|
spoc_cli.login('somehost')
|
||||||
|
|
||||||
|
nput.assert_called_once_with('Username: ')
|
||||||
|
getpass.assert_called_once()
|
||||||
|
login.assert_called_once_with('somehost', 'someuser', 'somepass')
|
||||||
|
captured = capsys.readouterr()
|
||||||
|
assert captured.out == ''
|
||||||
|
|
||||||
@patch('spoc.prune')
|
@patch('spoc.prune')
|
||||||
def test_prune(prune):
|
def test_prune(prune):
|
||||||
|
Loading…
Reference in New Issue
Block a user