|
2 | 2 |
|
3 | 3 | from unittest.mock import Mock, ANY, patch |
4 | 4 | from serial import SerialException |
5 | | -from nrfcredstore.cli import main, parse_args, FUN_MODE_OFFLINE |
| 5 | +from nrfcredstore.cli import main, parse_args, run, FUN_MODE_OFFLINE |
6 | 6 |
|
7 | 7 | from nrfcredstore.credstore import CredType |
8 | 8 | from nrfcredstore.exceptions import NoATClientException, ATCommandError |
@@ -32,6 +32,9 @@ def test_non_responsive_device(self, credstore, command_interface): |
32 | 32 | main(parse_args(['fakedev', 'list']), credstore) |
33 | 33 | assert e.type == TimeoutError |
34 | 34 |
|
| 35 | + def test_non_responsive_device(self, credstore, command_interface, empty_cred_list): |
| 36 | + command_interface.detect_shell_mode.enable_error_codes.return_value = False |
| 37 | + main(parse_args(['fakedev', 'list']), credstore) |
35 | 38 |
|
36 | 39 | def test_list_default(self, credstore, empty_cred_list): |
37 | 40 | main(parse_args(['fakedev', 'list']), credstore) |
@@ -117,6 +120,9 @@ def test_at_command_error_exit_code(self, credstore): |
117 | 120 | main(parse_args(['fakedev', 'list']), credstore) |
118 | 121 | assert e.type == RuntimeError |
119 | 122 |
|
120 | | -# plan for new tests: |
121 | | -# Comms cannot find device |
122 | | -# Comms cannot enable error codes |
| 123 | + def test_cannot_find_device(self): |
| 124 | + with patch("nrfcredstore.comms.__init__", return_value=Mock()) as mock_comms: |
| 125 | + mock_comms.side_effect = Exception("No device found") |
| 126 | + with pytest.raises(Exception) as e: |
| 127 | + run(['nrfcredstore', 'fakedev', 'list']) |
| 128 | + assert e.type == Exception |
0 commit comments