File: test_normalize_depends_on.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 (45 lines) | stat: -rw-r--r-- 1,444 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
45
from __future__ import annotations

import copy
import unittest
from typing import Any

from parameterized import parameterized

from podman_compose import normalize_service


class TestNormalizeServicesSimple(unittest.TestCase):
    @parameterized.expand([
        (
            {"depends_on": "my_service"},
            {"depends_on": {"my_service": {"condition": "service_started"}}},
        ),
        (
            {"depends_on": ["my_service"]},
            {"depends_on": {"my_service": {"condition": "service_started"}}},
        ),
        (
            {"depends_on": ["my_service1", "my_service2"]},
            {
                "depends_on": {
                    "my_service1": {"condition": "service_started"},
                    "my_service2": {"condition": "service_started"},
                },
            },
        ),
        (
            {"depends_on": {"my_service": {"condition": "service_started"}}},
            {"depends_on": {"my_service": {"condition": "service_started"}}},
        ),
        (
            {"depends_on": {"my_service": {"condition": "service_healthy"}}},
            {"depends_on": {"my_service": {"condition": "service_healthy"}}},
        ),
    ])
    def test_normalize_service_simple(
        self, test_case: dict[str, Any], expected: dict[str, Any]
    ) -> None:
        copy.deepcopy(test_case)
        result = normalize_service(test_case)
        self.assertEqual(result, expected)