-
Notifications
You must be signed in to change notification settings - Fork 486
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split exec args parsing into new function and add unit tests for it
Signed-off-by: Ari Pollak <[email protected]>
- Loading branch information
Showing
2 changed files
with
53 additions
and
2 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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# SPDX-License-Identifier: GPL-2.0 | ||
|
||
import argparse | ||
import unittest | ||
|
||
from podman_compose import compose_exec_args | ||
|
||
|
||
class TestExecArgs(unittest.TestCase): | ||
def test_minimal(self): | ||
cnt = get_minimal_container() | ||
args = get_minimal_args() | ||
|
||
result = compose_exec_args(cnt, "container_name", args) | ||
expected = ["--interactive", "--tty", "container_name"] | ||
self.assertEqual(result, expected) | ||
|
||
def test_additional_env_value_equals(self): | ||
cnt = get_minimal_container() | ||
args = get_minimal_args() | ||
args.env = ["key=valuepart1=valuepart2"] | ||
|
||
result = compose_exec_args(cnt, "container_name", args) | ||
expected = [ | ||
"--interactive", | ||
"--tty", | ||
"--env", | ||
"key=valuepart1=valuepart2", | ||
"container_name", | ||
] | ||
self.assertEqual(result, expected) | ||
|
||
|
||
def get_minimal_container(): | ||
return {} | ||
|
||
|
||
def get_minimal_args(): | ||
return argparse.Namespace( | ||
T=None, | ||
cnt_command=None, | ||
env=None, | ||
privileged=None, | ||
user=None, | ||
workdir=None, | ||
) |