mirror of
https://github.com/scito/extract_otp_secret_keys
synced 2024-11-18 09:28:19 +00:00
mock no_args tests
This commit is contained in:
parent
9f0872c2d0
commit
95e7d73173
@ -2,3 +2,4 @@ wheel
|
|||||||
pytest
|
pytest
|
||||||
flake8
|
flake8
|
||||||
pylint
|
pylint
|
||||||
|
pytest-mock
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
cd /extract
|
cd /extract
|
||||||
pip install -U pytest && pytest "$@"
|
pip install -U pytest pytest-mock && pytest "$@"
|
||||||
|
@ -433,8 +433,24 @@ def test_extract_help(capsys):
|
|||||||
assert e.type == SystemExit
|
assert e.type == SystemExit
|
||||||
assert e.value.code == 0
|
assert e.value.code == 0
|
||||||
|
|
||||||
@pytest.mark.skipif(qreader_available, reason="Cannot test interactive mode")
|
def test_extract_no_arguments(capsys, mocker):
|
||||||
def test_extract_no_arguments(capsys):
|
if qreader_available:
|
||||||
|
# Arrange
|
||||||
|
otps = read_json('example_output.json')
|
||||||
|
mocker.patch('extract_otp_secret_keys.extract_otps_from_camera', return_value=otps)
|
||||||
|
|
||||||
|
# Act
|
||||||
|
extract_otp_secret_keys.main(['-c', '-'])
|
||||||
|
|
||||||
|
# Assert
|
||||||
|
captured = capsys.readouterr()
|
||||||
|
|
||||||
|
expected_csv = read_csv('example_output.csv')
|
||||||
|
actual_csv = read_csv_str(captured.out)
|
||||||
|
|
||||||
|
assert actual_csv == expected_csv
|
||||||
|
assert captured.err == ''
|
||||||
|
else:
|
||||||
# Act
|
# Act
|
||||||
with pytest.raises(SystemExit) as e:
|
with pytest.raises(SystemExit) as e:
|
||||||
extract_otp_secret_keys.main([])
|
extract_otp_secret_keys.main([])
|
||||||
|
Loading…
Reference in New Issue
Block a user