Debian Codegraph @

tests/integration/interpolation/test_podman_compose_interpolation.py

raw symbols SCIP
1 # SPDX-License-Identifier: GPL-2.0
2
3 import json
4 import os
5 import unittest
6
7 from tests.integration.test_utils import RunSubprocessMixin
8 from tests.integration.test_utils import podman_compose_path
9 from tests.integration.test_utils import test_path
10
11
12 def compose_yaml_path() -> str:
13 return os.path.join(os.path.join(test_path(), "interpolation"), "docker-compose.yml")
14
15
16 class TestComposeInterpolation(unittest.TestCase, RunSubprocessMixin):
17 def test_interpolation(self) -> None:
18 try:
19 self.run_subprocess_assert_returncode([
20 "env",
21 "EXAMPLE_VARIABLE_USER=test_user",
22 podman_compose_path(),
23 "-f",
24 compose_yaml_path(),
25 "up",
26 ])
27 output, _ = self.run_subprocess_assert_returncode([
28 podman_compose_path(),
29 "-f",
30 compose_yaml_path(),
31 "logs",
32 ])
33 self.assertIn("EXAMPLE_VARIABLE='Host user: test_user'", str(output))
34 self.assertIn("EXAMPLE_BRACES='Host user: test_user'", str(output))
35 self.assertIn("EXAMPLE_COLON_DASH_DEFAULT='My default'", str(output))
36 self.assertIn("EXAMPLE_DASH_DEFAULT='My other default'", str(output))
37 self.assertIn("EXAMPLE_DOT_ENV='This value is from the .env file'", str(output))
38 self.assertIn("EXAMPLE_EMPTY=''", str(output))
39 self.assertIn("EXAMPLE_LITERAL='This is a $literal'", str(output))
40
41 output, _ = self.run_subprocess_assert_returncode([
42 "podman",
43 "inspect",
44 "interpolation_labels_test_1",
45 ])
46 inspect_output = json.loads(output)
47 labels_dict = inspect_output[0].get("Config", {}).get("Labels", {})
48 self.assertIn(('TEST', 'test_labels'), labels_dict.items())
49 self.assertIn(('TEST.test2', 'test2(`TEST`)'), labels_dict.items())
50 self.assertIn(('test.TEST', 'TEST'), labels_dict.items())
51
52 finally:
53 self.run_subprocess_assert_returncode([
54 podman_compose_path(),
55 "-f",
56 compose_yaml_path(),
57 "down",
58 ])