Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convert_service_ports takes only a dict as param #3275

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions docker/types/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,11 +560,9 @@ def __init__(self, mode=None, ports=None):


def convert_service_ports(ports):
if isinstance(ports, list):
return ports
if not isinstance(ports, dict):
raise TypeError(
'Invalid type for ports, expected dict or list'
'Invalid type for ports, expected dict'
)

result = []
Expand Down
6 changes: 6 additions & 0 deletions tests/unit/dockertypes_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,3 +491,9 @@ def test_convert_service_ports_multiple(self):
} in converted_ports

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)