Unit test for custom action module
This patch adds unit test for the custom action module. Change-Id: I2fe2fea02d28d6e8864af0b192c918e75e7c4def
This commit is contained in:
parent
bbb0adff90
commit
53436e8f88
|
@ -10,12 +10,9 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from oslo_log import log as logging
|
||||
|
||||
from senlin.engine.actions import base
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class CustomAction(base.Action):
|
||||
ACTIONS = (
|
||||
|
@ -24,11 +21,5 @@ class CustomAction(base.Action):
|
|||
'ACTION_EXECUTE',
|
||||
)
|
||||
|
||||
def __init__(self, context, action, **kwargs):
|
||||
super(CustomAction, self).__init__(context, action, **kwargs)
|
||||
|
||||
def execute(self, **kwargs):
|
||||
return self.RES_OK
|
||||
|
||||
def cancel(self):
|
||||
return self.RES_OK
|
||||
return self.RES_OK, ''
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
|
||||
from senlin.engine.actions import custom_action as ca
|
||||
from senlin.tests.unit.common import base
|
||||
from senlin.tests.unit.common import utils
|
||||
|
||||
|
||||
class CustomActionTest(base.SenlinTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(CustomActionTest, self).setUp()
|
||||
self.ctx = utils.dummy_context()
|
||||
|
||||
def test_init(self):
|
||||
obj = ca.CustomAction(self.ctx, 'OBJECT_ACTION')
|
||||
self.assertIsNotNone(obj)
|
||||
|
||||
def test_execute(self):
|
||||
obj = ca.CustomAction(self.ctx, 'OBJECT_ACTION')
|
||||
|
||||
params = {'key': 'value'}
|
||||
res = obj.execute(**params)
|
||||
|
||||
self.assertEqual(obj.RES_OK, res[0])
|
||||
self.assertEqual('', res[1])
|
Loading…
Reference in New Issue