diff --git a/cyborgclient/osc/v2/deployable.py b/cyborgclient/osc/v2/deployable.py index 2792a5e..12364d3 100644 --- a/cyborgclient/osc/v2/deployable.py +++ b/cyborgclient/osc/v2/deployable.py @@ -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) diff --git a/cyborgclient/tests/unit/osc/v2/fakes.py b/cyborgclient/tests/unit/osc/v2/fakes.py index 62a225d..922c387 100644 --- a/cyborgclient/tests/unit/osc/v2/fakes.py +++ b/cyborgclient/tests/unit/osc/v2/fakes.py @@ -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): diff --git a/cyborgclient/tests/unit/osc/v2/test_deployable.py b/cyborgclient/tests/unit/osc/v2/test_deployable.py index 4c07222..afb751c 100644 --- a/cyborgclient/tests/unit/osc/v2/test_deployable.py +++ b/cyborgclient/tests/unit/osc/v2/test_deployable.py @@ -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))