2022-05-27 14:17:04 +08:00
|
|
|
from compose_viz.models.port import Port, Protocol
|
2022-05-21 23:00:20 +08:00
|
|
|
|
|
|
|
|
|
|
|
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"
|
2022-05-24 16:02:47 +08:00
|
|
|
assert p.protocol == Protocol.any
|
2022-05-21 23:00:20 +08:00
|
|
|
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
|