mirror of
https://github.com/yavook/kiwi-scp.git
synced 2024-11-24 21:52:59 +00:00
pytest
This commit is contained in:
parent
3686731f29
commit
b4684998fd
4 changed files with 54 additions and 11 deletions
|
@ -10,17 +10,15 @@ class TestDefault:
|
|||
assert i.config is not None
|
||||
assert len(i.config.projects) == 1
|
||||
|
||||
p = i.config.projects[0]
|
||||
pc = i.config.projects[0]
|
||||
|
||||
assert p.name == "hello-world.project"
|
||||
assert pc.name == "hello-world.project"
|
||||
|
||||
ss = i.get_services(p.name)
|
||||
p = i.get_project("hello-world.project")
|
||||
|
||||
assert len(ss.content) == 5
|
||||
assert p.directory == Path("example/hello-world.project")
|
||||
|
||||
s = ss.content[0]
|
||||
|
||||
assert s.name == "greeter"
|
||||
assert i.get_project("nonexistent") is None
|
||||
|
||||
def test_empty(self):
|
||||
i = Instance()
|
||||
|
|
31
tests/test_project.py
Normal file
31
tests/test_project.py
Normal file
|
@ -0,0 +1,31 @@
|
|||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from kiwi_scp._constants import COMPOSE_FILE_NAME
|
||||
from kiwi_scp.instance import Project
|
||||
|
||||
|
||||
class TestDefault:
|
||||
def test_example(self):
|
||||
p = Project(Path("example/hello-world.project"))
|
||||
|
||||
ss = p.get_services()
|
||||
|
||||
assert len(ss.content) == 5
|
||||
|
||||
s = ss.content[0]
|
||||
|
||||
assert s.name == "greeter"
|
||||
|
||||
ss2 = p.get_services(["nonexistent"])
|
||||
|
||||
assert len(ss2.content) == 0
|
||||
|
||||
def test_empty(self):
|
||||
p = Project(Path("nonexistent"))
|
||||
|
||||
with pytest.raises(FileNotFoundError) as exc_info:
|
||||
p.get_services()
|
||||
|
||||
assert exc_info.value.filename == f"nonexistent/{COMPOSE_FILE_NAME}"
|
|
@ -9,7 +9,7 @@ class TestDefault:
|
|||
def test_empty(self):
|
||||
s = Service(
|
||||
name="s",
|
||||
description=CommentedMap(),
|
||||
content=CommentedMap(),
|
||||
)
|
||||
|
||||
assert s.name == "s"
|
||||
|
@ -18,7 +18,7 @@ class TestDefault:
|
|||
def test_no_configs(self):
|
||||
s = Service(
|
||||
name="s",
|
||||
description=CommentedMap({
|
||||
content=CommentedMap({
|
||||
"image": "repo/image:tag",
|
||||
}),
|
||||
)
|
||||
|
@ -29,7 +29,7 @@ class TestDefault:
|
|||
def test_no_configs_in_volumes(self):
|
||||
s = Service(
|
||||
name="s",
|
||||
description=CommentedMap({
|
||||
content=CommentedMap({
|
||||
"image": "repo/image:tag",
|
||||
"volumes": [
|
||||
"docker_volume/third/dir:/path/to/third/mountpoint",
|
||||
|
@ -45,7 +45,7 @@ class TestDefault:
|
|||
def test_with_configs(self):
|
||||
s = Service(
|
||||
name="s",
|
||||
description=CommentedMap({
|
||||
content=CommentedMap({
|
||||
"image": "repo/image:tag",
|
||||
"volumes": [
|
||||
"${CONFDIR}/some/config:/path/to/some/config",
|
||||
|
|
14
tests/test_services.py
Normal file
14
tests/test_services.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
from ruamel.yaml import CommentedMap
|
||||
|
||||
from kiwi_scp.instance import Service, Services
|
||||
|
||||
|
||||
class TestServices:
|
||||
def test_empty(self):
|
||||
s = Service(
|
||||
name="s",
|
||||
content=CommentedMap(),
|
||||
)
|
||||
ss = Services([s])
|
||||
|
||||
assert str(ss) == "services:\n s: {}"
|
Loading…
Reference in a new issue