Browse Source

Prepare stable/train

Update .gitreview for stable/train

Change-Id: Ifae2ec26e9ccf125ba84d3b20795b3912d756811

Add mocks to fix unit tests

Change: https://review.opendev.org/687305 broke
the unit tests. We need to mock the method:
  get_undercloud_registry()

Change-Id: I2488a8bdda1eab8f46d5dfda027633174f52e342
Closes-Bug: #1848275
(cherry picked from commit 0b21efc53d)
changes/64/688964/1
OpenStack Release Bot 2 years ago
committed by Emilien Macchi
parent
commit
e7132d47ea
  1. 1
      .gitreview
  2. 36
      tripleoclient/tests/v1/test_container_image.py

1
.gitreview

@ -2,3 +2,4 @@
host=review.opendev.org
port=29418
project=openstack/python-tripleoclient.git
defaultbranch=stable/train

36
tripleoclient/tests/v1/test_container_image.py

@ -87,9 +87,11 @@ class TestContainerImagePush(TestPluginV1):
super(TestContainerImagePush, self).setUp()
self.cmd = container_image.TripleOContainerImagePush(self.app, None)
@mock.patch('tripleo_common.image.image_uploader.get_undercloud_registry',
return_value='uc.ctlplane.somedomain')
@mock.patch('tripleo_common.image.image_uploader.UploadTask')
@mock.patch('tripleo_common.image.image_uploader.ImageUploadManager')
def test_take_action(self, mock_manager, mock_task):
def test_take_action(self, mock_manager, mock_task, mock_get_uc_registry):
arglist = ['docker.io/namespace/foo']
verifylist = [('image_to_push', 'docker.io/namespace/foo')]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@ -136,9 +138,12 @@ class TestContainerImagePush(TestPluginV1):
mock_add_upload.assert_called_once_with(mock_uploadtask)
mock_run_tasks.assert_called_once()
@mock.patch('tripleo_common.image.image_uploader.get_undercloud_registry',
return_value='uc.ctlplane.somedomain')
@mock.patch('tripleo_common.image.image_uploader.UploadTask')
@mock.patch('tripleo_common.image.image_uploader.ImageUploadManager')
def test_take_action_local(self, mock_manager, mock_task):
def test_take_action_local(self, mock_manager, mock_task,
mock_get_uc_registry):
arglist = ['docker.io/namespace/foo', '--local']
verifylist = [('image_to_push', 'docker.io/namespace/foo'),
('local', True)]
@ -186,9 +191,12 @@ class TestContainerImagePush(TestPluginV1):
mock_add_upload.assert_called_once_with(mock_uploadtask)
mock_run_tasks.assert_called_once()
@mock.patch('tripleo_common.image.image_uploader.get_undercloud_registry',
return_value='uc.ctlplane.somedomain')
@mock.patch('tripleo_common.image.image_uploader.UploadTask')
@mock.patch('tripleo_common.image.image_uploader.ImageUploadManager')
def test_take_action_local_path(self, mock_manager, mock_task):
def test_take_action_local_path(self, mock_manager, mock_task,
mock_get_uc_registry):
arglist = ['containers-storage:docker.io/namespace/foo']
verifylist = [('image_to_push',
'containers-storage:docker.io/namespace/foo')]
@ -236,9 +244,12 @@ class TestContainerImagePush(TestPluginV1):
mock_add_upload.assert_called_once_with(mock_uploadtask)
mock_run_tasks.assert_called_once()
@mock.patch('tripleo_common.image.image_uploader.get_undercloud_registry',
return_value='uc.ctlplane.somedomain')
@mock.patch('tripleo_common.image.image_uploader.UploadTask')
@mock.patch('tripleo_common.image.image_uploader.ImageUploadManager')
def test_take_action_oserror(self, mock_manager, mock_task):
def test_take_action_oserror(self, mock_manager, mock_task,
mock_get_uc_registry):
arglist = ['docker.io/namespace/foo']
verifylist = [('image_to_push', 'docker.io/namespace/foo')]
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
@ -274,9 +285,12 @@ class TestContainerImagePush(TestPluginV1):
self.cmd.take_action,
parsed_args)
@mock.patch('tripleo_common.image.image_uploader.get_undercloud_registry',
return_value='uc.ctlplane.somedomain')
@mock.patch('tripleo_common.image.image_uploader.UploadTask')
@mock.patch('tripleo_common.image.image_uploader.ImageUploadManager')
def test_take_action_all_options(self, mock_manager, mock_task):
def test_take_action_all_options(self, mock_manager, mock_task,
mock_get_uc_registry):
arglist = ['--registry-url', '127.0.0.1:8787',
'--append-tag', 'test',
'--username', 'user',
@ -348,8 +362,10 @@ class TestContainerImageDelete(TestPluginV1):
super(TestContainerImageDelete, self).setUp()
self.cmd = container_image.TripleOContainerImageDelete(self.app, None)
@mock.patch('tripleo_common.image.image_uploader.get_undercloud_registry',
return_value='uc.ctlplane.somedomain')
@mock.patch('tripleo_common.image.image_uploader.ImageUploadManager')
def test_oserror(self, mock_manager):
def test_oserror(self, mock_manager, mock_get_uc_registry):
arglist = ['-y', 'foo']
verifylist = [('yes', True),
@ -388,8 +404,10 @@ class TestContainerImageList(TestPluginV1):
super(TestContainerImageList, self).setUp()
self.cmd = container_image.TripleOContainerImageList(self.app, None)
@mock.patch('tripleo_common.image.image_uploader.get_undercloud_registry',
return_value='uc.ctlplane.somedomain')
@mock.patch('tripleo_common.image.image_uploader.ImageUploadManager')
def test_take_action(self, mock_manager):
def test_take_action(self, mock_manager, mock_get_uc_registry):
arglist = []
verifylist = []
@ -401,8 +419,10 @@ class TestContainerImageList(TestPluginV1):
actual = (('Image Name',), [('a',), ('b',)])
self.assertEqual(actual, rv)
@mock.patch('tripleo_common.image.image_uploader.get_undercloud_registry',
return_value='uc.ctlplane.somedomain')
@mock.patch('tripleo_common.image.image_uploader.ImageUploadManager')
def test_take_action_auth(self, mock_manager):
def test_take_action_auth(self, mock_manager, mock_get_uc_registry):
# check arg parsing items
arglist = ['--registry-url', 'reg-url',
'--username', 'foo',

Loading…
Cancel
Save