Skip to content

Commit fc02771

Browse files
committed
tests: Rewrite test_normalize_depends_on to unittest
This test was forgotten about during initial migration.
1 parent b86f8b1 commit fc02771

File tree

1 file changed

+40
-38
lines changed

1 file changed

+40
-38
lines changed
Lines changed: 40 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,45 @@
1+
from __future__ import annotations
2+
13
import copy
4+
import unittest
5+
from typing import Any
26

3-
from podman_compose import normalize_service
7+
from parameterized import parameterized
48

5-
test_cases_simple = [
6-
(
7-
{"depends_on": "my_service"},
8-
{"depends_on": {"my_service": {"condition": "service_started"}}},
9-
),
10-
(
11-
{"depends_on": ["my_service"]},
12-
{"depends_on": {"my_service": {"condition": "service_started"}}},
13-
),
14-
(
15-
{"depends_on": ["my_service1", "my_service2"]},
16-
{
17-
"depends_on": {
18-
"my_service1": {"condition": "service_started"},
19-
"my_service2": {"condition": "service_started"},
20-
},
21-
},
22-
),
23-
(
24-
{"depends_on": {"my_service": {"condition": "service_started"}}},
25-
{"depends_on": {"my_service": {"condition": "service_started"}}},
26-
),
27-
(
28-
{"depends_on": {"my_service": {"condition": "service_healthy"}}},
29-
{"depends_on": {"my_service": {"condition": "service_healthy"}}},
30-
),
31-
]
9+
from podman_compose import normalize_service
3210

3311

34-
def test_normalize_service_simple():
35-
for test_case, expected in copy.deepcopy(test_cases_simple):
36-
test_original = copy.deepcopy(test_case)
37-
test_case = normalize_service(test_case)
38-
test_result = expected == test_case
39-
if not test_result:
40-
print("test: ", test_original)
41-
print("expected: ", expected)
42-
print("actual: ", test_case)
43-
assert test_result
12+
class TestNormalizeServicesSimple(unittest.TestCase):
13+
@parameterized.expand([
14+
(
15+
{"depends_on": "my_service"},
16+
{"depends_on": {"my_service": {"condition": "service_started"}}},
17+
),
18+
(
19+
{"depends_on": ["my_service"]},
20+
{"depends_on": {"my_service": {"condition": "service_started"}}},
21+
),
22+
(
23+
{"depends_on": ["my_service1", "my_service2"]},
24+
{
25+
"depends_on": {
26+
"my_service1": {"condition": "service_started"},
27+
"my_service2": {"condition": "service_started"},
28+
},
29+
},
30+
),
31+
(
32+
{"depends_on": {"my_service": {"condition": "service_started"}}},
33+
{"depends_on": {"my_service": {"condition": "service_started"}}},
34+
),
35+
(
36+
{"depends_on": {"my_service": {"condition": "service_healthy"}}},
37+
{"depends_on": {"my_service": {"condition": "service_healthy"}}},
38+
),
39+
])
40+
def test_normalize_service_simple(
41+
self, test_case: dict[str, Any], expected: dict[str, Any]
42+
) -> None:
43+
copy.deepcopy(test_case)
44+
result = normalize_service(test_case)
45+
self.assertEqual(result, expected)

0 commit comments

Comments
 (0)