1
0
Fork 0
mirror of https://github.com/yavook/kiwi-scp.git synced 2024-11-22 04:43:00 +00:00
kiwi-scp/tests/test_instance.py

39 lines
867 B
Python
Raw Normal View History

2021-10-25 11:00:11 +00:00
from pathlib import Path
from kiwi_scp.instance import Instance
2021-10-26 14:11:28 +00:00
class TestDefault:
def test_example(self):
i = Instance(Path("example"))
2021-10-25 11:00:11 +00:00
2021-10-26 14:11:28 +00:00
assert i.config is not None
assert len(i.config.projects) == 1
2021-10-25 11:00:11 +00:00
2021-10-26 14:11:28 +00:00
p = i.config.projects[0]
2021-10-25 11:00:11 +00:00
2021-10-26 14:11:28 +00:00
assert p.name == "hello-world.project"
2021-10-25 11:00:11 +00:00
2021-10-28 13:53:32 +00:00
ss = list(i.get_services(p.name))
2021-10-26 14:19:33 +00:00
2021-10-28 13:53:32 +00:00
assert len(ss) == 5
s = ss[0]
assert s.name == "greeter"
assert s == i.get_service(p.name, s.name)
2021-10-26 14:19:33 +00:00
2021-10-26 14:11:28 +00:00
def test_empty(self):
i = Instance()
2021-10-25 11:00:11 +00:00
2021-10-26 14:11:28 +00:00
assert i.config is not None
assert len(i.config.projects) == 0
2021-10-25 11:00:11 +00:00
2021-10-26 14:11:28 +00:00
def test_no_such_dir(self):
nonexistent_path = Path("nonexistent")
i = Instance(nonexistent_path)
2021-10-25 11:00:11 +00:00
2021-10-26 14:11:28 +00:00
assert i.directory == nonexistent_path
assert i.config is not None
assert len(i.config.projects) == 0