Merge "Fix intermittent v2 shell unit test failures"
This commit is contained in:
@@ -758,10 +758,13 @@ class ShellV2Test(testtools.TestCase):
|
|||||||
self.assert_exits_with_msg(func=test_shell.do_image_delete,
|
self.assert_exits_with_msg(func=test_shell.do_image_delete,
|
||||||
func_args=args)
|
func_args=args)
|
||||||
|
|
||||||
|
@mock.patch('sys.stdout', autospec=True)
|
||||||
@mock.patch.object(utils, 'print_err')
|
@mock.patch.object(utils, 'print_err')
|
||||||
def test_do_image_download_with_forbidden_id(self, mocked_print_err):
|
def test_do_image_download_with_forbidden_id(self, mocked_print_err,
|
||||||
|
mocked_stdout):
|
||||||
args = self._make_args({'id': 'IMG-01', 'file': None,
|
args = self._make_args({'id': 'IMG-01', 'file': None,
|
||||||
'progress': False})
|
'progress': False})
|
||||||
|
mocked_stdout.isatty = lambda: False
|
||||||
with mock.patch.object(self.gc.images, 'data') as mocked_data:
|
with mock.patch.object(self.gc.images, 'data') as mocked_data:
|
||||||
mocked_data.side_effect = exc.HTTPForbidden
|
mocked_data.side_effect = exc.HTTPForbidden
|
||||||
try:
|
try:
|
||||||
@@ -773,10 +776,12 @@ class ShellV2Test(testtools.TestCase):
|
|||||||
self.assertEqual(1, mocked_data.call_count)
|
self.assertEqual(1, mocked_data.call_count)
|
||||||
self.assertEqual(1, mocked_print_err.call_count)
|
self.assertEqual(1, mocked_print_err.call_count)
|
||||||
|
|
||||||
|
@mock.patch('sys.stdout', autospec=True)
|
||||||
@mock.patch.object(utils, 'print_err')
|
@mock.patch.object(utils, 'print_err')
|
||||||
def test_do_image_download_with_500(self, mocked_print_err):
|
def test_do_image_download_with_500(self, mocked_print_err, mocked_stdout):
|
||||||
args = self._make_args({'id': 'IMG-01', 'file': None,
|
args = self._make_args({'id': 'IMG-01', 'file': None,
|
||||||
'progress': False})
|
'progress': False})
|
||||||
|
mocked_stdout.isatty = lambda: False
|
||||||
with mock.patch.object(self.gc.images, 'data') as mocked_data:
|
with mock.patch.object(self.gc.images, 'data') as mocked_data:
|
||||||
mocked_data.side_effect = exc.HTTPInternalServerError
|
mocked_data.side_effect = exc.HTTPInternalServerError
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user