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
64f4ba90
Kaydet (Commit)
64f4ba90
authored
Şub 05, 2014
tarafından
Maxime Petazzoni
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Support remote API v1.8 (and make it the default)
Signed-off-by:
Maxime Petazzoni
<
max@signalfuse.com
>
üst
417d6912
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
7 deletions
+21
-7
client.py
docker/client.py
+5
-2
fake_api.py
tests/fake_api.py
+7
-4
test.py
tests/test.py
+9
-1
No files found.
docker/client.py
Dosyayı görüntüle @
64f4ba90
...
...
@@ -28,6 +28,7 @@ from .utils import utils
if
not
six
.
PY3
:
import
websocket
DEFAULT_DOCKER_API_VERSION
=
'1.8'
DEFAULT_TIMEOUT_SECONDS
=
60
STREAM_HEADER_SIZE_BYTES
=
8
...
...
@@ -65,7 +66,7 @@ class APIError(requests.exceptions.HTTPError):
class
Client
(
requests
.
Session
):
def
__init__
(
self
,
base_url
=
None
,
version
=
"1.6"
,
def
__init__
(
self
,
base_url
=
None
,
version
=
DEFAULT_DOCKER_API_VERSION
,
timeout
=
DEFAULT_TIMEOUT_SECONDS
):
super
(
Client
,
self
)
.
__init__
()
if
base_url
is
None
:
...
...
@@ -363,7 +364,7 @@ class Client(requests.Session):
if
context
is
not
None
:
context
.
close
()
if
stream
:
if
stream
or
utils
.
compare_version
(
'1.8'
,
self
.
_version
)
>=
0
:
return
self
.
_stream_result
(
response
)
else
:
output
=
self
.
_result
(
response
)
...
...
@@ -473,6 +474,8 @@ class Client(requests.Session):
def
images
(
self
,
name
=
None
,
quiet
=
False
,
all
=
False
,
viz
=
False
):
if
viz
:
if
utils
.
compare_version
(
'1.7'
,
self
.
_version
)
>=
0
:
raise
Exception
(
'Viz output is not supported in API >= 1.7!'
)
return
self
.
_result
(
self
.
_get
(
self
.
_url
(
"images/viz"
)))
params
=
{
'filter'
:
name
,
...
...
tests/fake_api.py
Dosyayı görüntüle @
64f4ba90
...
...
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
CURRENT_VERSION
=
'v1.
6
'
CURRENT_VERSION
=
'v1.
8
'
FAKE_CONTAINER_ID
=
'3cc2351ab11b'
FAKE_IMAGE_ID
=
'e9aa60c60128'
...
...
@@ -30,13 +30,16 @@ FAKE_PATH = '/path'
def
get_fake_version
():
status_code
=
200
response
=
{
'GoVersion'
:
'1'
,
'Version'
:
'1.1.1'
}
response
=
{
'GoVersion'
:
'1'
,
'Version'
:
'1.1.1'
,
'GitCommit'
:
'deadbeef+CHANGES'
}
return
status_code
,
response
def
get_fake_info
():
status_code
=
200
response
=
{
'Containers'
:
1
,
'Images'
:
1
,
'Debug'
:
''
}
response
=
{
'Containers'
:
1
,
'Images'
:
1
,
'Debug'
:
False
,
'MemoryLimit'
:
False
,
'SwapLimit'
:
False
,
'IPv4Forwarding'
:
True
}
return
status_code
,
response
...
...
@@ -52,7 +55,7 @@ def get_fake_images():
'Id'
:
FAKE_IMAGE_ID
,
'Created'
:
'2 days ago'
,
'Repository'
:
'busybox'
,
'
Tag'
:
'latest'
'
RepoTags'
:
[
'busybox:latest'
,
'busybox:1.0'
],
}]
return
status_code
,
response
...
...
tests/test.py
Dosyayı görüntüle @
64f4ba90
...
...
@@ -55,7 +55,8 @@ def fake_resp(url, data=None, **kwargs):
return
response
(
status_code
=
status_code
,
content
=
content
)
fake_request
=
mock
.
Mock
(
side_effect
=
fake_resp
)
url_prefix
=
'http+unix://var/run/docker.sock/v1.6/'
url_prefix
=
'http+unix://var/run/docker.sock/v{0}/'
.
format
(
docker
.
client
.
DEFAULT_DOCKER_API_VERSION
)
@mock.patch.multiple
(
'docker.Client'
,
get
=
fake_request
,
post
=
fake_request
,
...
...
@@ -103,6 +104,13 @@ class DockerClientTest(unittest.TestCase):
timeout
=
docker
.
client
.
DEFAULT_TIMEOUT_SECONDS
)
def
test_image_viz
(
self
):
try
:
self
.
client
.
images
(
'busybox'
,
viz
=
True
)
self
.
fail
(
'Viz output should not be supported!'
)
except
Exception
:
pass
###################
## LISTING TESTS ##
###################
...
...
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