Skip to content

Commit

Permalink
Add test to cover when terminal is not a TTY
Browse files Browse the repository at this point in the history
  • Loading branch information
jpadilla committed Nov 5, 2017
1 parent 6031675 commit 99c1ee9
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,19 @@ def patched_sys_stdin_read():

assert 'There was an error decoding the token' in str(excinfo.value)

def test_decode_payload_raises_terminal_not_a_tty(self, monkeypatch):
decode_args = ['--key', '1234', 'decode']
parser = build_argparser()
args = parser.parse_args(decode_args)

monkeypatch.setattr(sys.stdin, 'isatty', lambda: False)
monkeypatch.setattr(sys.stdin, 'read', lambda: 'token')

with pytest.raises(IOError) as excinfo:
decode_payload(args)
assert 'Cannot read from stdin: terminal not a TTY' \
in str(excinfo.value)

@pytest.mark.parametrize('key,name,job,exp,verify', [
('1234', 'Vader', 'Sith', None, None),
('4567', 'Anakin', 'Jedi', '+1', None),
Expand Down

0 comments on commit 99c1ee9

Please sign in to comment.