Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
docker-py
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
docker-py
Commits
24f75ea2
Kaydet (Commit)
24f75ea2
authored
Mar 13, 2017
tarafından
Joffrey F
Kaydeden (comit)
GitHub
Mar 13, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge pull request #1500 from shin-/fix_split_port_empty_string
Raise an error when passing an empty string to split_port
üst
4011fa7d
54b3c364
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
43 deletions
+48
-43
ports.py
docker/utils/ports.py
+2
-0
api_client_test.py
tests/integration/api_client_test.py
+1
-43
api_container_test.py
tests/integration/api_container_test.py
+42
-0
utils_test.py
tests/unit/utils_test.py
+3
-0
No files found.
docker/utils/ports.py
Dosyayı görüntüle @
24f75ea2
...
...
@@ -67,6 +67,8 @@ def split_port(port):
if
len
(
parts
)
==
1
:
internal_port
,
=
parts
if
not
internal_port
:
_raise_invalid_port
(
port
)
return
to_port_range
(
internal_port
),
None
if
len
(
parts
)
==
2
:
external_port
,
internal_port
=
parts
...
...
tests/integration/api_client_test.py
Dosyayı görüntüle @
24f75ea2
...
...
@@ -8,7 +8,7 @@ import warnings
import
docker
from
docker.utils
import
kwargs_from_env
from
.base
import
BaseAPIIntegrationTest
,
BUSYBOX
from
.base
import
BaseAPIIntegrationTest
class
InformationTest
(
BaseAPIIntegrationTest
):
...
...
@@ -25,48 +25,6 @@ class InformationTest(BaseAPIIntegrationTest):
self
.
assertIn
(
'Debug'
,
res
)
class
LinkTest
(
BaseAPIIntegrationTest
):
def
test_remove_link
(
self
):
# Create containers
container1
=
self
.
client
.
create_container
(
BUSYBOX
,
'cat'
,
detach
=
True
,
stdin_open
=
True
)
container1_id
=
container1
[
'Id'
]
self
.
tmp_containers
.
append
(
container1_id
)
self
.
client
.
start
(
container1_id
)
# Create Link
# we don't want the first /
link_path
=
self
.
client
.
inspect_container
(
container1_id
)[
'Name'
][
1
:]
link_alias
=
'mylink'
container2
=
self
.
client
.
create_container
(
BUSYBOX
,
'cat'
,
host_config
=
self
.
client
.
create_host_config
(
links
=
{
link_path
:
link_alias
}
)
)
container2_id
=
container2
[
'Id'
]
self
.
tmp_containers
.
append
(
container2_id
)
self
.
client
.
start
(
container2_id
)
# Remove link
linked_name
=
self
.
client
.
inspect_container
(
container2_id
)[
'Name'
][
1
:]
link_name
=
'
%
s/
%
s'
%
(
linked_name
,
link_alias
)
self
.
client
.
remove_container
(
link_name
,
link
=
True
)
# Link is gone
containers
=
self
.
client
.
containers
(
all
=
True
)
retrieved
=
[
x
for
x
in
containers
if
link_name
in
x
[
'Names'
]]
self
.
assertEqual
(
len
(
retrieved
),
0
)
# Containers are still there
retrieved
=
[
x
for
x
in
containers
if
x
[
'Id'
]
.
startswith
(
container1_id
)
or
x
[
'Id'
]
.
startswith
(
container2_id
)
]
self
.
assertEqual
(
len
(
retrieved
),
2
)
class
LoadConfigTest
(
BaseAPIIntegrationTest
):
def
test_load_legacy_config
(
self
):
folder
=
tempfile
.
mkdtemp
()
...
...
tests/integration/api_container_test.py
Dosyayı görüntüle @
24f75ea2
...
...
@@ -1253,3 +1253,45 @@ class ContainerCPUTest(BaseAPIIntegrationTest):
self
.
client
.
start
(
container
)
inspect_data
=
self
.
client
.
inspect_container
(
container
)
self
.
assertEqual
(
inspect_data
[
'HostConfig'
][
'CpusetCpus'
],
cpuset_cpus
)
class
LinkTest
(
BaseAPIIntegrationTest
):
def
test_remove_link
(
self
):
# Create containers
container1
=
self
.
client
.
create_container
(
BUSYBOX
,
'cat'
,
detach
=
True
,
stdin_open
=
True
)
container1_id
=
container1
[
'Id'
]
self
.
tmp_containers
.
append
(
container1_id
)
self
.
client
.
start
(
container1_id
)
# Create Link
# we don't want the first /
link_path
=
self
.
client
.
inspect_container
(
container1_id
)[
'Name'
][
1
:]
link_alias
=
'mylink'
container2
=
self
.
client
.
create_container
(
BUSYBOX
,
'cat'
,
host_config
=
self
.
client
.
create_host_config
(
links
=
{
link_path
:
link_alias
}
)
)
container2_id
=
container2
[
'Id'
]
self
.
tmp_containers
.
append
(
container2_id
)
self
.
client
.
start
(
container2_id
)
# Remove link
linked_name
=
self
.
client
.
inspect_container
(
container2_id
)[
'Name'
][
1
:]
link_name
=
'
%
s/
%
s'
%
(
linked_name
,
link_alias
)
self
.
client
.
remove_container
(
link_name
,
link
=
True
)
# Link is gone
containers
=
self
.
client
.
containers
(
all
=
True
)
retrieved
=
[
x
for
x
in
containers
if
link_name
in
x
[
'Names'
]]
self
.
assertEqual
(
len
(
retrieved
),
0
)
# Containers are still there
retrieved
=
[
x
for
x
in
containers
if
x
[
'Id'
]
.
startswith
(
container1_id
)
or
x
[
'Id'
]
.
startswith
(
container2_id
)
]
self
.
assertEqual
(
len
(
retrieved
),
2
)
tests/unit/utils_test.py
Dosyayı görüntüle @
24f75ea2
...
...
@@ -578,6 +578,9 @@ class PortsTest(unittest.TestCase):
self
.
assertRaises
(
ValueError
,
lambda
:
split_port
(
"localhost:80:"
))
def
test_split_port_empty_string
(
self
):
self
.
assertRaises
(
ValueError
,
lambda
:
split_port
(
""
))
def
test_build_port_bindings_with_one_port
(
self
):
port_bindings
=
build_port_bindings
([
"127.0.0.1:1000:1000"
])
self
.
assertEqual
(
port_bindings
[
"1000"
],
[(
"127.0.0.1"
,
"1000"
)])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment