|
5 | 5 | from pathlib import Path
|
6 | 6 |
|
7 | 7 | from tests.integration.test_utils import RunSubprocessMixin
|
8 |
| - |
9 |
| - |
10 |
| -def base_path(): |
11 |
| - """Returns the base path for the project""" |
12 |
| - return Path(__file__).parent.parent.parent |
13 |
| - |
14 |
| - |
15 |
| -def test_path(): |
16 |
| - """Returns the path to the tests directory""" |
17 |
| - return os.path.join(base_path(), "tests/integration") |
18 |
| - |
19 |
| - |
20 |
| -def podman_compose_path(): |
21 |
| - """Returns the path to the podman compose script""" |
22 |
| - return os.path.join(base_path(), "podman_compose.py") |
23 |
| - |
24 |
| - |
25 |
| -class TestPodmanCompose(unittest.TestCase, RunSubprocessMixin): |
26 |
| - def test_extends_w_file_subdir(self): |
| 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(): |
| 13 | + return os.path.join(os.path.join(test_path(), "extends_w_file_subdir"), "docker-compose.yml") |
| 14 | + |
| 15 | + |
| 16 | +class TestComposeExtendsWithFileSubdir(unittest.TestCase, RunSubprocessMixin): |
| 17 | + def test_extends_w_file_subdir(self): # when file is Dockerfile for building the image |
| 18 | + try: |
| 19 | + self.run_subprocess_assert_returncode( |
| 20 | + [ |
| 21 | + podman_compose_path(), |
| 22 | + "-f", |
| 23 | + compose_yaml_path(), |
| 24 | + "up", |
| 25 | + ], |
| 26 | + ) |
| 27 | + output, _ = self.run_subprocess_assert_returncode([ |
| 28 | + podman_compose_path(), |
| 29 | + "-f", |
| 30 | + compose_yaml_path(), |
| 31 | + "ps", |
| 32 | + ]) |
| 33 | + self.assertIn("extends_w_file_subdir_web_1", str(output)) |
| 34 | + finally: |
| 35 | + self.run_subprocess_assert_returncode([ |
| 36 | + podman_compose_path(), |
| 37 | + "-f", |
| 38 | + compose_yaml_path(), |
| 39 | + "down", |
| 40 | + ]) |
| 41 | + |
| 42 | + def test_podman_compose_extends_w_file_subdir(self): |
27 | 43 | """
|
28 | 44 | Test that podman-compose can execute podman-compose -f <file> up with extended File which
|
29 | 45 | includes a build context
|
30 | 46 | :return:
|
31 | 47 | """
|
32 |
| - main_path = Path(__file__).parent.parent.parent |
| 48 | + main_path = Path(__file__).parent.parent.parent.parent |
33 | 49 |
|
34 | 50 | command_up = [
|
35 | 51 | "coverage",
|
@@ -86,26 +102,3 @@ def test_extends_w_file_subdir(self):
|
86 | 102 | # check container did not exists anymore
|
87 | 103 | out, _ = self.run_subprocess_assert_returncode(command_check_container)
|
88 | 104 | self.assertEqual(out, b'')
|
89 |
| - |
90 |
| - def test_extends_w_empty_service(self): |
91 |
| - """ |
92 |
| - Test that podman-compose can execute podman-compose -f <file> up with extended File which |
93 |
| - includes an empty service. (e.g. if the file is used as placeholder for more complex |
94 |
| - configurations.) |
95 |
| - """ |
96 |
| - main_path = Path(__file__).parent.parent.parent |
97 |
| - |
98 |
| - command_up = [ |
99 |
| - "python3", |
100 |
| - str(main_path.joinpath("podman_compose.py")), |
101 |
| - "-f", |
102 |
| - str( |
103 |
| - main_path.joinpath( |
104 |
| - "tests", "integration", "extends_w_empty_service", "docker-compose.yml" |
105 |
| - ) |
106 |
| - ), |
107 |
| - "up", |
108 |
| - "-d", |
109 |
| - ] |
110 |
| - |
111 |
| - self.run_subprocess_assert_returncode(command_up) |
0 commit comments