Add unit tests

Signed-off-by: Keerthan Reddy Mala <kmala@deis.com>
This commit is contained in:
Keerthan Reddy Mala 2016-07-21 11:01:03 -06:00
parent 9b63bed6a0
commit 1294d3c410
No known key found for this signature in database
GPG Key ID: 09B31D7AE33FF0AA
1 changed files with 26 additions and 0 deletions

View File

@ -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):