Skip to content

Commit

Permalink
Resolves docker#553, Resolves docker#546 - bug fixes with unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Nephin <[email protected]>
  • Loading branch information
dnephin committed Oct 18, 2014
1 parent 2efb4f5 commit 7544580
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 3 deletions.
2 changes: 1 addition & 1 deletion fig/cli/docker_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def docker_client():
"""
cert_path = os.environ.get('DOCKER_CERT_PATH', '')
if cert_path == '':
cert_path = os.path.join(os.environ.get('HOME'), '.docker')
cert_path = os.path.join(os.environ.get('HOME', ''), '.docker')

base_url = os.environ.get('DOCKER_HOST')
tls_config = None
Expand Down
4 changes: 3 additions & 1 deletion fig/progress_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ def stream_output(output, stream):
all_events.append(event)

if 'progress' in event or 'progressDetail' in event:
image_id = event['id']
image_id = event.get('id')
if not image_id:
continue

if image_id in lines:
diff = len(lines) - lines[image_id]
Expand Down
16 changes: 16 additions & 0 deletions tests/unit/cli/docker_client_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from __future__ import unicode_literals
from __future__ import absolute_import
import os

import mock
from tests import unittest

from fig.cli import docker_client


class DockerClientTestCase(unittest.TestCase):

def test_docker_client_no_home(self):
with mock.patch.dict(os.environ):
del os.environ['HOME']
docker_client.docker_client()
2 changes: 1 addition & 1 deletion tests/unit/cli/verbose_proxy_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from fig.cli import verbose_proxy


class VerboseProxy(unittest.TestCase):
class VerboseProxyTestCase(unittest.TestCase):

def test_format_call(self):
expected = "(u'arg1', True, key=u'value')"
Expand Down
20 changes: 20 additions & 0 deletions tests/unit/progress_stream_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from __future__ import unicode_literals
from __future__ import absolute_import
from tests import unittest

import mock
from six import StringIO

from fig import progress_stream


class ProgressStreamTestCase(unittest.TestCase):

def test_stream_output(self):
output = [
'{"status": "Downloading", "progressDetail": {"current": '
'31019763, "start": 1413653874, "total": 62763875}, '
'"progress": "..."}',
]
events = progress_stream.stream_output(output, StringIO())
self.assertEqual(len(events), 1)
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ commands =
[flake8]
# ignore line-length for now
ignore = E501,E203
exclude = fig/packages

0 comments on commit 7544580

Please sign in to comment.