40 lines
1.0 KiB
Python
40 lines
1.0 KiB
Python
from radiuma_api.io_port import InPort, OutPort, ImageType, TextType, CompatibilityException
|
|
# Codes Go Below:
|
|
|
|
|
|
def test_compatible_ports():
|
|
"""Ports with the same DType must connect successfully."""
|
|
outp = OutPort("o", ImageType())
|
|
inp = InPort("i", ImageType())
|
|
|
|
outp.connect(inp)
|
|
|
|
assert inp.connected_output == outp
|
|
|
|
|
|
def test_incompatible_ports():
|
|
"""Connecting mismatched DTypes must raise CompatibilityException."""
|
|
outp = OutPort("o", ImageType())
|
|
inp = InPort("i", TextType())
|
|
|
|
try:
|
|
outp.connect(inp)
|
|
assert False, "Expected CompatibilityException"
|
|
except CompatibilityException:
|
|
assert True
|
|
|
|
|
|
def test_outport_single_connection_limit():
|
|
"""OutPort must not allow more than one connection."""
|
|
outp = OutPort("o", ImageType())
|
|
inp1 = InPort("i1", ImageType())
|
|
inp2 = InPort("i2", ImageType())
|
|
|
|
outp.connect(inp1)
|
|
|
|
try:
|
|
outp.connect(inp2)
|
|
assert False, "Expected OutPort max connections error"
|
|
except CompatibilityException:
|
|
assert True
|