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
29b12cf0
Kaydet (Commit)
29b12cf0
authored
Eyl 25, 2015
tarafından
Aanand Prasad
Kaydeden (comit)
Joffrey F
Eyl 25, 2015
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
_url can take arbitrarily many arguments
Signed-off-by:
Aanand Prasad
<
aanand.prasad@gmail.com
>
üst
26e22bbd
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
12 deletions
+37
-12
client.py
docker/client.py
+10
-9
test.py
tests/test.py
+27
-3
No files found.
docker/client.py
Dosyayı görüntüle @
29b12cf0
...
...
@@ -111,21 +111,22 @@ class Client(
def
_delete
(
self
,
url
,
**
kwargs
):
return
self
.
delete
(
url
,
**
self
.
_set_request_timeout
(
kwargs
))
def
_url
(
self
,
pathfmt
,
resource_id
=
None
,
versioned_api
=
True
):
if
resource_id
and
not
isinstance
(
resource_id
,
six
.
string_types
):
def
_url
(
self
,
pathfmt
,
*
args
,
**
kwargs
):
for
arg
in
args
:
if
not
isinstance
(
arg
,
six
.
string_types
):
raise
ValueError
(
'Expected a resource ID
string but found {0} ({1}) '
'instead'
.
format
(
resource_id
,
type
(
resource_id
))
'Expected a
string but found {0} ({1}) '
'instead'
.
format
(
arg
,
type
(
arg
))
)
elif
resource_id
:
resource_id
=
six
.
moves
.
urllib
.
parse
.
quote_plus
(
resource_id
)
if
versioned_api
:
args
=
map
(
six
.
moves
.
urllib
.
parse
.
quote_plus
,
args
)
if
kwargs
.
get
(
'versioned_api'
,
True
):
return
'{0}/v{1}{2}'
.
format
(
self
.
base_url
,
self
.
_version
,
pathfmt
.
format
(
resource_id
)
self
.
base_url
,
self
.
_version
,
pathfmt
.
format
(
*
args
)
)
else
:
return
'{0}{1}'
.
format
(
self
.
base_url
,
pathfmt
.
format
(
resource_id
))
return
'{0}{1}'
.
format
(
self
.
base_url
,
pathfmt
.
format
(
*
args
))
def
_raise_for_status
(
self
,
response
,
explanation
=
None
):
"""Raises stored :class:`APIError`, if one occurred."""
...
...
tests/test.py
Dosyayı görüntüle @
29b12cf0
...
...
@@ -104,7 +104,9 @@ def fake_put(self, url, *args, **kwargs):
def
fake_delete
(
self
,
url
,
*
args
,
**
kwargs
):
return
fake_request
(
'DELETE'
,
url
,
*
args
,
**
kwargs
)
url_prefix
=
'http+docker://localunixsocket/v{0}/'
.
format
(
url_base
=
'http+docker://localunixsocket/'
url_prefix
=
'{0}v{1}/'
.
format
(
url_base
,
docker
.
constants
.
DEFAULT_DOCKER_API_VERSION
)
...
...
@@ -174,6 +176,14 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
url
,
'{0}{1}'
.
format
(
url_prefix
,
'hello/somename/world'
)
)
url
=
self
.
client
.
_url
(
'/hello/{0}/world/{1}'
,
'somename'
,
'someothername'
)
self
.
assertEqual
(
url
,
'{0}{1}'
.
format
(
url_prefix
,
'hello/somename/world/someothername'
)
)
url
=
self
.
client
.
_url
(
'/hello/{0}/world'
,
'/some?name'
)
self
.
assertEqual
(
url
,
'{0}{1}'
.
format
(
url_prefix
,
'hello/
%2
Fsome
%3
Fname/world'
)
...
...
@@ -187,8 +197,13 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
url
=
self
.
client
.
_url
(
'/simple'
)
self
.
assertEqual
(
url
,
'{0}{1}'
.
format
(
url_prefix
,
'simple'
))
url
=
self
.
client
.
_url
(
'/simple'
,
None
)
self
.
assertEqual
(
url
,
'{0}{1}'
.
format
(
url_prefix
,
'simple'
))
def
test_url_unversioned_api
(
self
):
url
=
self
.
client
.
_url
(
'/hello/{0}/world'
,
'somename'
,
versioned_api
=
False
)
self
.
assertEqual
(
url
,
'{0}{1}'
.
format
(
url_base
,
'hello/somename/world'
)
)
#########################
# INFORMATION TESTS #
...
...
@@ -202,6 +217,15 @@ class DockerClientTest(Cleanup, base.BaseTestCase):
timeout
=
DEFAULT_TIMEOUT_SECONDS
)
def
test_version_no_api_version
(
self
):
self
.
client
.
version
(
False
)
fake_request
.
assert_called_with
(
'GET'
,
url_base
+
'version'
,
timeout
=
DEFAULT_TIMEOUT_SECONDS
)
def
test_retrieve_server_version
(
self
):
client
=
docker
.
Client
(
version
=
"auto"
)
self
.
assertTrue
(
isinstance
(
client
.
_version
,
six
.
string_types
))
...
...
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