()
| 36 | |
| 37 | |
| 38 | def test_edit_handler(): |
| 39 | env = {'EDITOR': 'my-editor'} |
| 40 | popen_cls = mock.Mock() |
| 41 | application = mock.Mock() |
| 42 | application.history = [ |
| 43 | '!ls', |
| 44 | '.edit', |
| 45 | 'aws ec2 describe-instances', |
| 46 | 'aws ec2 allocate-hosts', |
| 47 | ] |
| 48 | popen = PopenLogger() |
| 49 | handler = app.EditHandler(popen, env) |
| 50 | handler.run(['.edit'], application) |
| 51 | # Ensure our editor was called with some arbitrary temp filename. |
| 52 | command_run = popen.cmd |
| 53 | assert len(command_run) == 2 |
| 54 | assert command_run[0] == 'my-editor' |
| 55 | # Ensure the contents of the temp file are correct |
| 56 | expected_contents = 'aws ec2 describe-instances\naws ec2 allocate-hosts' |
| 57 | assert popen.contents == expected_contents |
| 58 | |
| 59 | |
| 60 | def test_error_msg_printed_on_error_handler(errstream): |
nothing calls this directly
no test coverage detected