-
Notifications
You must be signed in to change notification settings - Fork 617
Expand file tree
/
Copy pathtest_podman_compose_run.py
More file actions
89 lines (78 loc) · 2.86 KB
/
Copy pathtest_podman_compose_run.py
File metadata and controls
89 lines (78 loc) · 2.86 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# SPDX-License-Identifier: GPL-2.0
import os
import subprocess
import unittest
from tests.integration.test_utils import RunSubprocessMixin
from tests.integration.test_utils import podman_compose_path
from tests.integration.test_utils import test_path
def compose_yaml_path() -> str:
"""Returns the path to the compose file used for this test module"""
base_path = os.path.join(test_path(), "run_tty")
return os.path.join(base_path, "docker-compose.yml")
class TestComposeExtraHosts(unittest.TestCase, RunSubprocessMixin):
def test_exec(self) -> None:
script_installed = (
subprocess.run(["script", "--version"], stdout=subprocess.DEVNULL).returncode == 0
)
self.run_subprocess_assert_returncode([
podman_compose_path(),
"-f",
compose_yaml_path(),
"build",
"--no-cache",
])
# TTY auto detected (no tty)
self.run_subprocess_assert_returncode(
[
podman_compose_path(),
"-f",
compose_yaml_path(),
"run",
"web1",
"tty",
"-s",
],
expected_returncode=1, # exit code 1 == no tty
)
# TTY auto detected (tty emulated by 'script' command)
if script_installed:
self.run_subprocess_assert_returncode(
[
"script",
"--return",
"--quiet",
"--log-out",
"/dev/null",
"--command",
f"{podman_compose_path()} -f {compose_yaml_path()} run web1 tty -s",
],
expected_returncode=0, # exit code 0 == tty
)
# TTY disabled (even though an emulated tty is available through the 'script' command)
if script_installed:
self.run_subprocess_assert_returncode(
[
"script",
"--return",
"--quiet",
"--log-out",
"/dev/null",
"--command",
f"{podman_compose_path()} -f {compose_yaml_path()} run --no-tty web1 tty -s",
],
expected_returncode=1, # exit code 1 == no tty
)
# TTY enabled (tty emulated by 'script' command)
if script_installed:
self.run_subprocess_assert_returncode(
[
"script",
"--return",
"--log-out",
"/dev/null",
"--quiet",
"--command",
f"{podman_compose_path()} -f {compose_yaml_path()} run --tty web1 tty -s",
],
expected_returncode=0, # exit code 0 == tty
)