Skip to content

Commit b314ba9

Browse files
minrkconsideRatio
authored andcommitted
test new port argument possibilities
1 parent 6826d72 commit b314ba9

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

tests/unit/test_args.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"""
44
import os
55
import pytest
6-
import logging
76
from repo2docker.__main__ import make_r2d
87
from repo2docker import __version__
98

@@ -71,10 +70,6 @@ def test_run_required():
7170
with pytest.raises(SystemExit):
7271
make_r2d(["--no-run", "-p", "8000:8000", "."])
7372

74-
# Can't publish any ports while running if we don't specify a command explicitly
75-
with pytest.raises(SystemExit):
76-
make_r2d(["-p", "8000:8000", "."])
77-
7873

7974
def test_clean():
8075
"""

tests/unit/test_ports.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import pytest
1414

1515
from repo2docker.app import Repo2Docker
16+
from repo2docker.__main__ import make_r2d
1617

1718

1819
def read_port_mapping_response(
@@ -95,7 +96,7 @@ def _cleanup():
9596
else:
9697
break
9798
else:
98-
pytest.fail("Never succeded in talking to %s" % url)
99+
pytest.fail("Never succeeded in talking to %s" % url)
99100
assert "Directory listing" in r.text
100101

101102

@@ -113,3 +114,16 @@ def test_port_mapping(request, tmpdir, host, protocol):
113114
"""Test a port mapping"""
114115
port = str(random.randint(50000, 51000))
115116
read_port_mapping_response(request, tmpdir, host=host, port=port, protocol=protocol)
117+
118+
119+
@pytest.mark.parametrize(
120+
"port_str, port_dict",
121+
[
122+
("8000", {"8000/tcp": "8000"}),
123+
("8000:9000", {"9000/tcp": "8000"}),
124+
("127.0.0.1:8000:9000", {"9000/tcp": ("127.0.0.1", "8000")}),
125+
],
126+
)
127+
def test_port_args(port_str, port_dict):
128+
app = make_r2d(["-p", port_str, "."])
129+
assert app.ports == port_dict

0 commit comments

Comments
 (0)