MCPcopy
hub / github.com/awslabs/aws-shell / test_edit_handler

Function test_edit_handler

tests/unit/test_app.py:38–57  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

36
37
38def 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
60def test_error_msg_printed_on_error_handler(errstream):

Callers

nothing calls this directly

Calls 2

runMethod · 0.95
PopenLoggerClass · 0.85

Tested by

no test coverage detected