Skip to content

Commit

Permalink
Use all existing RHC_WORKER variables for script (#66)
Browse files Browse the repository at this point in the history
Signed-off-by: Andrea Waltlova <awaltlov@redhat.com>
  • Loading branch information
andywaltlova authored Mar 12, 2024
1 parent cce38b8 commit be1b37c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
8 changes: 4 additions & 4 deletions scripts/c2r_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,10 +491,10 @@ def run_convert2rhel():
print("Running Convert2RHEL %s" % SCRIPT_TYPE.title())
env = {"PATH": os.environ["PATH"]}

if "RHC_WORKER_CONVERT2RHEL_DISABLE_TELEMETRY" in os.environ:
env["CONVERT2RHEL_DISABLE_TELEMETRY"] = os.environ[
"RHC_WORKER_CONVERT2RHEL_DISABLE_TELEMETRY"
]
for key, value in os.environ.items():
valid_prefix = "RHC_WORKER_"
if key.startswith(valid_prefix):
env[key.replace(valid_prefix, "")] = value

command = ["/usr/bin/convert2rhel"]
if IS_ANALYSIS:
Expand Down
12 changes: 10 additions & 2 deletions tests/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@

@patch("scripts.c2r_script.SCRIPT_TYPE", "CONVERSION")
def test_run_convert2rhel_conversion():
mock_env = {"PATH": "/fake/path", "RHC_WORKER_CONVERT2RHEL_DISABLE_TELEMETRY": "1"}
mock_env = {
"PATH": "/fake/path",
"RHC_WORKER_CONVERT2RHEL_DISABLE_TELEMETRY": "1",
"RHC_WORKER_FOO": "1",
}

with patch("os.environ", mock_env), patch(
"scripts.c2r_script.run_subprocess", return_value=(b"", 0)
Expand All @@ -14,7 +18,11 @@ def test_run_convert2rhel_conversion():

mock_popen.assert_called_once_with(
["/usr/bin/convert2rhel", "-y"],
env={"PATH": "/fake/path", "CONVERT2RHEL_DISABLE_TELEMETRY": "1"},
env={
"PATH": "/fake/path",
"CONVERT2RHEL_DISABLE_TELEMETRY": "1",
"FOO": "1",
},
)


Expand Down

0 comments on commit be1b37c

Please sign in to comment.