# 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
        current_ctx.set(_ctx)
        params = {'USER': 'testuser'}
        with requests_mock.mock(
                real_http=True) as m:  # real_http to check fake uri and get ex
            # call 1
            with open(
                os.path.join(__location__, 'get_response1.json'), 'r'
            ) as f:
                m.get('http://test123.test:80/testuser/test_rest/get',
                      json=json.load(f),
                      status_code=200)

            def _match_request_text(request):
                return '101' in (request.text or '')

            # call 2
            m.post('http://test123.test:80/test_rest/posts',
                   additional_matcher=_match_request_text,
                   request_headers={'Content-type': 'test/type'},
                   text='resp')

            # call 1
            with open(
                os.path.join(__location__, 'get_response2.json'), 'r'
            ) as f:
                m.get('http://test123.test:80/get',
                      json=json.load(f),
                      headers={'Content-Type': 'application/json'},
                      status_code=200)


# 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

        current_ctx.set(_ctx)
        params = {'USER': 'testuser'}
        with requests_mock.mock(
                real_http=True) as m:  # real_http to check fake uri and get ex
            # call 1
            with open(
                os.path.join(__location__, 'get_response1.json'), 'r'
            ) as f:
                m.get('http://test123.test:80/testuser/test_rest/get',
                      json=json.load(f),
                      status_code=200)

            def _match_request_text(request):
                return '101' in (request.text or '')

            # call 2
            m.post('http://test123.test:80/test_rest/posts',
                   additional_matcher=_match_request_text,
                   request_headers={'Content-type': 'test/type'},
                   text='resp')

            # call 1
            with open(
                os.path.join(__location__, 'get_response2.json'), 'r'
            ) as f:
                m.get('http://test123.test:80/get',
                      json=json.load(f),
                      headers={'Content-Type': 'application/json'},
                      status_code=200)


            tasks.execute(params=params, template_file='mock_param')