-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from oamg/feat/work-with-worker-env-variables
Use env variables passed by rhc during execution command
- Loading branch information
Showing
2 changed files
with
29 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,25 @@ | ||
from mock import patch | ||
from mock import patch, ANY | ||
|
||
from scripts.leapp_script import execute_operation | ||
|
||
|
||
@patch("scripts.leapp_script.run_subprocess", return_value=(b"", 0)) | ||
def test_run_leapp_upgrade(mock_popen): | ||
execute_operation(["fake command"]) | ||
def test_execute_simple_command(mock_popen): | ||
output = execute_operation(["fake command"]) | ||
|
||
mock_popen.assert_called_once_with(["fake command"]) | ||
mock_popen.assert_called_once_with(["fake command"], env=ANY) | ||
assert output == "" | ||
|
||
|
||
def test_execure_custom_variables(): | ||
mock_env = {"FOO": "BAR", "BAR": "BAZ", "RHC_WORKER_LALA": "LAND"} | ||
command = ["/usr/bin/leapp", "preupgrade"] | ||
with patch("os.environ", mock_env), patch( | ||
"scripts.leapp_script.run_subprocess", return_value=(b"", 0) | ||
) as mock_popen: | ||
result = execute_operation(command) | ||
mock_popen.assert_called_once_with( | ||
command, | ||
env={"FOO": "BAR", "BAR": "BAZ", "LALA": "LAND"}, | ||
) | ||
assert result == "" |