2022-05-18 09:12:24 +02:00
|
|
|
import pytest
|
2022-05-18 17:28:18 +02:00
|
|
|
|
2022-05-18 09:24:51 +02:00
|
|
|
from compose_viz.extends import Extends
|
2022-05-18 09:12:24 +02:00
|
|
|
from compose_viz.service import Service
|
2022-05-18 17:28:18 +02:00
|
|
|
|
|
|
|
|
2022-05-18 09:24:51 +02:00
|
|
|
def test_extend_init():
|
|
|
|
try:
|
2022-05-18 17:28:18 +02:00
|
|
|
Extends(service_name="frontend", from_file="tests/in/000001.yaml")
|
|
|
|
Extends(service_name="frontend")
|
2022-05-18 09:24:51 +02:00
|
|
|
|
|
|
|
assert True
|
2022-05-18 17:28:18 +02:00
|
|
|
except Exception as e:
|
|
|
|
assert False, e
|
2022-05-18 09:24:51 +02:00
|
|
|
|
|
|
|
with pytest.raises(TypeError):
|
2022-05-18 17:28:18 +02:00
|
|
|
Extends(from_file="tests/in/000001.yaml") # type: ignore
|
|
|
|
|
|
|
|
|
2022-05-18 09:24:51 +02:00
|
|
|
def test_service_init():
|
2022-05-18 09:12:24 +02:00
|
|
|
with pytest.raises(ValueError, match=r"Both image and extends are not defined in service 'frontend', aborting."):
|
2022-05-18 17:28:18 +02:00
|
|
|
Service(name="frontend")
|
|
|
|
|
|
|
|
with pytest.raises(
|
|
|
|
ValueError, match=r"Only one of image and extends can be defined in service 'frontend', aborting."
|
|
|
|
):
|
|
|
|
Service(
|
|
|
|
name="frontend", image="image", extends=Extends(service_name="frontend", from_file="tests/in/000001.yaml")
|
|
|
|
)
|