convert_service_ports takes only a dict as param

Signed-off-by: billou <nabil.benyoussef@gmail.com>
This commit is contained in:
billou 2024-07-12 22:05:55 -04:00
parent a3652028b1
commit bc5bcdade5
2 changed files with 7 additions and 3 deletions

View File

@ -560,11 +560,9 @@ class EndpointSpec(dict):
def convert_service_ports(ports): def convert_service_ports(ports):
if isinstance(ports, list):
return ports
if not isinstance(ports, dict): if not isinstance(ports, dict):
raise TypeError( raise TypeError(
'Invalid type for ports, expected dict or list' 'Invalid type for ports, expected dict'
) )
result = [] result = []

View File

@ -491,3 +491,9 @@ class ServicePortsTest(unittest.TestCase):
} in converted_ports } in converted_ports
assert len(converted_ports) == 3 assert len(converted_ports) == 3
def test_convert_service_ports_wrong_ports_type(self):
ports = 'ports_as_string'
with pytest.raises(TypeError):
convert_service_ports(ports)