Print a message on successful login

This commit is contained in:
Disassembler 2021-07-11 16:02:33 +02:00
parent 612497abb1
commit 05f4d7955b
No known key found for this signature in database
GPG Key ID: 524BD33A0EE29499
2 changed files with 17 additions and 1 deletions

View File

@ -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()

View File

@ -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):