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
d1f7979f
Kaydet (Commit)
d1f7979f
authored
Mar 26, 2019
tarafından
Ulysses Souza
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Refactor and add tests
Signed-off-by:
Ulysses Souza
<
ulysses.souza@docker.com
>
üst
4890864d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
8 deletions
+46
-8
models_containers_test.py
tests/integration/models_containers_test.py
+46
-8
No files found.
tests/integration/models_containers_test.py
Dosyayı görüntüle @
d1f7979f
...
...
@@ -346,9 +346,10 @@ class ContainerTest(BaseIntegrationTest):
'memory_stats'
,
'blkio_stats'
]:
assert
key
in
stats
def
test_ports
(
self
):
def
test_ports
_target_none
(
self
):
client
=
docker
.
from_env
(
version
=
TEST_API_VERSION
)
target_ports
=
{
'2222/tcp'
:
None
}
ports
=
None
target_ports
=
{
'2222/tcp'
:
ports
}
container
=
client
.
containers
.
run
(
"alpine"
,
"sleep 100"
,
detach
=
True
,
ports
=
target_ports
...
...
@@ -361,12 +362,49 @@ class ContainerTest(BaseIntegrationTest):
for
actual_port
in
actual_ports
[
target_client
]:
actual_keys
=
sorted
(
actual_port
.
keys
())
assert
sorted
([
'HostIp'
,
'HostPort'
])
==
actual_keys
if
target_host
is
None
:
int
(
actual_port
[
'HostPort'
])
elif
isinstance
(
target_host
,
(
list
,
tuple
)):
raise
NotImplementedError
()
else
:
assert
actual_port
[
'HostPort'
]
==
target_host
.
split
(
'/'
,
1
)
assert
target_host
is
ports
assert
int
(
actual_port
[
'HostPort'
])
>
0
client
.
close
()
def
test_ports_target_tuple
(
self
):
client
=
docker
.
from_env
(
version
=
TEST_API_VERSION
)
ports
=
(
'127.0.0.1'
,
1111
)
target_ports
=
{
'2222/tcp'
:
ports
}
container
=
client
.
containers
.
run
(
"alpine"
,
"sleep 100"
,
detach
=
True
,
ports
=
target_ports
)
self
.
tmp_containers
.
append
(
container
.
id
)
container
.
reload
()
# required to get auto-assigned ports
actual_ports
=
container
.
ports
assert
sorted
(
target_ports
.
keys
())
==
sorted
(
actual_ports
.
keys
())
for
target_client
,
target_host
in
target_ports
.
items
():
for
actual_port
in
actual_ports
[
target_client
]:
actual_keys
=
sorted
(
actual_port
.
keys
())
assert
sorted
([
'HostIp'
,
'HostPort'
])
==
actual_keys
assert
target_host
==
ports
assert
int
(
actual_port
[
'HostPort'
])
>
0
client
.
close
()
def
test_ports_target_list
(
self
):
client
=
docker
.
from_env
(
version
=
TEST_API_VERSION
)
ports
=
[
1234
,
4567
]
target_ports
=
{
'2222/tcp'
:
ports
}
container
=
client
.
containers
.
run
(
"alpine"
,
"sleep 100"
,
detach
=
True
,
ports
=
target_ports
)
self
.
tmp_containers
.
append
(
container
.
id
)
container
.
reload
()
# required to get auto-assigned ports
actual_ports
=
container
.
ports
assert
sorted
(
target_ports
.
keys
())
==
sorted
(
actual_ports
.
keys
())
for
target_client
,
target_host
in
target_ports
.
items
():
for
actual_port
in
actual_ports
[
target_client
]:
actual_keys
=
sorted
(
actual_port
.
keys
())
assert
sorted
([
'HostIp'
,
'HostPort'
])
==
actual_keys
assert
target_host
==
ports
assert
int
(
actual_port
[
'HostPort'
])
>
0
client
.
close
()
def
test_stop
(
self
):
client
=
docker
.
from_env
(
version
=
TEST_API_VERSION
)
...
...
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