-
Notifications
You must be signed in to change notification settings - Fork 579
Expand file tree
/
Copy pathtest_compose_exec_args.py
More file actions
55 lines (42 loc) · 1.42 KB
/
test_compose_exec_args.py
File metadata and controls
55 lines (42 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# SPDX-License-Identifier: GPL-2.0
import argparse
import unittest
from podman_compose import compose_exec_args
class TestComposeExecArgs(unittest.TestCase):
def test_minimal(self) -> None:
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) -> None:
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 test_noninteractive(self) -> None:
cnt = get_minimal_container()
args = get_minimal_args()
args.tty = False
result = compose_exec_args(cnt, "container_name", args)
expected = ["container_name"]
self.assertEqual(result, expected)
def get_minimal_container() -> dict:
return {}
def get_minimal_args() -> argparse.Namespace:
return argparse.Namespace(
tty=True,
cnt_command=None,
env=None,
privileged=None,
user=None,
workdir=None,
)