|
1 | 1 | import errno |
2 | 2 | import os |
3 | | -import subprocess |
4 | | -from subprocess import PIPE |
5 | | - |
6 | 3 | import pytest |
7 | | -from botocore import credentials |
8 | | -from botocore.exceptions import ClientError |
9 | | -from hypothesis import given |
10 | | -from hypothesis.strategies import lists, text |
11 | | - |
| 4 | +import subprocess |
12 | 5 | from aws_gate import __version__ |
| 6 | +from aws_gate.constants import DEFAULT_GATE_BIN_PATH |
13 | 7 | from aws_gate.exceptions import AWSConnectionError |
14 | 8 | from aws_gate.utils import ( |
15 | 9 | is_existing_profile, |
|
23 | 17 | fetch_instance_details_from_config, |
24 | 18 | get_instance_details, |
25 | 19 | ) |
| 20 | +from botocore import credentials |
| 21 | +from botocore.exceptions import ClientError |
| 22 | +from hypothesis import given |
| 23 | +from hypothesis.strategies import lists, text |
| 24 | +from subprocess import PIPE |
26 | 25 |
|
27 | 26 |
|
28 | 27 | # pylint: disable=too-few-public-methods |
@@ -138,6 +137,16 @@ def test_execute(mocker, cmd, args): |
138 | 137 | assert execute(cmd, args) == "output" |
139 | 138 |
|
140 | 139 |
|
| 140 | +def test_execute_environment(mocker): |
| 141 | + mock_output = mocker.MagicMock(stdout=b"output") |
| 142 | + m = mocker.patch("aws_gate.utils.subprocess.run", return_value=mock_output) |
| 143 | + |
| 144 | + execute("ls", ["-l"]) |
| 145 | + |
| 146 | + assert m.call_args_list[0][1]["env"] is not None |
| 147 | + assert DEFAULT_GATE_BIN_PATH in m.call_args_list[0][1]["env"]["PATH"] |
| 148 | + |
| 149 | + |
141 | 150 | def test_execute_command_exited_with_nonzero_rc(mocker): |
142 | 151 | mock = mocker.patch( |
143 | 152 | "aws_gate.utils.subprocess.run", |
|
0 commit comments