
Remove logic to stage heat template in git repo. Ranger-agent will receive heat template directly from ranger. Change-Id: I9b6b0df2460989775a51368d019e49e66369c56e
92 lines
2.8 KiB
Python
92 lines
2.8 KiB
Python
# Copyright (c) 2012 OpenStack Foundation
|
|
# All Rights Reserved.
|
|
#
|
|
# 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.
|
|
|
|
"""
|
|
Unit Tests for ord.client.rpcapi
|
|
"""
|
|
import copy
|
|
from mox3 import stubout
|
|
from ord.client import rpcapi
|
|
from ord.tests import base
|
|
from oslo_config import cfg
|
|
|
|
CONF = cfg.CONF
|
|
|
|
|
|
class RpcAPITestCase(base.BaseTestCase):
|
|
|
|
def setUp(self):
|
|
super(RpcAPITestCase, self).setUp()
|
|
self.stubs = stubout.StubOutForTesting()
|
|
self.addCleanup(self.stubs.UnsetAll)
|
|
self.addCleanup(self.stubs.SmartUnsetAll)
|
|
|
|
def _test_api(self, method, rpc_method, **kwargs):
|
|
|
|
ctxt = {'request_id': '1'}
|
|
rpcapi_inst = rpcapi.RpcAPI()
|
|
|
|
self.assertIsNotNone(rpcapi_inst.target)
|
|
self.assertIsNotNone(rpcapi_inst.transport)
|
|
self.assertIsNotNone(rpcapi_inst._client)
|
|
self.assertEqual(rpcapi_inst.target.topic, 'ord-notifier-q')
|
|
|
|
expected_retval = 'foo' if method == 'call' else None
|
|
|
|
target = {
|
|
"version": kwargs.pop('version', '1.0')
|
|
}
|
|
|
|
expected_msg = copy.deepcopy(kwargs)
|
|
|
|
self.fake_args = None
|
|
self.fake_kwargs = None
|
|
|
|
def _fake_prepare_method(*args, **kwds):
|
|
for kwd in kwds:
|
|
self.assertEqual(kwds[kwd], target[kwd])
|
|
return rpcapi_inst._client
|
|
|
|
def _fake_rpc_method(*args, **kwargs):
|
|
self.fake_args = args
|
|
self.fake_kwargs = kwargs
|
|
if expected_retval:
|
|
return expected_retval
|
|
|
|
self.stubs.Set(rpcapi_inst._client, "prepare", _fake_prepare_method)
|
|
self.stubs.Set(rpcapi_inst._client, rpc_method, _fake_rpc_method)
|
|
|
|
retval = getattr(rpcapi_inst, method)(ctxt, **kwargs)
|
|
|
|
self.assertEqual(retval, expected_retval)
|
|
expected_args = [ctxt, method, expected_msg]
|
|
|
|
for arg, expected_arg in zip(self.fake_args, expected_args):
|
|
self.assertEqual(arg, expected_arg)
|
|
|
|
def test_invoke_notifier_rpc(self):
|
|
kwargs = {
|
|
'request_id': '1',
|
|
'resource_id': 'qwe1234',
|
|
'resource-type': 'image'
|
|
}
|
|
payload = str(kwargs)
|
|
heat_template = 'test'
|
|
self._test_api('invoke_notifier_rpc',
|
|
rpc_method='cast',
|
|
payload=payload,
|
|
version='1.0',
|
|
heat_template=heat_template)
|