File: test_podman_compose_additional_contexts.py

package info (click to toggle)
podman-compose 1.5.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,004 kB
  • sloc: python: 10,946; sh: 107; javascript: 48; makefile: 13
file content (44 lines) | stat: -rw-r--r-- 1,343 bytes parent folder | download
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
# SPDX-License-Identifier: GPL-2.0


"""Test how additional contexts are passed to podman."""

import os
import subprocess
import unittest

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"""
    return os.path.join(test_path(), "additional_contexts", "project")


class TestComposeBuildAdditionalContexts(unittest.TestCase):
    def test_build_additional_context(self) -> None:
        """podman build should receive additional contexts as --build-context

        See additional_context/project/docker-compose.yaml for context paths
        """
        cmd = (
            "coverage",
            "run",
            podman_compose_path(),
            "--dry-run",
            "--verbose",
            "-f",
            os.path.join(compose_yaml_path(), "docker-compose.yml"),
            "build",
        )
        p = subprocess.run(
            cmd,
            stdout=subprocess.PIPE,
            check=False,
            stderr=subprocess.STDOUT,
            text=True,
        )
        self.assertEqual(p.returncode, 0)
        self.assertIn("--build-context=data=../data_for_dict", p.stdout)
        self.assertIn("--build-context=data=../data_for_list", p.stdout)