Merge pull request #1212 from p12tic/normalize-depends-unittest

tests: Rewrite test_normalize_depends_on to unittest
This commit is contained in:
Povilas Kanapickas 2025-05-19 18:26:45 +03:00 committed by GitHub
commit f5e3162e91
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,8 +1,16 @@
from __future__ import annotations
import copy import copy
import unittest
from typing import Any
from parameterized import parameterized
from podman_compose import normalize_service from podman_compose import normalize_service
test_cases_simple = [
class TestNormalizeServicesSimple(unittest.TestCase):
@parameterized.expand([
( (
{"depends_on": "my_service"}, {"depends_on": "my_service"},
{"depends_on": {"my_service": {"condition": "service_started"}}}, {"depends_on": {"my_service": {"condition": "service_started"}}},
@ -28,16 +36,10 @@ test_cases_simple = [
{"depends_on": {"my_service": {"condition": "service_healthy"}}}, {"depends_on": {"my_service": {"condition": "service_healthy"}}},
{"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]
def test_normalize_service_simple(): ) -> None:
for test_case, expected in copy.deepcopy(test_cases_simple): copy.deepcopy(test_case)
test_original = copy.deepcopy(test_case) result = normalize_service(test_case)
test_case = normalize_service(test_case) self.assertEqual(result, expected)
test_result = expected == test_case
if not test_result:
print("test: ", test_original)
print("expected: ", expected)
print("actual: ", test_case)
assert test_result