def test_run(self, get_obj_client_mock): # setup swift swift = mock.MagicMock() swift.get_account.return_value = ({}, [ { 'count': 1, 'bytes': 55, 'name': 'overcloud' }, ]) swift.get_container.return_value = ({ 'x-container-meta-usage-tripleo': 'plan', }, []) get_obj_client_mock.return_value = swift # Test action = plan.ListPlansAction() action.run(self.ctx) # verify self.assertEqual([self.container], action.run(self.ctx)) swift.get_account.assert_called() swift.get_container.assert_called_with(self.container)
def test_run(self, get_workflow_client_mock, get_obj_client_mock): # setup swift swift = mock.MagicMock() swift.get_account.return_value = ({}, [ { 'count': 1, 'bytes': 55, 'name': 'overcloud' }, ]) swift.get_container.return_value = ({ 'x-container-meta-usage-tripleo': 'plan', }, []) get_obj_client_mock.return_value = swift # setup mistral mistral = mock.MagicMock() env_item = mock.Mock() env_item.name = self.container mistral.environments.list.return_value = [env_item] get_workflow_client_mock.return_value = mistral # Test action = plan.ListPlansAction() action.run() # verify self.assertEqual([self.container], action.run()) swift.get_account.assert_called() swift.get_container.assert_called_with(self.container)
def list_deployment_plans(clients): mistral_context = clients.tripleoclient.create_mistral_context() return plan.ListPlansAction().run(mistral_context)