def test_image_download(self): class Fake(): id = 'pass' file = 'test' gc = client.Client('1', 'http://is.invalid') with mock.patch.object(gc.images, 'data') as mocked_data: mocked_data.return_value = 'test_passed' test_shell.do_image_download(gc, Fake())
def test_image_download(self): class Fake(): id = 'pass' file = 'test' gc = client.Client('1', 'http://no.where') with mock.patch.object(gc.images, 'data') as mocked_data: mocked_data.return_value = 'test_passed' test_shell.do_image_download(gc, Fake())
def test_image_download(self): args = self._make_args({"id": "pass", "file": "test", "progress": False}) with mock.patch.object(self.gc.images, "data") as mocked_data: resp = test_utils.FakeResponse({}, StringIO.StringIO("CCC")) ret = mocked_data.return_value = http.ResponseBodyIterator(resp) test_shell.do_image_download(self.gc, args) mocked_data.assert_called_once_with("pass") utils.save_image.assert_called_once_with(ret, "test")
def test_image_download(self): args = self._make_args( {'id': 'pass', 'file': 'test', 'progress': False}) with mock.patch.object(self.gc.images, 'data') as mocked_data: resp = test_utils.FakeResponse({}, StringIO.StringIO('CCC')) ret = mocked_data.return_value = http.ResponseBodyIterator(resp) test_shell.do_image_download(self.gc, args) mocked_data.assert_called_once_with('pass') utils.save_image.assert_called_once_with(ret, 'test')
def test_image_download_with_progressbar(self): args = self._make_args({"id": "pass", "file": "test", "progress": True}) with mock.patch.object(self.gc.images, "data") as mocked_data: resp = test_utils.FakeResponse({}, StringIO.StringIO("CCC")) mocked_data.return_value = http.ResponseBodyIterator(resp) test_shell.do_image_download(self.gc, args) mocked_data.assert_called_once_with("pass") utils.save_image.assert_called_once_with(mock.ANY, "test") self.assertIsInstance(utils.save_image.call_args[0][0], progressbar.VerboseIteratorWrapper)
def test_image_download(self): args = self._make_args( {'id': 'IMG-01', 'file': 'test', 'progress': True}) with mock.patch.object(self.gc.images, 'data') as mocked_data: def _data(): for c in 'abcedf': yield c mocked_data.return_value = utils.IterableWithLength(_data(), 5) test_shell.do_image_download(self.gc, args) mocked_data.assert_called_once_with('IMG-01')
def test_image_download(self): args = self._make_args({"id": "IMG-01", "file": "test", "progress": True}) with mock.patch.object(self.gc.images, "data") as mocked_data: def _data(): for c in "abcedf": yield c mocked_data.return_value = utils.IterableWithLength(_data(), 5) test_shell.do_image_download(self.gc, args) mocked_data.assert_called_once_with("IMG-01")
def test_image_download(self): args = self._make_args({ 'id': 'pass', 'file': 'test', 'progress': False }) with mock.patch.object(self.gc.images, 'data') as mocked_data: resp = test_utils.FakeResponse({}, StringIO.StringIO('CCC')) ret = mocked_data.return_value = http.ResponseBodyIterator(resp) test_shell.do_image_download(self.gc, args) mocked_data.assert_called_once_with('pass') utils.save_image.assert_called_once_with(ret, 'test')
def test_image_download_with_progressbar(self): args = self._make_args( {'id': 'pass', 'file': 'test', 'progress': True}) with mock.patch.object(self.gc.images, 'data') as mocked_data: resp = test_utils.FakeResponse({}, StringIO.StringIO('CCC')) mocked_data.return_value = http.ResponseBodyIterator(resp) test_shell.do_image_download(self.gc, args) mocked_data.assert_called_once_with('pass') utils.save_image.assert_called_once_with(mock.ANY, 'test') self.assertIsInstance( utils.save_image.call_args[0][0], progressbar.VerboseIteratorWrapper )
def test_image_download_with_progressbar(self): args = self._make_args({ 'id': 'pass', 'file': 'test', 'progress': True }) with mock.patch.object(self.gc.images, 'data') as mocked_data: resp = test_utils.FakeResponse({}, StringIO.StringIO('CCC')) mocked_data.return_value = http.ResponseBodyIterator(resp) test_shell.do_image_download(self.gc, args) mocked_data.assert_called_once_with('pass') utils.save_image.assert_called_once_with(mock.ANY, 'test') self.assertIsInstance(utils.save_image.call_args[0][0], progressbar.VerboseIteratorWrapper)