add unittest for program deployable in cyborg module
add unittest for program deployable in cyborg module, fix the bug that calls wrong api Closes-Bug: #2031605 Change-Id: I581061cf352cd157d537e9bf2a5493bd83ad1b38
This commit is contained in:
parent
f397f0d171
commit
0d0490285b
|
@ -163,5 +163,5 @@ class ProgramDeployable(command.ShowOne):
|
|||
program_info = [{'path': '/program',
|
||||
'value': [{'image_uuid': image_uuid}],
|
||||
'op': 'replace'}]
|
||||
acc_client.update_deployable(dep_uuid, program_info)
|
||||
acc_client.program(dep_uuid, program_info)
|
||||
return _show_deployable(acc_client, dep_uuid)
|
||||
|
|
|
@ -16,6 +16,7 @@ from osc_lib.tests import utils
|
|||
from unittest import mock
|
||||
import uuid
|
||||
|
||||
image_uuid = uuid.uuid4().hex
|
||||
deployable_created_at = '2019-06-24T00:00:00.000000+00:00'
|
||||
deployable_updated_at = '2019-06-24T11:11:11.111111+11:11'
|
||||
deployable_uuid = uuid.uuid4().hex
|
||||
|
@ -134,6 +135,7 @@ class TestAccelerator(utils.TestCommand):
|
|||
|
||||
self.app.client_manager.auth_ref = mock.MagicMock(auth_token="TOKEN")
|
||||
self.app.client_manager.accelerator = mock.MagicMock()
|
||||
self.app.client_manager.image = mock.MagicMock()
|
||||
|
||||
|
||||
class FakeAcceleratorResource(fakes.FakeResource):
|
||||
|
|
|
@ -148,3 +148,46 @@ class TestDeployableShow(TestDeployable):
|
|||
exc.CommandError,
|
||||
'deployable not found: %s' % acc_fakes.deployable_uuid,
|
||||
self.cmd.take_action, parsed_args)
|
||||
|
||||
|
||||
class TestDeployableProgram(TestDeployable):
|
||||
|
||||
def setUp(self):
|
||||
super(TestDeployableProgram, self).setUp()
|
||||
|
||||
fake_arq = acc_fakes.FakeAcceleratorResource(
|
||||
None,
|
||||
copy.deepcopy(acc_fakes.DEPLOYABLE),
|
||||
loaded=True)
|
||||
self.mock_acc_client.program.return_value = fake_arq
|
||||
self.mock_acc_client.get_deployable.return_value = fake_arq
|
||||
self.cmd = osc_deployable.ProgramDeployable(self.app, None)
|
||||
|
||||
def test_deployable_program(self):
|
||||
arglist = [acc_fakes.deployable_uuid, acc_fakes.image_uuid]
|
||||
verifylist = []
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
columns, data = self.cmd.take_action(parsed_args)
|
||||
|
||||
program_info = [{'path': '/program',
|
||||
'value': [{'image_uuid': acc_fakes.image_uuid}],
|
||||
'op': 'replace'}]
|
||||
self.mock_acc_client.program.assert_called_with(
|
||||
acc_fakes.deployable_uuid, program_info)
|
||||
|
||||
collist = (
|
||||
'created_at',
|
||||
'updated_at',
|
||||
'uuid',
|
||||
'name'
|
||||
)
|
||||
|
||||
self.assertEqual(collist, columns)
|
||||
|
||||
datalist = [
|
||||
acc_fakes.deployable_created_at,
|
||||
acc_fakes.deployable_updated_at,
|
||||
acc_fakes.deployable_uuid,
|
||||
acc_fakes.deployable_name
|
||||
]
|
||||
self.assertEqual(datalist, list(data))
|
||||
|
|
Loading…
Reference in New Issue