summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeerthan Reddy Mala <kmala@deis.com>2016-07-21 11:01:03 -0600
committerKeerthan Reddy Mala <kmala@deis.com>2016-07-22 10:04:32 -0600
commit1294d3c4103fc33949edc146be9bc91fd1a05c4d (patch)
treeaa9e81193c19d1f4e91f1891d2e69149aebe449d
parent9b63bed6a0b5185b043e85df8c49d86d2c048aa1 (diff)
downloaddocker-py-1294d3c4103fc33949edc146be9bc91fd1a05c4d.tar.gz
Add unit tests
Signed-off-by: Keerthan Reddy Mala <kmala@deis.com>
-rw-r--r--tests/unit/image_test.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/unit/image_test.py b/tests/unit/image_test.py
index 8fd894c..b2b1dd6 100644
--- a/tests/unit/image_test.py
+++ b/tests/unit/image_test.py
@@ -2,6 +2,7 @@ import docker
import pytest
from . import fake_api
+from docker import auth
from .api_test import (
DockerClientTest, fake_request, DEFAULT_TIMEOUT_SECONDS, url_prefix,
fake_resolve_authconfig
@@ -262,6 +263,31 @@ class ImageTest(DockerClientTest):
timeout=DEFAULT_TIMEOUT_SECONDS
)
+ def test_push_image_with_auth(self):
+ auth_config = {
+ 'username': "test_user",
+ 'password': "test_password",
+ 'serveraddress': "test_server",
+ }
+ encoded_auth = auth.encode_header(auth_config)
+ self.client.push(
+ fake_api.FAKE_IMAGE_NAME, tag=fake_api.FAKE_TAG_NAME,
+ auth_config=auth_config
+ )
+
+ fake_request.assert_called_with(
+ 'POST',
+ url_prefix + 'images/test_image/push',
+ params={
+ 'tag': fake_api.FAKE_TAG_NAME,
+ },
+ data='{}',
+ headers={'Content-Type': 'application/json',
+ 'X-Registry-Auth': encoded_auth},
+ stream=False,
+ timeout=DEFAULT_TIMEOUT_SECONDS
+ )
+
def test_push_image_stream(self):
with mock.patch('docker.auth.auth.resolve_authconfig',
fake_resolve_authconfig):