From 5d090fca4508a1ee36ffe0b14d6b5e0ab35c65a4 Mon Sep 17 00:00:00 2001 From: Xyphuz Date: Sat, 21 May 2022 23:00:20 +0800 Subject: [PATCH] test: add test_port.py --- tests/test_port.py | 23 +++++++++++++++++++++++ tests/test_volume.py | 4 ++-- 2 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 tests/test_port.py diff --git a/tests/test_port.py b/tests/test_port.py new file mode 100644 index 0000000..c7baf39 --- /dev/null +++ b/tests/test_port.py @@ -0,0 +1,23 @@ +from compose_viz.port import Port, Protocol + + +def test_port_init_normal() -> None: + try: + p = Port(host_port="8080", container_port="80") + + assert p.host_port == "8080" + assert p.container_port == "80" + assert p.protocol == Protocol.tcp + except Exception as e: + assert False, e + + +def test_port_with_protocol() -> None: + try: + p = Port(host_port="8080", container_port="80", protocol=Protocol.udp) + + assert p.host_port == "8080" + assert p.container_port == "80" + assert p.protocol == Protocol.udp + except Exception as e: + assert False, e diff --git a/tests/test_volume.py b/tests/test_volume.py index a58b56e..8081ae3 100644 --- a/tests/test_volume.py +++ b/tests/test_volume.py @@ -1,7 +1,7 @@ from compose_viz.volume import Volume, VolumeType -def test_extend_init_normal() -> None: +def test_volume_init_normal() -> None: try: v = Volume(source="./foo", target="./bar") @@ -12,7 +12,7 @@ def test_extend_init_normal() -> None: assert False, e -def test_extend_with_type() -> None: +def test_volume_with_type() -> None: try: v = Volume(source="./foo", target="./bar", type=VolumeType.bind)