# Path: cloudify_rest/tasks.py
# def _get_params_attributes(ctx, runtime_properties, params_list):
# def bunch_execute(templates=None, **kwargs):
# def execute(*argc, **kwargs):
# def execute_as_relationship(*argc, **kwargs):
# def execute_as_workflow(*args, **kwargs):
# def _execute_in_retry(template, params, instance_props, node_props,
#                       resource_callback=None, save_path=None,
#                       prerender=False, remove_calls=False, auth=None):
# def _execute(params, template_file, retry_count, retry_sleep, ctx, **kwargs):


import unittest
import requests_mock
import json
import os
import logging
from mock import MagicMock, patch
from cloudify.exceptions import RecoverableError, NonRecoverableError
from cloudify.mocks import MockCloudifyContext
from cloudify.state import current_ctx
from cloudify.manager import DirtyTrackingDict
from cloudify_rest import tasks
# See the License for the specific language governing permissions and
# limitations under the License.




class TestPlugin(unittest.TestCase):

    def test_execute_mock_sdk(self):
        _ctx = MockCloudifyContext('node_name',
                                   properties={'hosts': ['--fake.cake--',
                                                         'test123.test'],
                                               'port': -1,
                                               'ssl': False,
                                               'verify': False,
                                               'params': {'f': 'e'}})
        _ctx.instance._runtime_properties = DirtyTrackingDict(
            {'b': {'c': 'd'}})
        __location__ = os.path.realpath(
            os.path.join(os.getcwd(), os.path.dirname(__file__)))
        with open(os.path.join(__location__, 'template1.yaml'), 'r') as f:
            template = f.read()
        _ctx.get_resource = MagicMock(return_value=template.encode('utf-8'))
        _ctx.logger.setLevel(logging.DEBUG)
        current_ctx.set(_ctx)

        check_mock = MagicMock(return_value={})
        with patch(
            "cloudify_rest.tasks.utility.process", check_mock
        ):

# Path: cloudify_rest/tasks.py
# def _get_params_attributes(ctx, runtime_properties, params_list):
# def bunch_execute(templates=None, **kwargs):
# def execute(*argc, **kwargs):
# def execute_as_relationship(*argc, **kwargs):
# def execute_as_workflow(*args, **kwargs):
# def _execute_in_retry(template, params, instance_props, node_props,
#                       resource_callback=None, save_path=None,
#                       prerender=False, remove_calls=False, auth=None):
# def _execute(params, template_file, retry_count, retry_sleep, ctx, **kwargs):


# Path: cloudify_rest/tests/test_plugin.py
import unittest
import requests_mock
import json
import os
import logging
from mock import MagicMock, patch
from cloudify.exceptions import RecoverableError, NonRecoverableError
from cloudify.mocks import MockCloudifyContext
from cloudify.state import current_ctx
from cloudify.manager import DirtyTrackingDict
from cloudify_rest import tasks

# See the License for the specific language governing permissions and
# limitations under the License.




class TestPlugin(unittest.TestCase):

    def test_execute_mock_sdk(self):
        _ctx = MockCloudifyContext('node_name',
                                   properties={'hosts': ['--fake.cake--',
                                                         'test123.test'],
                                               'port': -1,
                                               'ssl': False,
                                               'verify': False,
                                               'params': {'f': 'e'}})
        _ctx.instance._runtime_properties = DirtyTrackingDict(
            {'b': {'c': 'd'}})
        __location__ = os.path.realpath(
            os.path.join(os.getcwd(), os.path.dirname(__file__)))
        with open(os.path.join(__location__, 'template1.yaml'), 'r') as f:
            template = f.read()
        _ctx.get_resource = MagicMock(return_value=template.encode('utf-8'))
        _ctx.logger.setLevel(logging.DEBUG)
        current_ctx.set(_ctx)

        check_mock = MagicMock(return_value={})
        with patch(
            "cloudify_rest.tasks.utility.process", check_mock
        ):

            tasks.bunch_execute(templates=[{