2022-05-18 15:12:24 +08:00
|
|
|
import pytest
|
2022-05-18 23:28:18 +08:00
|
|
|
|
2022-05-18 15:24:51 +08:00
|
|
|
from compose_viz.extends import Extends
|
2022-05-18 23:28:18 +08:00
|
|
|
|
|
|
|
|
2022-05-19 00:41:08 +08:00
|
|
|
def test_extend_init_normal() -> None:
|
2022-05-18 15:24:51 +08:00
|
|
|
try:
|
2022-05-24 16:02:47 +08:00
|
|
|
e = Extends(service_name="frontend", from_file="tests/ymls/others/empty.yaml")
|
2022-05-19 00:38:42 +08:00
|
|
|
|
2022-05-21 17:25:56 +08:00
|
|
|
assert e.service_name == "frontend"
|
2022-05-24 16:02:47 +08:00
|
|
|
assert e.from_file == "tests/ymls/others/empty.yaml"
|
2022-05-19 00:38:42 +08:00
|
|
|
except Exception as e:
|
|
|
|
assert False, e
|
|
|
|
|
|
|
|
|
2022-05-19 00:41:08 +08:00
|
|
|
def test_extend_init_without_from_file() -> None:
|
2022-05-19 00:38:42 +08:00
|
|
|
try:
|
2022-05-21 17:25:56 +08:00
|
|
|
e = Extends(service_name="frontend")
|
2022-05-18 15:24:51 +08:00
|
|
|
|
2022-05-21 17:25:56 +08:00
|
|
|
assert e.service_name == "frontend"
|
|
|
|
assert e.from_file is None
|
2022-05-18 23:28:18 +08:00
|
|
|
except Exception as e:
|
|
|
|
assert False, e
|
2022-05-18 15:24:51 +08:00
|
|
|
|
2022-05-19 00:38:42 +08:00
|
|
|
|
2022-05-19 00:41:08 +08:00
|
|
|
def test_extend_init_without_service_name() -> None:
|
2022-05-18 15:24:51 +08:00
|
|
|
with pytest.raises(TypeError):
|
2022-05-24 16:02:47 +08:00
|
|
|
Extends(from_file="tests/ymls/others/empty.yaml") # type: ignore
|