1 # ================================================================================
2 # Copyright (c) 2019 Wipro Limited Intellectual Property. All rights reserved.
3 # ================================================================================
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 # ============LICENSE_END=========================================================
18 """unit tests for tasks in clamppolicyplugin"""
23 from cloudify.exceptions import NonRecoverableError
24 from cloudify.state import current_ctx
26 from clamppolicyplugin import tasks
27 from tests.log_ctx import CtxLogger
28 from tests.mock_cloudify_ctx import (TARGET_NODE_ID, TARGET_NODE_NAME,
29 MockCloudifyContextFull)
30 from tests.mock_setup import (CONFIG_NAME, MONKEYED_POLICY_ID, POLICY_BODY,
31 POLICY_ID, POLICY_MODEL_ID, POLICY_NAME, MonkeyedNode,
32 MonkeyedPolicyBody, MonkeyedResponse)
34 from cloudify.mocks import MockCloudifyContext
35 from cloudify.state import current_ctx
37 def monkeyed_policy_handler_get(full_path, headers=None):
38 """monkeypatch for the GET to policy-engine"""
39 return MonkeyedResponse(full_path, headers,
40 MonkeyedPolicyBody.create_policy(MONKEYED_POLICY_ID))
42 def test_policy_get():
43 """test policy_get operation on clamp.nodes.policy node"""
44 mock_ctx = MockCloudifyContext(node_id='policy_model_id',node_name='clamp.nodes.policy')
45 current_ctx.set(mock_ctx)