Update unit tests for stream_output to match the behaviour of a docker-py response.
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
This commit is contained in:
parent
7e4c3142d7
commit
71ff872e8e
8 changed files with 29 additions and 21 deletions
|
|
@ -10,27 +10,27 @@ from tests import unittest
|
|||
class ProgressStreamTestCase(unittest.TestCase):
|
||||
def test_stream_output(self):
|
||||
output = [
|
||||
'{"status": "Downloading", "progressDetail": {"current": '
|
||||
'31019763, "start": 1413653874, "total": 62763875}, '
|
||||
'"progress": "..."}',
|
||||
b'{"status": "Downloading", "progressDetail": {"current": '
|
||||
b'31019763, "start": 1413653874, "total": 62763875}, '
|
||||
b'"progress": "..."}',
|
||||
]
|
||||
events = progress_stream.stream_output(output, StringIO())
|
||||
self.assertEqual(len(events), 1)
|
||||
|
||||
def test_stream_output_div_zero(self):
|
||||
output = [
|
||||
'{"status": "Downloading", "progressDetail": {"current": '
|
||||
'0, "start": 1413653874, "total": 0}, '
|
||||
'"progress": "..."}',
|
||||
b'{"status": "Downloading", "progressDetail": {"current": '
|
||||
b'0, "start": 1413653874, "total": 0}, '
|
||||
b'"progress": "..."}',
|
||||
]
|
||||
events = progress_stream.stream_output(output, StringIO())
|
||||
self.assertEqual(len(events), 1)
|
||||
|
||||
def test_stream_output_null_total(self):
|
||||
output = [
|
||||
'{"status": "Downloading", "progressDetail": {"current": '
|
||||
'0, "start": 1413653874, "total": null}, '
|
||||
'"progress": "..."}',
|
||||
b'{"status": "Downloading", "progressDetail": {"current": '
|
||||
b'0, "start": 1413653874, "total": null}, '
|
||||
b'"progress": "..."}',
|
||||
]
|
||||
events = progress_stream.stream_output(output, StringIO())
|
||||
self.assertEqual(len(events), 1)
|
||||
|
|
|
|||
|
|
@ -280,7 +280,7 @@ class ServiceTest(unittest.TestCase):
|
|||
|
||||
def test_build_does_not_pull(self):
|
||||
self.mock_client.build.return_value = [
|
||||
'{"stream": "Successfully built 12345"}',
|
||||
b'{"stream": "Successfully built 12345"}',
|
||||
]
|
||||
|
||||
service = Service('foo', client=self.mock_client, build='.')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue