Skip to content
This repository has been archived by the owner on Apr 11, 2022. It is now read-only.

Commit

Permalink
#28 add test for error case
Browse files Browse the repository at this point in the history
  • Loading branch information
hjacobs committed Feb 5, 2016
1 parent 8ae9cd3 commit a463c78
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,20 @@ def test_latest(monkeypatch, tmpdir):
monkeypatch.setattr('pierone.api.session.get', MagicMock(return_value=response))
with runner.isolated_filesystem():
result = runner.invoke(cli, ['latest', 'myteam', 'myart'], catch_exceptions=False)
assert '1.0' in result.output
assert '1.0' == result.output.rstrip()


def test_latest_not_found(monkeypatch, tmpdir):
response = MagicMock()
response.raise_for_status.side_effect = Exception('FAIL')
runner = CliRunner()
monkeypatch.setattr('stups_cli.config.load_config', lambda x: {'url': 'https://pierone.example.org'})
monkeypatch.setattr('zign.api.get_token', MagicMock(return_value='tok123'))
monkeypatch.setattr('pierone.api.get_existing_token', MagicMock(return_value={'access_token': 'tok123'}))
monkeypatch.setattr('pierone.api.session.get', MagicMock(return_value=response))
with runner.isolated_filesystem():
result = runner.invoke(cli, ['latest', 'myteam', 'myart'], catch_exceptions=False)
assert 'None' == result.output.rstrip()


def test_url_without_scheme(monkeypatch, tmpdir):
Expand Down

0 comments on commit a463c78

Please sign in to comment.