-
Notifications
You must be signed in to change notification settings - Fork 484
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit test for depends_on normalization as a dict
Signed-off-by: Hedayat Vatankhah <hedayat.fwd@gmail.com>
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import copy | ||
from podman_compose import normalize_service | ||
|
||
|
||
test_cases_simple = [ | ||
( | ||
{"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(): | ||
for test_case, expected in copy.deepcopy(test_cases_simple): | ||
test_original = copy.deepcopy(test_case) | ||
test_case = normalize_service(test_case) | ||
test_result = expected == test_case | ||
if not test_result: | ||
print("test: ", test_original) | ||
print("expected: ", expected) | ||
print("actual: ", test_case) | ||
assert test_result |