1
0
Fork 0
mirror of https://github.com/yavook/kiwi-scp.git synced 2024-11-24 05:33:00 +00:00
kiwi-scp/tests/test_project.py

41 lines
886 B
Python
Raw Normal View History

2021-11-03 16:35:36 +00:00
from pathlib import Path
import pytest
from kiwi_scp._constants import COMPOSE_FILE_NAME
2021-11-17 15:36:34 +00:00
from kiwi_scp.config import KiwiConfig
2021-12-02 16:08:14 +00:00
from kiwi_scp.project import Project
2021-11-03 16:35:36 +00:00
class TestDefault:
2021-11-17 15:36:34 +00:00
cfg = KiwiConfig()
2021-11-03 16:35:36 +00:00
def test_example(self):
2021-11-17 15:36:34 +00:00
p = Project(
directory=Path("example/hello-world.project"),
2022-01-27 14:26:10 +00:00
parent_instance=None,
2021-11-17 15:36:34 +00:00
)
2021-11-03 16:35:36 +00:00
2021-11-17 15:36:34 +00:00
ss = p.services
2021-11-03 16:35:36 +00:00
assert len(ss.content) == 5
s = ss.content[0]
assert s.name == "greeter"
2021-11-17 15:36:34 +00:00
ss2 = p.services.filter_existing(["nonexistent"])
2021-11-03 16:35:36 +00:00
assert len(ss2.content) == 0
def test_empty(self):
2021-11-17 15:36:34 +00:00
p = Project(
directory=Path("nonexistent"),
2022-01-27 14:26:10 +00:00
parent_instance=None,
2021-11-17 15:36:34 +00:00
)
2021-11-03 16:35:36 +00:00
with pytest.raises(FileNotFoundError) as exc_info:
2021-11-17 15:36:34 +00:00
_ = p.services
2021-11-03 16:35:36 +00:00
assert exc_info.value.filename == f"nonexistent/{COMPOSE_FILE_NAME}"