# -*- coding: utf-8 -*-
###
# (C) Copyright [2019] Hewlett Packard Enterprise Development LP
#
# 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.
###
import io
import unittest
import mock
from mock import call

from tests.test_utils import mock_builtin
from hpOneView.connection import connection
from hpOneView import exceptions
from hpOneView.resources.resource import (ResourceClient, ResourceHelper, ResourceFileHandlerMixin,
                                          ResourceZeroBodyMixin, ResourcePatchMixin, ResourceUtilizationMixin,
                                          ResourceSchemaMixin, Resource,
                                          RESOURCE_CLIENT_INVALID_ID, UNRECOGNIZED_URI, TaskMonitor,
                                          RESOURCE_CLIENT_TASK_EXPECTED, RESOURCE_ID_OR_URI_REQUIRED,
                                          transform_list_to_dict, extract_id_from_uri, merge_resources,
                                          merge_default_values, unavailable_method)


class StubResourceFileHandler(ResourceFileHandlerMixin, Resource):
    """Stub class to test resource file operations"""


class StubResourceZeroBody(ResourceZeroBodyMixin, Resource):
    """Stub class to test resoruce zero body methods"""


class StubResourcePatch(ResourcePatchMixin, Resource):
    """Stub class to test resource patch operations"""


class StubResourceUtilization(ResourceUtilizationMixin, Resource):
    """Stub class to test resource utilization methods"""


class StubResourceSchema(ResourceSchemaMixin, Resource):
    """Stub class to test resource schema methods"""


class StubResource(Resource):
    """Stub class to test resource common methods"""
    URI = "/rest/testuri"


class BaseTest(unittest.TestCase):

    URI = "/rest/testuri"
    TYPE_V200 = "typeV200"
    TYPE_V300 = "typeV300"

    DEFAULT_VALUES = {
        "200": {"type": TYPE_V200},
        "300": {"type": TYPE_V300}
    }

    def setUp(self, resource_client=None):
        self.resource_client = resource_client
        self.resource_client.URI = self.URI
        self.resource_client.DEFAULT_VALUES = self.DEFAULT_VALUES
        self.resource_client.data = {"uri": "/rest/testuri"}
        self.resource_client._merge_default_values()
        self.task = {"task": "task", "taskState": "Finished"}
        self.response_body = {"body": "body"}
        self.custom_headers = {"Accept-Language": "en_US"}


class ResourceFileHandlerMixinTest(BaseTest):

    def setUp(self):
        self.connection = connection('127.0.0.1', 300)
        self.resource_client = StubResourceFileHandler(self.connection)
        super(ResourceFileHandlerMixinTest, self).setUp(self.resource_client)

    @mock.patch.object(connection, "post_multipart_with_response_handling")
    def test_upload_should_call_post_multipart(self, mock_post_multipart):
        uri = "/rest/testuri/"
        filepath = "test/SPPgen9snap6.2015_0405.81.iso"
        mock_post_multipart.return_value = None, mock.Mock()

        self.resource_client.upload(filepath, uri)

        mock_post_multipart.assert_called_once_with(uri, filepath, "SPPgen9snap6.2015_0405.81.iso")

    @mock.patch.object(connection, "post_multipart_with_response_handling")
    def test_upload_should_call_post_multipart_with_resource_uri_when_not_uri_provided(self, mock_post_multipart):
        filepath = "test/SPPgen9snap6.2015_0405.81.iso"
        mock_post_multipart.return_value = None, mock.Mock()

        self.resource_client.upload(filepath)

        mock_post_multipart.assert_called_once_with("/rest/testuri", mock.ANY, mock.ANY)

    @mock.patch.object(connection, "post_multipart_with_response_handling")
    @mock.patch.object(TaskMonitor, "wait_for_task")
    @mock.patch.object(connection, "get")
    def test_upload_should_wait_for_task_when_response_is_task(self, mock_get, mock_wait4task, mock_post_multipart):
        uri = "/rest/testuri/"
        filepath = "test/SPPgen9snap6.2015_0405.81.iso"
        mock_post_multipart.return_value = self.task, mock.Mock()

        self.resource_client.upload(filepath, uri)

        mock_wait4task.assert_called_once_with(self.task, -1)

    @mock.patch.object(connection, "post_multipart_with_response_handling")
    @mock.patch.object(TaskMonitor, "wait_for_task")
    def test_upload_should_not_wait_for_task_when_response_is_not_task(self, mock_wait4task, mock_post_multipart):
        uri = "/rest/testuri/"
        filepath = "test/SPPgen9snap6.2015_0405.81.iso"
        mock_post_multipart.return_value = None, mock.Mock()

        self.resource_client.upload(filepath, uri)

        mock_wait4task.not_been_called()

    @mock.patch.object(connection, "post_multipart_with_response_handling")
    @mock.patch.object(TaskMonitor, "wait_for_task")
    @mock.patch.object(connection, "get")
    def test_upload_should_return_associated_resource_when_response_is_task(self, mock_get, mock_wait4task,
                                                                            mock_post_multipart):
        fake_associated_resurce = mock.Mock()
        uri = "/rest/testuri/"
        filepath = "test/SPPgen9snap6.2015_0405.81.iso"
        mock_post_multipart.return_value = self.task, mock.Mock()
        mock_wait4task.return_value = fake_associated_resurce

        result = self.resource_client.upload(filepath, uri)

        self.assertEqual(result, fake_associated_resurce)

    @mock.patch.object(connection, "post_multipart_with_response_handling")
    @mock.patch.object(TaskMonitor, "wait_for_task")
    def test_upload_should_return_resource_when_response_is_not_task(self, mock_wait4task, mock_post_multipart):
        fake_response_body = mock.Mock()
        uri = "/rest/testuri/"
        filepath = "test/SPPgen9snap6.2015_0405.81.iso"
        mock_post_multipart.return_value = None, fake_response_body

        result = self.resource_client.upload(filepath, uri)

        self.assertEqual(result, fake_response_body)

    @mock.patch.object(connection, "download_to_stream")
    @mock.patch(mock_builtin("open"))
    def test_download_should_call_download_to_stream_with_given_uri(self, mock_open, mock_download_to_stream):
        file_path = "~/archive.log"
        uri = "/rest/testuri/3ec91dd2-0ebb-4484-8b2d-90d065114315"
        mock_open.return_value = io.StringIO()

        self.resource_client.download(uri, file_path)

        mock_download_to_stream.assert_called_once_with(mock.ANY, uri)

    @mock.patch.object(connection, "download_to_stream")
    @mock.patch(mock_builtin("open"))
    def test_download_should_call_download_to_stream_with_open_file(self, mock_open, mock_download_to_stream):
        file_path = "~/archive.log"
        uri = "/rest/testuri/3ec91dd2-0ebb-4484-8b2d-90d065114315"
        fake_file = io.StringIO()
        mock_open.return_value = fake_file

        self.resource_client.download(uri, file_path)

        mock_open.assert_called_once_with(file_path, 'wb')
        mock_download_to_stream.assert_called_once_with(fake_file, mock.ANY)

    @mock.patch.object(connection, "download_to_stream")
    @mock.patch(mock_builtin("open"))
    def test_download_should_return_true_when_success(self, mock_open, mock_download_to_stream):
        file_path = "~/archive.log"
        uri = "/rest/testuri/3ec91dd2-0ebb-4484-8b2d-90d065114315"
        mock_download_to_stream.return_value = True
        mock_open.return_value = io.StringIO()

        result = self.resource_client.download(uri, file_path)

        self.assertTrue(result)

    @mock.patch.object(connection, "download_to_stream")
    @mock.patch(mock_builtin("open"))
    def test_download_should_return_false_when_error(self, mock_open, mock_download_to_stream):
        file_path = "~/archive.log"
        uri = "/rest/testuri/3ec91dd2-0ebb-4484-8b2d-90d065114315"
        mock_download_to_stream.return_value = False
        mock_open.return_value = io.StringIO()

        result = self.resource_client.download(uri, file_path)

        self.assertFalse(result)


class ResourceZeroBodyMixinTest(BaseTest):

    def setUp(self):
        self.connection = connection('127.0.0.1', 300)
        self.resource_client = StubResourceZeroBody(self.connection)
        super(ResourceZeroBodyMixinTest, self).setUp(self.resource_client)

    @mock.patch.object(connection, "post")
    @mock.patch.object(TaskMonitor, "wait_for_task")
    def test_create_with_zero_body_called_once(self, mock_wait4task, mock_post):
        mock_post.return_value = self.task, self.task
        mock_wait4task.return_value = self.task
        self.resource_client.create_with_zero_body()

        mock_post.assert_called_once_with(
            "/rest/testuri", {}, custom_headers=None)

    @mock.patch.object(connection, "post")
    @mock.patch.object(TaskMonitor, "wait_for_task")
    def test_create_with_zero_body_called_once_without_uri(self, mock_wait4task, mock_post):
        mock_post.return_value = self.task, self.task
        mock_wait4task.return_value = self.task
        self.resource_client.create_with_zero_body(timeout=-1)

        mock_post.assert_called_once_with(
            "/rest/testuri", {}, custom_headers=None)

    @mock.patch.object(connection, "post")
    @mock.patch.object(TaskMonitor, "wait_for_task")
    def test_create_with_zero_body_and_custom_headers(self, mock_wait4task, mock_post):
        mock_post.return_value = self.task, self.task
        mock_wait4task.return_value = self.task
        self.resource_client.create_with_zero_body(custom_headers=self.custom_headers)

        mock_post.assert_called_once_with(mock.ANY, mock.ANY, custom_headers={"Accept-Language": "en_US"})

    @mock.patch.object(connection, "post")
    @mock.patch.object(TaskMonitor, "wait_for_task")
    def test_create_with_zero_body_return_entity(self, mock_wait4task, mock_post):
        response_body = {"resource_name": "name"}

        mock_post.return_value = self.task, self.task
        mock_wait4task.return_value = response_body

        new_resource = self.resource_client.create_with_zero_body(timeout=-1)

        self.assertNotEqual(new_resource, self.resource_client)

    @mock.patch.object(connection, "post")
    def test_create_with_zero_body_without_task(self, mock_post):
        mock_post.return_value = None, self.response_body

        new_resource = self.resource_client.create_with_zero_body()

        self.assertNotEqual(new_resource, self.resource_client)

    @mock.patch.object(Resource, "ensure_resource_data")
    @mock.patch.object(connection, "put")
    @mock.patch.object(TaskMonitor, "wait_for_task")
    def test_update_with_zero_body_called_once(self, mock_wait4task, mock_update, mock_ensure_resource):
        mock_update.return_value = self.task, self.task
        mock_wait4task.return_value = self.task
        self.resource_client.URI = "/rest/enclosures"

        self.resource_client.update_with_zero_body("/rest/enclosures/09USE133E5H4/configuration",
                                                   timeout=-1)

        mock_update.assert_called_once_with(
            "/rest/enclosures/09USE133E5H4/configuration", None, custom_headers=None)

    @mock.patch.object(Resource, "ensure_resource_data")
    @mock.patch.object(connection, "put")
    @mock.patch.object(TaskMonitor, "wait_for_task")
    def test_update_with_zero_body_and_custom_headers(self, mock_wait4task, mock_update, mock_ensure_resource):
        mock_update.return_value = self.task, self.task
        mock_wait4task.return_value = self.task

        self.resource_client.update_with_zero_body(uri="/rest/testuri", custom_headers=self.custom_headers)

        mock_update.assert_called_once_with(mock.ANY, mock.ANY, custom_headers={"Accept-Language": "en_US"})

    @mock.patch.object(Resource, "ensure_resource_data")
    @mock.patch.object(connection, "put")
    @mock.patch.object(TaskMonitor, "wait_for_task")
    def test_update_with_zero_body_return_entity(self, mock_wait4task, mock_put, mock_ensure_resource):
        response_body = {"resource_name": "name"}
        self.resource_client.URI = "/rest/enclosures"

        mock_put.return_value = self.task, self.task
        mock_wait4task.return_value = response_body

        result = self.resource_client.update_with_zero_body(
            "/rest/enclosures/09USE133E5H4/configuration", timeout=-1)

        self.assertEqual(result, response_body)

    @mock.patch.object(connection, "put")
    def test_update_with_zero_body_without_task(self, mock_put):
        mock_put.return_value = None, self.response_body
        self.resource_client.URI = "/rest/enclosures"
        result = self.resource_client.update_with_zero_body(
            "/rest/enclosures/09USE133E5H4/configuration", timeout=-1)

        self.assertEqual(result, self.response_body)


class ResourcePatchMixinTest(BaseTest):

    def setUp(self):
        self.connection = connection('127.0.0.1', 300)
        self.resource_client = StubResourcePatch(self.connection)
        super(ResourcePatchMixinTest, self).setUp(self.resource_client)

    @mock.patch.object(Resource, "ensure_resource_data")
    @mock.patch.object(connection, "patch")
    def test_patch_request_when_id_is_provided_v200(self, mock_patch, mock_ensure_resource):
        uri = "/rest/testuri"
        request_body = [{
            "op": "replace",
            "path": "/name",
            "value": "new_name",
        }]
        mock_patch.return_value = {}, {}
        self.connection._apiVersion = 200

        self.resource_client.patch("replace", "/name", "new_name")

        mock_patch.assert_called_once_with(uri, request_body, custom_headers={})

    @mock.patch.object(Resource, "ensure_resource_data")
    @mock.patch.object(connection, "patch")
    def test_patch_request_when_id_is_provided_v300(self, mock_patch, mock_ensure_resource):
        request_body = [{
            "op": "replace",
            "path": "/name",
            "value": "new_name",
        }]
        mock_patch.return_value = {}, {}
        self.resource_client.patch("replace", "/name", "new_name")

        mock_patch.assert_called_once_with(
            "/rest/testuri", request_body, custom_headers={"Content-Type": "application/json-patch+json"})

    @mock.patch.object(Resource, "ensure_resource_data")
    @mock.patch.object(connection, "patch")
    def test_patch_request_when_uri_is_provided(self, mock_patch, mock_ensure_resource):
        request_body = [{
            "op": "replace",
            "path": "/name",
            "value": "new_name",
        }]
        mock_patch.return_value = {}, {}
        self.resource_client.patch("replace", "/name", "new_name")

        mock_patch.assert_called_once_with(
            "/rest/testuri", request_body, custom_headers={"Content-Type": "application/json-patch+json"})

    @mock.patch.object(Resource, "ensure_resource_data")
    @mock.patch.object(connection, "patch")
    def test_patch_with_custom_headers_v200(self, mock_patch, mock_ensure_resource):
        mock_patch.return_value = {}, {}
        self.connection._apiVersion = 200

        self.resource_client.patch("operation", "/field", "value",
                                   custom_headers=self.custom_headers)

        mock_patch.assert_called_once_with(mock.ANY, mock.ANY, custom_headers={"Accept-Language": "en_US"})

    @mock.patch.object(Resource, "ensure_resource_data")
    @mock.patch.object(connection, "patch")
    def test_patch_with_custom_headers_v300(self, mock_patch, mock_ensure_resource):
        mock_patch.return_value = {}, {}
        self.resource_client.patch("operation", "/field", "value",
                                   custom_headers=self.custom_headers)

        mock_patch.assert_called_once_with(mock.ANY,
                                           mock.ANY,
                                           custom_headers={"Accept-Language": "en_US",
                                                           "Content-Type": "application/json-patch+json"})

    @mock.patch.object(Resource, "ensure_resource_data")
    @mock.patch.object(connection, "patch")
    @mock.patch.object(TaskMonitor, "wait_for_task")
    def test_patch_return_entity(self, mock_wait4task, mock_patch, mock_ensure_resource):
        entity = {"resource_id": "123a53cz"}
        mock_patch.return_value = self.task, self.task
        mock_wait4task.return_value = entity
        self.resource_client.patch("replace", "/name", "new_name")

        self.assertEqual(self.resource_client.data, entity)

    @mock.patch.object(Resource, "ensure_resource_data")
    @mock.patch.object(connection, "patch")
    @mock.patch.object(TaskMonitor, "get_completed_task")
    def test_patch_request_custom_headers_with_content_type(self, mock_task, mock_patch, mock_ensure_resource):
        uri = "/rest/testuri"
        dict_info = {"resource_name": "a name"}
        mock_patch.return_value = {}, {}
        headers = {"Content-Type": "application/json",
                   "Extra": "extra"}
        self.connection._apiVersion = 300

        self.resource_client.patch_request(uri, body=dict_info, custom_headers=headers)

        mock_patch.assert_called_once_with(uri, dict_info, custom_headers=headers)

    @mock.patch.object(Resource, "ensure_resource_data")
    @mock.patch.object(connection, "patch")
    @mock.patch.object(TaskMonitor, "get_completed_task")
    def test_patch_request_custom_headers(self, mock_task, mock_patch, mock_ensure_resource):
        uri = "/rest/testuri"
        dict_info = {"resource_name": "a name"}
        mock_patch.return_value = {}, {}
        headers = {"Extra": "extra"}
        self.connection._apiVersion = 300

        self.resource_client.patch_request(uri, body=dict_info, custom_headers=headers)

        mock_patch.assert_called_once_with(
            uri,
            dict_info,
            custom_headers={"Extra": "extra",
                            "Content-Type": "application/json-patch+json"})

    @mock.patch.object(Resource, "ensure_resource_data")
    @mock.patch.object(connection, "patch")
    @mock.patch.object(TaskMonitor, "wait_for_task")
    def test_wait_for_activity_on_patch(self, mock_wait4task, mock_patch, mock_ensure_resource):
        entity = {"resource_id": "123a53cz"}
        mock_patch.return_value = self.task, self.task
        mock_wait4task.return_value = entity
        self.resource_client.patch("replace", "/name", "new_name")

        mock_wait4task.assert_called_once_with(self.task, mock.ANY)


class ResourceUtilizationMixinTest(BaseTest):

    def setUp(self):
        self.connection = connection('127.0.0.1', 300)
        self.resource_client = StubResourceUtilization(self.connection)
        super(ResourceUtilizationMixinTest, self).setUp(self.resource_client)

    @mock.patch.object(Resource, "ensure_resource_data")
    @mock.patch.object(connection, "get")
    def test_get_utilization_with_args(self, mock_get, mock_ensure_resource):
        self.resource_client.get_utilization(fields="AmbientTemperature,AveragePower,PeakPower",
                                             filter="startDate=2016-05-30T03:29:42.361Z",
                                             refresh=True, view="day")

        expected_uri = "/rest/testuri/utilization" \
                       "?filter=startDate%3D2016-05-30T03%3A29%3A42.361Z" \
                       "&fields=AmbientTemperature%2CAveragePower%2CPeakPower" \
                       "&refresh=true" \
                       "&view=day"

        mock_get.assert_called_once_with(expected_uri)

    @mock.patch.object(Resource, "ensure_resource_data")
    @mock.patch.object(connection, "get")
    def test_get_utilization_with_multiple_filters(self, mock_get, mock_ensure_resource):
        self.resource_client.get_utilization(
            fields="AmbientTemperature,AveragePower,PeakPower",
            filter=["startDate=2016-05-30T03:29:42.361Z",
                    "endDate=2016-05-31T03:29:42.361Z"],
            refresh=True,
            view="day")
        expected_uri = "/rest/testuri/utilization" \
                       "?filter=startDate%3D2016-05-30T03%3A29%3A42.361Z" \
                       "&filter=endDate%3D2016-05-31T03%3A29%3A42.361Z" \
                       "&fields=AmbientTemperature%2CAveragePower%2CPeakPower" \
                       "&refresh=true" \
                       "&view=day"

        mock_get.assert_called_once_with(expected_uri)

    @mock.patch.object(Resource, "ensure_resource_data")
    @mock.patch.object(connection, "get")
    def test_get_utilization_by_id_with_defaults(self, mock_get, mock_ensure_resource):
        self.resource_client.get_utilization()

        expected_uri = "/rest/testuri/utilization"

        mock_get.assert_called_once_with(expected_uri)

    @mock.patch.object(Resource, "ensure_resource_data")
    @mock.patch.object(connection, "get")
    def test_get_utilization_by_uri_with_defaults(self, mock_get, mock_ensure_resource):
        self.resource_client.get_utilization()

        expected_uri = "/rest/testuri/utilization"

        mock_get.assert_called_once_with(expected_uri)


class ResourceSchemaMixinTest(BaseTest):

    def setUp(self):
        self.connection = connection('127.0.0.1', 300)
        self.resource_client = StubResourceSchema(self.connection)
        super(ResourceSchemaMixinTest, self).setUp(self.resource_client)

    @mock.patch.object(connection, "get")
    def test_get_schema_uri(self, mock_get):
        self.resource_client.get_schema()
        mock_get.assert_called_once_with(self.URI + "/schema")


class ResourceTest(BaseTest):

    def setUp(self):
        self.connection = connection('127.0.0.1', 300)
        self.resource_client = StubResource(self.connection)
        super(ResourceTest, self).setUp(self.resource_client)
        self.resource_helper = ResourceHelper(self.URI, self.connection, None)

    @mock.patch.object(ResourceHelper, "do_put")
    @mock.patch.object(Resource, "ensure_resource_data")
    def test_ensure_resource_should_call_once(self, mock_do_put, mock_ensure_resource):
        self.resource_client.data = {"uri": "/rest/test"}
        self.resource_client.update(data={"name": "test"})
        mock_do_put.assert_called_once()
        mock_ensure_resource.assert_called_once()

    def test_ensure_resource_raise_unique_identifier_exception(self):
        self.resource_client.data = []
        self.assertRaises(exceptions.HPOneViewMissingUniqueIdentifiers,
                          self.resource_client.ensure_resource_data)

    @mock.patch.object(ResourceHelper, "do_get")
    def test_ensure_resource_raise_resource_not_found_exception_with_uri(self, mock_do_get):
        self.resource_client.data = {"uri": "/uri/test"}
        mock_do_get.return_value = []
        with self.assertRaises(exceptions.HPOneViewResourceNotFound):
            self.resource_client.ensure_resource_data(update_data=True)

    @mock.patch.object(Resource, "get_by")
    def test_ensure_resource_raise_resource_not_found_exception_without_uri(self, mock_get_by):
        self.resource_client.data = {"name": "testname"}
        mock_get_by.return_value = []
        with self.assertRaises(exceptions.HPOneViewResourceNotFound):
            self.resource_client.ensure_resource_data(update_data=True)

    @mock.patch.object(ResourceHelper, "do_get")
    @mock.patch.object(Resource, "get_by")
    def test_ensure_resource_should_update_resource_data(self, mock_do_get, mock_get_by):
        get_by_return_value = [{"name": "testname", "uri": "/rest/testuri"}]
        self.resource_client.data = {"name": "testname"}
        mock_do_get.return_value = get_by_return_value
        self.resource_client.ensure_resource_data(update_data=True)

        self.assertEqual(self.resource_client.data, get_by_return_value[0])

    @mock.patch.object(Resource, "get_by")
    def test_ensure_resource_without_data_update(self, mock_get_by):
        mock_get_by.return_value = []
        actual_result = self.resource_client.ensure_resource_data(update_data=False)
        expected_result = None
        self.assertEqual(actual_result, expected_result)

    @mock.patch.object(connection, "get")
    def test_get_all_called_once(self, mock_get):
        filter = "'name'='OneViewSDK \"Test FC Network'"
        sort = "name:ascending"
        query = "name NE 'WrongName'"

        mock_get.return_value = {"members": [{"member": "member"}]}

        result = self.resource_helper.get_all(
            1, 500, filter, query, sort)

        uri = "{resource_uri}?start=1" \
              "&count=500" \
              "&filter=%27name%27%3D%27OneViewSDK%20%22Test%20FC%20Network%27" \
              "&query=name%20NE%20%27WrongName%27" \
              "&sort=name%3Aascending".format(resource_uri=self.URI)

        self.assertEqual([{"member": "member"}], result)
        mock_get.assert_called_once_with(uri)

    @mock.patch.object(connection, "get")
    def test_get_all_with_defaults(self, mock_get):
        self.resource_client.get_all()
        uri = "{resource_uri}?start=0&count=-1".format(resource_uri=self.URI)

        mock_get.assert_called_once_with(uri)

    @mock.patch.object(connection, "get")
    def test_get_all_with_custom_uri(self, mock_get):
        self.resource_helper.get_all(uri="/rest/testuri/12467836/subresources")
        uri = "/rest/testuri/12467836/subresources?start=0&count=-1"

        mock_get.assert_called_once_with(uri)

    @mock.patch.object(connection, "get")
    def test_get_all_with_custom_uri_and_query_string(self, mock_get):
        self.resource_helper.get_all(uri="/rest/testuri/12467836/subresources?param=value")

        uri = "/rest/testuri/12467836/subresources?param=value&start=0&count=-1"
        mock_get.assert_called_once_with(uri)

    @mock.patch.object(connection, "get")
    def test_get_all_with_different_resource_uri_should_fail(self, mock_get):
        try:
            self.resource_helper.get_all(uri="/rest/other/resource/12467836/subresources")
        except exceptions.HPOneViewUnknownType as e:
            self.assertEqual(UNRECOGNIZED_URI, e.args[0])
        else:
            self.fail("Expected Exception was not raised")

    @mock.patch.object(connection, "get")
    def test_get_all_should_do_multi_requests_when_response_paginated(self, mock_get):
        uri_list = ["/rest/testuri?start=0&count=-1",
                    "/rest/testuri?start=3&count=3",
                    "/rest/testuri?start=6&count=3"]

        results = [{"nextPageUri": uri_list[1], "members": [{"id": "1"}, {"id": "2"}, {"id": "3"}]},
                   {"nextPageUri": uri_list[2], "members": [{"id": "4"}, {"id": "5"}, {"id": "6"}]},
                   {"nextPageUri": None, "members": [{"id": "7"}, {"id": "8"}]}]

        mock_get.side_effect = results

        self.resource_client.get_all()

        expected_calls = [call(uri_list[0]), call(uri_list[1]), call(uri_list[2])]
        self.assertEqual(mock_get.call_args_list, expected_calls)

    @mock.patch.object(connection, "get")
    def test_get_all_with_count_should_do_multi_requests_when_response_paginated(self, mock_get):
        uri_list = ["/rest/testuri?start=0&count=15",
                    "/rest/testuri?start=3&count=3",
                    "/rest/testuri?start=6&count=3"]

        results = [{"nextPageUri": uri_list[1], "members": [{"id": "1"}, {"id": "2"}, {"id": "3"}]},
                   {"nextPageUri": uri_list[2], "members": [{"id": "4"}, {"id": "5"}, {"id": "6"}]},
                   {'nextPageUri': None, "members": [{"id": "7"}, {"id": "8"}]}]

        mock_get.side_effect = results

        self.resource_client.get_all(count=15)

        expected_calls = [call(uri_list[0]), call(uri_list[1]), call(uri_list[2])]
        self.assertEqual(mock_get.call_args_list, expected_calls)

    @mock.patch.object(connection, "get")
    def test_get_all_should_return_all_items_when_response_paginated(self, mock_get):
        uri_list = ["/rest/testuri?start=0&count=-1",
                    "/rest/testuri?start=3&count=3",
                    "/rest/testuri?start=6&count=1"]

        results = [{"nextPageUri": uri_list[1], "members": [{"id": "1"}, {"id": "2"}, {"id": "3"}]},
                   {"nextPageUri": uri_list[2], "members": [{"id": "4"}, {"id": "5"}, {"id": "6"}]},
                   {"nextPageUri": None, "members": [{"id": "7"}]}]

        mock_get.side_effect = results

        result = self.resource_client.get_all()

        expected_items = [{'id': '1'}, {'id': '2'}, {'id': '3'}, {'id': '4'}, {'id': '5'}, {'id': '6'}, {'id': '7'}]
        self.assertSequenceEqual(result, expected_items)

    @mock.patch.object(connection, 'get')
    def test_get_all_should_limit_results_to_requested_count_when_response_is_paginated(self, mock_get):
        uri_list = ['/rest/testuri?start=0&count=15',
                    '/rest/testuri?start=3&count=3',
                    '/rest/testuri?start=6&count=1']

        results = [{"nextPageUri": uri_list[1], "members": [{"id": "1"}, {"id": "2"}, {"id": "3"}]},
                   {"nextPageUri": uri_list[2], "members": [{"id": "4"}, {"id": "5"}, {"id": "6"}]},
                   {"nextPageUri": None, "members": [{"id": "7"}]}]

        mock_get.side_effect = results

        result = self.resource_client.get_all(count=15)

        expected_items = [{"id": "1"}, {"id": "2"}, {"id": "3"}, {"id": "4"}, {"id": "5"}, {"id": "6"}, {"id": "7"}]
        self.assertSequenceEqual(result, expected_items)

    @mock.patch.object(connection, "get")
    def test_get_all_should_stop_requests_when_requested_count_reached(self, mock_get):
        """
        In this case, the user provides a maximum number of results to be returned but for pagination purposes, a
        nextPageUri is returned by OneView.
        """
        uri_list = ["/rest/testuri?start=0&count=3",
                    "/rest/testuri?start=3&count=3",
                    "/rest/testuri?start=6&count=3"]

        results = [{"nextPageUri": uri_list[1], "members": [{"id": "1"}, {"id": "2"}, {"id": "3"}]},
                   {"nextPageUri": uri_list[2], "members": [{"id": "4"}, {"id": "5"}, {"id": "6"}]},
                   {"nextPageUri": None, "members": [{"id": "7"}, {"id": "8"}]}]

        mock_get.side_effect = results

        self.resource_client.get_all(count=3)

        mock_get.assert_called_once_with(uri_list[0])

    @mock.patch.object(connection, "get")
    def test_get_all_should_stop_requests_when_next_page_is_equal_to_current_page(self, mock_get):
        uri = "/rest/testuri?start=0&count=-1"
        members = [{"id": "1"}, {"id": "2"}, {"id": "3"}]

        mock_get.return_value = {
            "nextPageUri": uri,
            "members": members,
            "uri": uri
        }

        result = self.resource_client.get_all()

        self.assertSequenceEqual(result, members)
        mock_get.assert_called_once_with(uri)

    @mock.patch.object(connection, "get")
    def test_get_all_should_return_empty_list_when_response_has_no_items(self, mock_get):
        mock_get.return_value = {"nextPageUri": None, "members": []}

        result = self.resource_client.get_all()

        self.assertEqual(result, [])

    @mock.patch.object(connection, "get")
    def test_get_all_should_return_empty_list_when_no_members(self, mock_get):
        mock_get.return_value = {"nextPageUri": None, "members": None}

        result = self.resource_client.get_all()

        self.assertEqual(result, [])

    @mock.patch.object(ResourceHelper, "do_get")
    def test_refresh(self, mock_do_get):
        updated_data = {"resource_name": "updated name"}
        mock_do_get.return_value = updated_data
        self.resource_client.refresh()
        self.assertEqual(self.resource_client.data, updated_data)

    @mock.patch.object(connection, "post")
    def test_create_uri(self, mock_post):
        dict_to_create = {"resource_name": "a name"}
        mock_post.return_value = {}, {}
        expected_dict = {"resource_name": "a name", "type": self.TYPE_V300}

        self.resource_client.create(dict_to_create, timeout=-1)
        mock_post.assert_called_once_with(self.URI, expected_dict, custom_headers=None)

    @mock.patch.object(connection, "post")
    def test_create_with_api_version_200(self, mock_post):
        dict_to_create = {"resource_name": "a name"}
        mock_post.return_value = {}, {}

        self.connection._apiVersion = 200
        self.resource_client._merge_default_values()
        expected_dict = {"resource_name": "a name", "type": self.TYPE_V200}

        self.resource_client.create(dict_to_create, timeout=-1)
        mock_post.assert_called_once_with(self.URI, expected_dict, custom_headers=None)

    @mock.patch.object(connection, "post")
    def test_create_with_default_api_version_300(self, mock_post):
        dict_to_create = {"resource_name": "a name"}
        mock_post.return_value = {}, {}

        expected_dict = {"resource_name": "a name", "type": self.TYPE_V300}
        self.resource_client.create(dict_to_create, timeout=-1)
        mock_post.assert_called_once_with(self.URI, expected_dict, custom_headers=None)

    @mock.patch.object(connection, "post")
    def test_create_should_not_override_resource_properties(self, mock_post):
        dict_to_create = {"resource_name": "a name", "type": "anotherType"}
        mock_post.return_value = {}, {}
        expected = {"resource_name": "a name", "type": "anotherType"}
        self.resource_client.create(dict_to_create)

        mock_post.assert_called_once_with(self.URI, expected, custom_headers=None)

    @mock.patch.object(connection, "post")
    def test_create_without_default_values(self, mock_post):
        dict_to_create = {"resource_name": "a name"}
        mock_post.return_value = {}, {}

        resource_client = ResourceClient(self.connection, self.URI)
        resource_client.create(dict_to_create, timeout=-1)

        mock_post.assert_called_once_with(self.URI, dict_to_create, custom_headers=None)

    @mock.patch.object(connection, "post")
    def test_create_with_custom_headers(self, mock_post):
        dict_to_create = {"resource_name": "a name"}
        mock_post.return_value = {}, {}

        self.resource_client.create(dict_to_create, custom_headers=self.custom_headers)

        mock_post.assert_called_once_with(mock.ANY, mock.ANY, custom_headers={"Accept-Language": "en_US"})

    @mock.patch.object(connection, "post")
    def test_create_should_return_new_resource_instance(self, mock_post):
        mock_post.return_value = {}, {}
        new_instance = self.resource_client.create({})
        self.assertNotEqual(self.resource_client, new_instance)

    @mock.patch.object(connection, "post")
    @mock.patch.object(TaskMonitor, "wait_for_task")
    def test_wait_for_activity_on_create(self, mock_wait4task, mock_post):
        mock_post.return_value = self.task, {}
        mock_wait4task.return_value = self.task

        self.resource_client.create({"test": "test"}, timeout=60)

        mock_wait4task.assert_called_once_with(self.task, 60)

    @mock.patch.object(Resource, "ensure_resource_data")
    @mock.patch.object(connection, "delete")
    def test_delete_should_return_true(self, mock_delete, mock_ensure_resource):
        mock_delete.return_value = None, self.response_body
        self.resource_client.data = {"uri": "/rest/testuri"}
        result = self.resource_client.delete()
        self.assertTrue(result)

    @mock.patch.object(connection, 'delete')
    def test_helper_delete_all_should_return_true(self, mock_delete):
        mock_delete.return_value = None, self.response_body

        filter = "name='Exchange Server'"
        result = self.resource_helper.delete_all(filter=filter, force=True, timeout=-1)
        self.assertTrue(result)

    @mock.patch.object(Resource, "ensure_resource_data")
    @mock.patch.object(connection, "delete")
    @mock.patch.object(TaskMonitor, "wait_for_task")
    def test_delete_with_force(self, mock_ensure_resource, mock_delete, mock_wait4task):
        mock_delete.return_value = self.task, self.response_body
        mock_wait4task.return_value = self.task
        self.resource_client.data = {"uri": "/rest/testuri"}
        self.resource_client.delete(force=True)

        mock_delete.assert_called_once_with("/rest/testuri?force=True", custom_headers=None)

    @mock.patch.object(Resource, "ensure_resource_data")
    @mock.patch.object(connection, "delete")
    @mock.patch.object(TaskMonitor, "wait_for_task")
    def test_delete_with_custom_headers(self, mock_ensure_resource, mock_delete, mock_wait4task):
        mock_delete.return_value = self.task, self.response_body
        mock_wait4task.return_value = self.task
        self.resource_client.data = {"uri": "/rest/testuri"}
        self.resource_client.delete(custom_headers=self.custom_headers)

        mock_delete.assert_called_once_with(mock.ANY, custom_headers={"Accept-Language": "en_US"})

    @mock.patch.object(Resource, "ensure_resource_data")
    @mock.patch.object(connection, "put")
    def test_update_with_uri_called_once(self, mock_put, mock_ensure_resource):
        uri = "/rest/testuri"
        dict_to_update = {"name": "test", "type": "typeV300"}
        self.resource_client.data = {'uri': uri}
        expected = {"name": "test", "type": "typeV300", "uri": uri}

        mock_put.return_value = None, self.response_body
        self.resource_client.update(dict_to_update)

        self.assertEqual(self.response_body, self.resource_client.data)
        mock_put.assert_called_once_with(uri, expected, custom_headers=None)

    @mock.patch.object(Resource, "ensure_resource_data")
    @mock.patch.object(connection, "put")
    def test_update_with_custom_headers(self, mock_put, mock_ensure_resource):
        dict_to_update = {"name": "test"}
        mock_put.return_value = None, self.response_body
        self.resource_client.update(dict_to_update, custom_headers=self.custom_headers)

        mock_put.assert_called_once_with(mock.ANY, mock.ANY, custom_headers={"Accept-Language": "en_US"})

    @mock.patch.object(Resource, "ensure_resource_data")
    @mock.patch.object(connection, "put")
    def test_update_with_force(self, mock_put, mock_laod_resource):
        dict_to_update = {"name": "test"}
        uri = "/rest/testuri"
        expected = {"name": "test", "uri": uri, "type": "typeV300"}
        mock_put.return_value = None, self.response_body

        self.resource_client.update(dict_to_update)

        expected_uri = "/rest/testuri"
        mock_put.assert_called_once_with(expected_uri, expected, custom_headers=None)

    @mock.patch.object(Resource, "ensure_resource_data")
    @mock.patch.object(connection, "put")
    def test_update_with_default_api_version_300(self, mock_put, mock_ensure_resource):
        dict_to_update = {"name": "test"}
        uri = "/rest/testuri"
        mock_put.return_value = None, self.response_body
        expected_dict = {"name": "test", "type": self.TYPE_V300, "uri": uri}
        self.resource_client._merge_default_values()
        self.resource_client.update(dict_to_update)
        mock_put.assert_called_once_with(uri, expected_dict, custom_headers=None)

    @mock.patch.object(Resource, "ensure_resource_data")
    @mock.patch.object(connection, "put")
    def test_update_should_not_override_resource_properties(self, mock_put, mock_ensure_resource):
        dict_to_update = {"name": "test", "type": "anotherType"}
        uri = "/rest/testuri"
        mock_put.return_value = None, self.response_body
        expected = {"name": "test", "type": "anotherType", "uri": uri}

        self.resource_client.update(dict_to_update)
        mock_put.assert_called_once_with(uri, expected, custom_headers=None)

    @mock.patch.object(Resource, "ensure_resource_data")
    @mock.patch.object(connection, "put")
    def test_update_without_default_values(self, mock_put, mock_ensure_resource):
        uri = "/rest/testuri"
        dict_to_update = {"name": "test"}
        expected = {"name": "test", "uri": uri, "type": "typeV300"}
        mock_put.return_value = None, self.response_body

        self.resource_client.update(dict_to_update)
        mock_put.assert_called_once_with(uri, expected, custom_headers=None)

    @mock.patch.object(Resource, "ensure_resource_data")
    @mock.patch.object(connection, "put")
    @mock.patch.object(TaskMonitor, "wait_for_task")
    def test_update_uri(self, mock_wait4task, mock_update, mock_ensure_resource):
        uri = "/rest/testuri"
        dict_to_update = {"resource_data": "resource_data", "uri": uri}
        expected = {"resource_data": "resource_data", "uri": uri, "type": "typeV300"}
        mock_update.return_value = self.task, self.response_body
        mock_wait4task.return_value = self.task
        self.resource_client.update(dict_to_update, False)

        self.assertEqual(self.task, self.resource_client.data)
        mock_update.assert_called_once_with(uri, expected, custom_headers=None)

    @mock.patch.object(Resource, "ensure_resource_data")
    @mock.patch.object(connection, "put")
    @mock.patch.object(TaskMonitor, "wait_for_task")
    def test_update_return_entity(self, mock_wait4task, mock_put, mock_ensure_resource):
        uri = "/rest/testuri"
        dict_to_update = {"resource_name": "a name", "uri": uri}
        mock_put.return_value = self.task, {}
        mock_wait4task.return_value = dict_to_update

        self.resource_client.update(dict_to_update, timeout=-1)

        self.assertEqual(self.resource_client.data, dict_to_update)

    @mock.patch.object(Resource, "get_by")
    def test_get_by_name_with_result(self, mock_get_by):
        self.resource_client.get_by_name("Resource Name,")
        mock_get_by.assert_called_once_with("name", "Resource Name,")

    @mock.patch.object(Resource, "get_by")
    def test_get_by_name_without_result(self, mock_get_by):
        mock_get_by.return_value = []
        response = self.resource_client.get_by_name("Resource Name,")
        self.assertIsNone(response)
        mock_get_by.assert_called_once_with("name", "Resource Name,")

    @mock.patch.object(connection, "get")
    def test_get_by_uri(self, mock_get):
        self.resource_client.get_by_uri("/rest/testuri")
        mock_get.assert_called_once_with('/rest/testuri')

    @mock.patch.object(connection, "get")
    def test_get_by_id_with_result(self, mock_get):
        self.resource_client.get_by_id("123")
        mock_get.assert_called_once_with("/rest/testuri/123")

    @mock.patch.object(connection, "get")
    def test_get_by_id_without_result(self, mock_get):
        mock_get.return_value = []
        response = self.resource_client.get_by_id("123")
        self.assertIsNone(response)
        mock_get.assert_called_once_with("/rest/testuri/123")

    @mock.patch.object(connection, "get")
    def test_get_collection_uri(self, mock_get):
        mock_get.return_value = {"members": [{"key": "value"}, {"key": "value"}]}

        self.resource_helper.get_collection()

        mock_get.assert_called_once_with(self.URI)

    @mock.patch.object(connection, "get")
    def test_get_collection_with_filter(self, mock_get):
        mock_get.return_value = {}

        self.resource_helper.get_collection(filter="name=name")

        mock_get.assert_called_once_with(self.URI + "?filter=name%3Dname")

    @mock.patch.object(connection, "get")
    def test_get_collection_with_path(self, mock_get):
        mock_get.return_value = {}

        self.resource_helper.get_collection(path="/test")

        mock_get.assert_called_once_with(self.URI + "/test")

    @mock.patch.object(connection, "get")
    def test_get_collection_with_multiple_filters(self, mock_get):
        mock_get.return_value = {}

        self.resource_helper.get_collection(filter=["name1=one", "name2=two", "name=three"])

        mock_get.assert_called_once_with(self.URI + "?filter=name1%3Done&filter=name2%3Dtwo&filter=name%3Dthree")

    @mock.patch.object(connection, "get")
    def test_get_collection_should_return_list(self, mock_get):
        mock_get.return_value = {"members": [{"key": "value"}, {"key": "value"}]}

        collection = self.resource_helper.get_collection()

        self.assertEqual(len(collection), 2)

    def test_build_uri_with_id_should_work(self):
        input = "09USE7335NW35"
        expected_output = "/rest/testuri/09USE7335NW35"
        result = self.resource_client._helper.build_uri(input)
        self.assertEqual(expected_output, result)

    def test_build_uri_with_uri_should_work(self):
        input = "/rest/testuri/09USE7335NW3"
        expected_output = "/rest/testuri/09USE7335NW3"
        result = self.resource_client._helper.build_uri(input)
        self.assertEqual(expected_output, result)

    def test_build_uri_with_none_should_raise_exception(self):
        try:
            self.resource_client._helper.build_uri(None)
        except ValueError as exception:
            self.assertEqual(RESOURCE_CLIENT_INVALID_ID, exception.args[0])
        else:
            self.fail("Expected Exception was not raised")

    def test_build_uri_with_empty_str_should_raise_exception(self):
        try:
            self.resource_client._helper.build_uri('')
        except ValueError as exception:
            self.assertEqual(RESOURCE_CLIENT_INVALID_ID, exception.args[0])
        else:
            self.fail("Expected Exception was not raised")

    def test_build_uri_with_different_resource_uri_should_raise_exception(self):
        try:
            self.resource_client._helper.build_uri(
                "/rest/test/another/resource/uri/09USE7335NW3")
        except exceptions.HPOneViewUnknownType as exception:
            self.assertEqual(UNRECOGNIZED_URI, exception.args[0])
        else:
            self.fail("Expected Exception was not raised")

    def test_build_uri_with_incomplete_uri_should_raise_exception(self):
        try:
            self.resource_client._helper.build_uri("/rest/")
        except exceptions.HPOneViewUnknownType as exception:
            self.assertEqual(UNRECOGNIZED_URI, exception.args[0])
        else:
            self.fail("Expected Exception was not raised")

    def test_build_subresource_uri(self):
        options = [
            dict(
                resource="1",
                subresource="2",
                path="sub",
                uri="/rest/testuri/1/sub/2"),
            dict(
                resource="/rest/testuri/3",
                subresource="4",
                path="sub",
                uri="/rest/testuri/3/sub/4"),
            dict(
                resource="5",
                subresource="/rest/testuri/5/sub/6",
                path="sub",
                uri="/rest/testuri/5/sub/6"),
            dict(
                resource="/rest/testuri/7",
                subresource="/rest/testuri/7/sub/8",
                path="sub",
                uri="/rest/testuri/7/sub/8"),
            dict(
                resource=None,
                subresource="/rest/testuri/9/sub/10",
                path="sub",
                uri="/rest/testuri/9/sub/10"),
            dict(
                resource="/rest/testuri/11",
                subresource="12",
                path="/sub/",
                uri="/rest/testuri/11/sub/12"),
            dict(
                resource="/rest/testuri/13",
                subresource=None,
                path="/sub/",
                uri="/rest/testuri/13/sub"),
        ]

        for option in options:
            uri = self.resource_client._helper.build_subresource_uri(option["resource"], option["subresource"], option["path"])
            self.assertEqual(uri, option["uri"])

    def test_build_subresource_uri_with_subresourceid_and_without_resource_should_fail(self):
        try:
            self.resource_client._helper.build_subresource_uri(None, "123456", "sub-path")
        except exceptions.HPOneViewValueError as exception:
            self.assertEqual(RESOURCE_ID_OR_URI_REQUIRED, exception.args[0])
        else:
            self.fail("Expected Exception was not raised")

    def test_merge_resources(self):
        resource1 = {"name": "resource1", "type": "resource"}
        resource2 = {"name": "resource2", "port": "1"}

        expected_resource = {"name": "resource2", "type": "resource", "port": "1"}

        merged_resource = merge_resources(resource1, resource2)
        self.assertEqual(merged_resource, expected_resource)

    def test_merge_default_values(self):
        default_type = {"type": "type1"}
        resource1 = {"name": "resource1"}
        resource2 = {"name": "resource2"}

        result_list = merge_default_values([resource1, resource2], default_type)

        expected_list = [
            {"name": "resource1", "type": "type1"},
            {"name": "resource2", "type": "type1"}
        ]

        self.assertEqual(result_list, expected_list)

    def test_raise_unavailable_method_exception(self):
        self.assertRaises(exceptions.HPOneViewUnavailableMethod,
                          unavailable_method)


class FakeResource(object):
    def __init__(self, con):
        self._connection = con
        self._client = ResourceClient(con, "/rest/fake/resource")

    def get_fake(self, uri):
        return self._client.get(uri)


class ResourceClientTest(unittest.TestCase):
    URI = "/rest/testuri"

    TYPE_V200 = 'typeV200'
    TYPE_V300 = 'typeV300'

    DEFAULT_VALUES = {
        '200': {'type': TYPE_V200},
        '300': {'type': TYPE_V300}
    }

    def setUp(self):
        super(ResourceClientTest, self).setUp()
        self.host = '127.0.0.1'
        self.connection = connection(self.host, 300)
        self.resource_client = ResourceClient(self.connection, self.URI)
        self.task = {"task": "task", "taskState": "Finished"}
        self.response_body = {"body": "body"}
        self.custom_headers = {'Accept-Language': 'en_US'}

    @mock.patch.object(connection, 'get')
    def test_get_all_called_once(self, mock_get):
        filter = "'name'='OneViewSDK \"Test FC Network'"
        sort = 'name:ascending'
        query = "name NE 'WrongName'"
        view = '"{view-name}"'
        scope_uris = '/rest/scopes/cd237b60-09e2-45c4-829e-082e318a6d2a'

        mock_get.return_value = {"members": [{"member": "member"}]}

        result = self.resource_client.get_all(
            1, 500, filter, query, sort, view, 'name,owner,modified', scope_uris=scope_uris)

        uri = '{resource_uri}?start=1' \
              '&count=500' \
              '&filter=%27name%27%3D%27OneViewSDK%20%22Test%20FC%20Network%27' \
              '&query=name%20NE%20%27WrongName%27' \
              '&sort=name%3Aascending' \
              '&view=%22%7Bview-name%7D%22' \
              '&fields=name%2Cowner%2Cmodified' \
              '&scopeUris=/rest/scopes/cd237b60-09e2-45c4-829e-082e318a6d2a'.format(resource_uri=self.URI)

        self.assertEqual([{'member': 'member'}], result)
        mock_get.assert_called_once_with(uri)

    @mock.patch.object(connection, 'get')
    def test_get_all_with_defaults(self, mock_get):
        self.resource_client.get_all()
        uri = "{resource_uri}?start=0&count=-1".format(resource_uri=self.URI)

        mock_get.assert_called_once_with(uri)

    @mock.patch.object(connection, 'get')
    def test_get_all_with_custom_uri(self, mock_get):
        self.resource_client.get_all(uri='/rest/testuri/12467836/subresources')
        uri = "/rest/testuri/12467836/subresources?start=0&count=-1"

        mock_get.assert_called_once_with(uri)

    @mock.patch.object(connection, 'get')
    def test_get_all_with_custom_uri_and_query_string(self, mock_get):
        self.resource_client.get_all(uri='/rest/testuri/12467836/subresources?param=value')

        uri = "/rest/testuri/12467836/subresources?param=value&start=0&count=-1"
        mock_get.assert_called_once_with(uri)

    @mock.patch.object(connection, 'get')
    def test_get_all_with_different_resource_uri_should_fail(self, mock_get):
        try:
            self.resource_client.get_all(uri='/rest/other/resource/12467836/subresources')
        except exceptions.HPOneViewUnknownType as e:
            self.assertEqual(UNRECOGNIZED_URI, e.args[0])
        else:
            self.fail('Expected Exception was not raised')

    @mock.patch.object(connection, 'get')
    def test_get_all_should_do_multi_requests_when_response_paginated(self, mock_get):
        uri_list = ['/rest/testuri?start=0&count=-1',
                    '/rest/testuri?start=3&count=3',
                    '/rest/testuri?start=6&count=3']

        results = [{'nextPageUri': uri_list[1], 'members': [{'id': '1'}, {'id': '2'}, {'id': '3'}]},
                   {'nextPageUri': uri_list[2], 'members': [{'id': '4'}, {'id': '5'}, {'id': '6'}]},
                   {'nextPageUri': None, 'members': [{'id': '7'}, {'id': '8'}]}]

        mock_get.side_effect = results

        self.resource_client.get_all()

        expected_calls = [call(uri_list[0]), call(uri_list[1]), call(uri_list[2])]
        self.assertEqual(mock_get.call_args_list, expected_calls)

    @mock.patch.object(connection, 'get')
    def test_get_all_with_count_should_do_multi_requests_when_response_paginated(self, mock_get):
        uri_list = ['/rest/testuri?start=0&count=15',
                    '/rest/testuri?start=3&count=3',
                    '/rest/testuri?start=6&count=3']

        results = [{'nextPageUri': uri_list[1], 'members': [{'id': '1'}, {'id': '2'}, {'id': '3'}]},
                   {'nextPageUri': uri_list[2], 'members': [{'id': '4'}, {'id': '5'}, {'id': '6'}]},
                   {'nextPageUri': None, 'members': [{'id': '7'}, {'id': '8'}]}]

        mock_get.side_effect = results

        self.resource_client.get_all(count=15)

        expected_calls = [call(uri_list[0]), call(uri_list[1]), call(uri_list[2])]
        self.assertEqual(mock_get.call_args_list, expected_calls)

    @mock.patch.object(connection, 'get')
    def test_get_all_should_return_all_items_when_response_paginated(self, mock_get):
        uri_list = ['/rest/testuri?start=0&count=-1',
                    '/rest/testuri?start=3&count=3',
                    '/rest/testuri?start=6&count=1']

        results = [{'nextPageUri': uri_list[1], 'members': [{'id': '1'}, {'id': '2'}, {'id': '3'}]},
                   {'nextPageUri': uri_list[2], 'members': [{'id': '4'}, {'id': '5'}, {'id': '6'}]},
                   {'nextPageUri': None, 'members': [{'id': '7'}]}]

        mock_get.side_effect = results

        result = self.resource_client.get_all()

        expected_items = [{'id': '1'}, {'id': '2'}, {'id': '3'}, {'id': '4'}, {'id': '5'}, {'id': '6'}, {'id': '7'}]
        self.assertSequenceEqual(result, expected_items)

    @mock.patch.object(connection, 'get')
    def test_get_all_should_limit_results_to_requested_count_when_response_is_paginated(self, mock_get):
        uri_list = ['/rest/testuri?start=0&count=15',
                    '/rest/testuri?start=3&count=3',
                    '/rest/testuri?start=6&count=1']

        results = [{'nextPageUri': uri_list[1], 'members': [{'id': '1'}, {'id': '2'}, {'id': '3'}]},
                   {'nextPageUri': uri_list[2], 'members': [{'id': '4'}, {'id': '5'}, {'id': '6'}]},
                   {'nextPageUri': None, 'members': [{'id': '7'}]}]

        mock_get.side_effect = results

        result = self.resource_client.get_all(count=15)

        expected_items = [{'id': '1'}, {'id': '2'}, {'id': '3'}, {'id': '4'}, {'id': '5'}, {'id': '6'}, {'id': '7'}]
        self.assertSequenceEqual(result, expected_items)

    @mock.patch.object(connection, 'get')
    def test_get_all_should_stop_requests_when_requested_count_reached(self, mock_get):
        """
        In this case, the user provides a maximum number of results to be returned but for pagination purposes, a
        nextPageUri is returned by OneView.
        """
        uri_list = ['/rest/testuri?start=0&count=3',
                    '/rest/testuri?start=3&count=3',
                    '/rest/testuri?start=6&count=3']

        results = [{'nextPageUri': uri_list[1], 'members': [{'id': '1'}, {'id': '2'}, {'id': '3'}]},
                   {'nextPageUri': uri_list[2], 'members': [{'id': '4'}, {'id': '5'}, {'id': '6'}]},
                   {'nextPageUri': None, 'members': [{'id': '7'}, {'id': '8'}]}]

        mock_get.side_effect = results

        self.resource_client.get_all(count=3)

        mock_get.assert_called_once_with(uri_list[0])

    @mock.patch.object(connection, 'get')
    def test_get_all_should_stop_requests_when_next_page_is_equal_to_current_page(self, mock_get):
        uri = '/rest/testuri?start=0&count=-1'
        members = [{'id': '1'}, {'id': '2'}, {'id': '3'}]

        mock_get.return_value = {
            'nextPageUri': uri,
            'members': members,
            'uri': uri
        }

        result = self.resource_client.get_all()

        self.assertSequenceEqual(result, members)
        mock_get.assert_called_once_with(uri)

    @mock.patch.object(connection, 'get')
    def test_get_all_should_return_empty_list_when_response_has_no_items(self, mock_get):
        mock_get.return_value = {'nextPageUri': None, 'members': []}

        result = self.resource_client.get_all()

        self.assertEqual(result, [])

    @mock.patch.object(connection, 'get')
    def test_get_all_should_return_empty_list_when_no_members(self, mock_get):
        mock_get.return_value = {'nextPageUri': None, 'members': None}

        result = self.resource_client.get_all()

        self.assertEqual(result, [])

    @mock.patch.object(connection, 'delete')
    @mock.patch.object(TaskMonitor, 'wait_for_task')
    def test_delete_all_called_once(self, mock_wait4task, mock_delete):
        mock_delete.return_value = self.task, self.response_body
        mock_wait4task.return_value = self.task

        filter = "name='Exchange Server'"
        uri = "/rest/testuri?filter=name%3D%27Exchange%20Server%27&force=True"
        self.resource_client.delete_all(filter=filter, force=True, timeout=-1)

        mock_delete.assert_called_once_with(uri)

    @mock.patch.object(connection, 'delete')
    def test_delete_all_should_return_true(self, mock_delete):
        mock_delete.return_value = None, self.response_body

        filter = "name='Exchange Server'"
        result = self.resource_client.delete_all(filter=filter, force=True, timeout=-1)

        self.assertTrue(result)

    @mock.patch.object(connection, 'delete')
    @mock.patch.object(TaskMonitor, 'wait_for_task')
    def test_delete_all_should_wait_for_task(self, mock_wait4task, mock_delete):
        mock_delete.return_value = self.task, self.response_body
        mock_wait4task.return_value = self.task

        filter = "name='Exchange Server'"
        delete_task = self.resource_client.delete_all(filter=filter, force=True, timeout=-1)

        mock_wait4task.assert_called_with(self.task, timeout=-1)
        self.assertEqual(self.task, delete_task)

    @mock.patch.object(connection, 'delete')
    @mock.patch.object(TaskMonitor, 'wait_for_task')
    def test_delete_by_id_called_once(self, mock_wait4task, mock_delete):
        mock_delete.return_value = self.task, self.response_body
        mock_wait4task.return_value = self.task

        delete_task = self.resource_client.delete('1', force=True, timeout=-1)

        self.assertEqual(self.task, delete_task)
        mock_delete.assert_called_once_with(self.URI + "/1?force=True", custom_headers=None)

    @mock.patch.object(connection, 'delete')
    @mock.patch.object(TaskMonitor, 'wait_for_task')
    def test_delete_with_custom_headers(self, mock_wait4task, mock_delete):
        mock_delete.return_value = self.task, self.response_body
        mock_wait4task.return_value = self.task

        self.resource_client.delete('1', custom_headers=self.custom_headers)

        mock_delete.assert_called_once_with(mock.ANY, custom_headers={'Accept-Language': 'en_US'})

    def test_delete_dict_invalid_uri(self):
        dict_to_delete = {"task": "task",
                          "uri": ""}
        try:
            self.resource_client.delete(dict_to_delete, False, -1)
        except exceptions.HPOneViewUnknownType as e:
            self.assertEqual("Unknown object type", e.args[0])
        else:
            self.fail()

    @mock.patch.object(connection, 'get')
    def test_get_schema_uri(self, mock_get):
        self.resource_client.get_schema()
        mock_get.assert_called_once_with(self.URI + "/schema")

    @mock.patch.object(connection, 'get')
    def test_get_by_id_uri(self, mock_get):
        self.resource_client.get('12345')
        mock_get.assert_called_once_with(self.URI + "/12345")

    @mock.patch.object(ResourceClient, 'get_by')
    def test_get_by_name_with_result(self, mock_get_by):
        mock_get_by.return_value = [{"name": "value"}]
        response = self.resource_client.get_by_name('Resource Name,')
        self.assertEqual(response, {"name": "value"})
        mock_get_by.assert_called_once_with("name", 'Resource Name,')

    @mock.patch.object(ResourceClient, 'get_by')
    def test_get_by_name_without_result(self, mock_get_by):
        mock_get_by.return_value = []
        response = self.resource_client.get_by_name('Resource Name,')
        self.assertIsNone(response)
        mock_get_by.assert_called_once_with("name", 'Resource Name,')

    @mock.patch.object(connection, 'get')
    def test_get_collection_uri(self, mock_get):
        mock_get.return_value = {"members": [{"key": "value"}, {"key": "value"}]}

        self.resource_client.get_collection('12345')

        mock_get.assert_called_once_with(self.URI + "/12345")

    @mock.patch.object(connection, 'get')
    def test_get_collection_with_filter(self, mock_get):
        mock_get.return_value = {}

        self.resource_client.get_collection('12345', 'name=name')

        mock_get.assert_called_once_with(self.URI + "/12345?filter=name%3Dname")

    @mock.patch.object(connection, 'get')
    def test_get_collection_with_multiple_filters(self, mock_get):
        mock_get.return_value = {}

        self.resource_client.get_collection('12345', ['name1=one', 'name2=two', 'name=three'])

        mock_get.assert_called_once_with(self.URI + "/12345?filter=name1%3Done&filter=name2%3Dtwo&filter=name%3Dthree")

    @mock.patch.object(connection, 'get')
    def test_get_collection_should_return_list(self, mock_get):
        mock_get.return_value = {"members": [{"key": "value"}, {"key": "value"}]}

        collection = self.resource_client.get_collection('12345')

        self.assertEqual(len(collection), 2)

    @mock.patch.object(ResourceClient, 'get_all')
    def test_get_by_property(self, mock_get_all):
        self.resource_client.get_by('name', 'MyFibreNetwork')
        mock_get_all.assert_called_once_with(filter="\"name='MyFibreNetwork'\"", uri='/rest/testuri')

    @mock.patch.object(ResourceClient, 'get_all')
    def test_get_by_with_incorrect_result_autofix(self, mock_get_all):

        mock_get_all.return_value = [{"name": "EXpected"},
                                     {"name": "not expected"}]

        response = self.resource_client.get_by('name', 'exPEcted')
        self.assertEqual(response, [{"name": "EXpected"}])
        mock_get_all.assert_called_once_with(filter="\"name='exPEcted'\"", uri='/rest/testuri')

    @mock.patch.object(ResourceClient, 'get_all')
    def test_get_by_with_incorrect_result_skip_autofix(self, mock_get_all):

        mock_get_all.return_value = [{"name": "expected"},
                                     {"name": "not expected"}]

        response = self.resource_client.get_by('connection.name', 'expected')
        self.assertEqual(response, [{'name': 'expected'}, {'name': 'not expected'}])
        mock_get_all.assert_called_once_with(filter="\"connection.name='expected'\"", uri='/rest/testuri')

    @mock.patch.object(ResourceClient, 'get_all')
    def test_get_by_property_with_uri(self, mock_get_all):
        self.resource_client.get_by('name', 'MyFibreNetwork', uri='/rest/testuri/5435534/sub')
        mock_get_all.assert_called_once_with(filter="\"name='MyFibreNetwork'\"", uri='/rest/testuri/5435534/sub')

    @mock.patch.object(ResourceClient, 'get_all')
    def test_get_by_property_with__invalid_uri(self, mock_get_all):
        try:
            self.resource_client.get_by('name', 'MyFibreNetwork', uri='/rest/other/5435534/sub')
        except exceptions.HPOneViewUnknownType as e:
            self.assertEqual('Unrecognized URI for this resource', e.args[0])
        else:
            self.fail()

    @mock.patch.object(connection, 'put')
    @mock.patch.object(TaskMonitor, 'wait_for_task')
    def test_update_with_zero_body_called_once(self, mock_wait4task, mock_update):
        mock_update.return_value = self.task, self.task
        mock_wait4task.return_value = self.task
        self.resource_client.update_with_zero_body('/rest/enclosures/09USE133E5H4/configuration',
                                                   timeout=-1)

        mock_update.assert_called_once_with(
            "/rest/enclosures/09USE133E5H4/configuration", None, custom_headers=None)

    @mock.patch.object(connection, 'put')
    @mock.patch.object(TaskMonitor, 'wait_for_task')
    def test_update_with_zero_body_and_custom_headers(self, mock_wait4task, mock_update):
        mock_update.return_value = self.task, self.task
        mock_wait4task.return_value = self.task
        self.resource_client.update_with_zero_body('1', custom_headers=self.custom_headers)

        mock_update.assert_called_once_with(mock.ANY, mock.ANY, custom_headers={'Accept-Language': 'en_US'})

    @mock.patch.object(connection, 'put')
    @mock.patch.object(TaskMonitor, 'wait_for_task')
    def test_update_with_zero_body_return_entity(self, mock_wait4task, mock_put):
        response_body = {"resource_name": "name"}

        mock_put.return_value = self.task, self.task
        mock_wait4task.return_value = response_body

        result = self.resource_client.update_with_zero_body(
            '/rest/enclosures/09USE133E5H4/configuration', timeout=-1)

        self.assertEqual(result, response_body)

    @mock.patch.object(connection, 'put')
    def test_update_with_zero_body_without_task(self, mock_put):
        mock_put.return_value = None, self.response_body

        result = self.resource_client.update_with_zero_body(
            '/rest/enclosures/09USE133E5H4/configuration', timeout=-1)

        self.assertEqual(result, self.response_body)

    @mock.patch.object(connection, 'put')
    def test_update_with_uri_called_once(self, mock_put):
        dict_to_update = {"name": "test"}
        uri = "/rest/resource/test"

        mock_put.return_value = None, self.response_body
        response = self.resource_client.update(dict_to_update, uri=uri)

        self.assertEqual(self.response_body, response)
        mock_put.assert_called_once_with(uri, dict_to_update, custom_headers=None)

    @mock.patch.object(connection, 'put')
    def test_update_with_custom_headers(self, mock_put):
        dict_to_update = {"name": "test"}
        mock_put.return_value = None, self.response_body

        self.resource_client.update(dict_to_update, uri="/path", custom_headers=self.custom_headers)

        mock_put.assert_called_once_with(mock.ANY, mock.ANY, custom_headers={'Accept-Language': 'en_US'})

    @mock.patch.object(connection, 'put')
    def test_update_with_force(self, mock_put):
        dict_to_update = {"name": "test"}
        uri = "/rest/resource/test"
        mock_put.return_value = None, self.response_body

        self.resource_client.update(dict_to_update, uri=uri, force=True)

        expected_uri = "/rest/resource/test?force=True"
        mock_put.assert_called_once_with(expected_uri, dict_to_update, custom_headers=None)

    @mock.patch.object(connection, 'put')
    def test_update_with_api_version_200(self, mock_put):
        dict_to_update = {"name": "test"}
        uri = "/rest/resource/test"

        mock_put.return_value = None, self.response_body
        self.connection._apiVersion = 200

        expected_dict = {"name": "test", "type": self.TYPE_V200}

        self.resource_client.update(dict_to_update, uri=uri, default_values=self.DEFAULT_VALUES)
        mock_put.assert_called_once_with(uri, expected_dict, custom_headers=None)

    @mock.patch.object(connection, 'put')
    def test_update_with_default_api_version_300(self, mock_put):
        dict_to_update = {"name": "test"}
        uri = "/rest/resource/test"

        mock_put.return_value = None, self.response_body

        expected_dict = {"name": "test", "type": self.TYPE_V300}

        self.resource_client.update(dict_to_update, uri=uri, default_values=self.DEFAULT_VALUES)
        mock_put.assert_called_once_with(uri, expected_dict, custom_headers=None)

    @mock.patch.object(connection, 'put')
    def test_update_should_not_override_resource_properties(self, mock_put):
        dict_to_update = {"name": "test", "type": "anotherType"}
        uri = "/rest/resource/test"

        mock_put.return_value = None, self.response_body

        self.resource_client.update(dict_to_update, uri=uri, default_values=self.DEFAULT_VALUES)
        mock_put.assert_called_once_with(uri, dict_to_update, custom_headers=None)

    @mock.patch.object(connection, 'put')
    def test_update_without_default_values(self, mock_put):
        dict_to_update = {"name": "test"}
        uri = "/rest/resource/test"

        mock_put.return_value = None, self.response_body

        resource_client = ResourceClient(self.connection, self.URI)
        resource_client.update(dict_to_update, uri=uri)

        mock_put.assert_called_once_with(uri, dict_to_update, custom_headers=None)

    @mock.patch.object(connection, 'put')
    @mock.patch.object(TaskMonitor, 'wait_for_task')
    def test_update_uri(self, mock_wait4task, mock_update):
        dict_to_update = {"resource_data": "resource_data",
                          "uri": "a_uri"}

        mock_update.return_value = self.task, self.response_body
        mock_wait4task.return_value = self.task
        update_task = self.resource_client.update(dict_to_update, False)

        self.assertEqual(self.task, update_task)
        mock_update.assert_called_once_with("a_uri", dict_to_update, custom_headers=None)

    @mock.patch.object(connection, 'put')
    @mock.patch.object(TaskMonitor, 'wait_for_task')
    def test_update_return_entity(self, mock_wait4task, mock_put):
        dict_to_update = {
            "resource_name": "a name",
            "uri": "a_uri",
        }
        mock_put.return_value = self.task, {}
        mock_wait4task.return_value = dict_to_update

        result = self.resource_client.update(dict_to_update, timeout=-1)

        self.assertEqual(result, dict_to_update)

    @mock.patch.object(connection, 'post')
    @mock.patch.object(TaskMonitor, 'wait_for_task')
    def test_create_with_zero_body_called_once(self, mock_wait4task, mock_post):
        mock_post.return_value = self.task, self.task
        mock_wait4task.return_value = self.task
        self.resource_client.create_with_zero_body('/rest/enclosures/09USE133E5H4/configuration',
                                                   timeout=-1)

        mock_post.assert_called_once_with(
            "/rest/enclosures/09USE133E5H4/configuration", {}, custom_headers=None)

    @mock.patch.object(connection, 'post')
    @mock.patch.object(TaskMonitor, 'wait_for_task')
    def test_create_with_zero_body_called_once_without_uri(self, mock_wait4task, mock_post):
        mock_post.return_value = self.task, self.task
        mock_wait4task.return_value = self.task
        self.resource_client.create_with_zero_body(timeout=-1)

        mock_post.assert_called_once_with(
            '/rest/testuri', {}, custom_headers=None)

    @mock.patch.object(connection, 'post')
    @mock.patch.object(TaskMonitor, 'wait_for_task')
    def test_create_with_zero_body_and_custom_headers(self, mock_wait4task, mock_post):
        mock_post.return_value = self.task, self.task
        mock_wait4task.return_value = self.task
        self.resource_client.create_with_zero_body('1', custom_headers=self.custom_headers)

        mock_post.assert_called_once_with(mock.ANY, mock.ANY, custom_headers={'Accept-Language': 'en_US'})

    @mock.patch.object(connection, 'post')
    @mock.patch.object(TaskMonitor, 'wait_for_task')
    def test_create_with_zero_body_return_entity(self, mock_wait4task, mock_post):
        response_body = {"resource_name": "name"}

        mock_post.return_value = self.task, self.task
        mock_wait4task.return_value = response_body

        result = self.resource_client.create_with_zero_body(
            '/rest/enclosures/09USE133E5H4/configuration', timeout=-1)

        self.assertEqual(result, response_body)

    @mock.patch.object(connection, 'post')
    def test_create_with_zero_body_without_task(self, mock_post):
        mock_post.return_value = None, self.response_body

        result = self.resource_client.create_with_zero_body(
            '/rest/enclosures/09USE133E5H4/configuration', timeout=-1)

        self.assertEqual(result, self.response_body)

    @mock.patch.object(connection, 'post')
    def test_create_uri(self, mock_post):
        dict_to_create = {"resource_name": "a name"}
        mock_post.return_value = {}, {}

        self.resource_client.create(dict_to_create, timeout=-1)
        mock_post.assert_called_once_with(self.URI, dict_to_create, custom_headers=None)

    @mock.patch.object(connection, 'post')
    def test_create_uri_with_force(self, mock_post):
        dict_to_create = {"resource_name": "a name", "force": "yes"}
        mock_post.return_value = {}, {}

        self.resource_client.create(dict_to_create, timeout=-1)
        expected_uri = "/rest/testuri"
        mock_post.assert_called_once_with(expected_uri, dict_to_create, custom_headers=None)

    @mock.patch.object(connection, 'post')
    def test_create_with_api_version_200(self, mock_post):
        dict_to_create = {"resource_name": "a name"}
        mock_post.return_value = {}, {}

        self.connection._apiVersion = 200
        expected_dict = {"resource_name": "a name", "type": self.TYPE_V200}

        self.resource_client.create(dict_to_create, timeout=-1, default_values=self.DEFAULT_VALUES)
        mock_post.assert_called_once_with(self.URI, expected_dict, custom_headers=None)

    @mock.patch.object(connection, 'post')
    def test_create_with_default_api_version_300(self, mock_post):
        dict_to_create = {"resource_name": "a name"}
        mock_post.return_value = {}, {}

        expected_dict = {"resource_name": "a name", "type": self.TYPE_V300}

        self.resource_client.create(dict_to_create, timeout=-1, default_values=self.DEFAULT_VALUES)
        mock_post.assert_called_once_with(self.URI, expected_dict, custom_headers=None)

    @mock.patch.object(connection, 'post')
    def test_create_should_not_override_resource_properties(self, mock_post):
        dict_to_create = {"resource_name": "a name", "type": "anotherType"}
        mock_post.return_value = {}, {}

        self.resource_client.create(dict_to_create, default_values=self.DEFAULT_VALUES)

        mock_post.assert_called_once_with(self.URI, dict_to_create, custom_headers=None)

    @mock.patch.object(connection, 'post')
    def test_create_without_default_values(self, mock_post):
        dict_to_create = {"resource_name": "a name"}
        mock_post.return_value = {}, {}

        resource_client = ResourceClient(self.connection, self.URI)
        resource_client.create(dict_to_create, timeout=-1)

        mock_post.assert_called_once_with(self.URI, dict_to_create, custom_headers=None)

    @mock.patch.object(connection, 'post')
    def test_create_with_custom_headers(self, mock_post):
        dict_to_create = {"resource_name": "a name"}
        mock_post.return_value = {}, {}

        self.resource_client.create(dict_to_create, custom_headers=self.custom_headers)

        mock_post.assert_called_once_with(mock.ANY, mock.ANY, custom_headers={'Accept-Language': 'en_US'})

    @mock.patch.object(connection, 'post')
    @mock.patch.object(TaskMonitor, 'wait_for_task')
    def test_create_return_entity(self, mock_wait4task, mock_post):
        dict_to_create = {
            "resource_name": "a name",
        }
        created_resource = {
            "resource_id": "123",
            "resource_name": "a name",
        }

        mock_post.return_value = self.task, {}
        mock_wait4task.return_value = created_resource

        result = self.resource_client.create(dict_to_create, -1)

        self.assertEqual(result, created_resource)

    @mock.patch.object(connection, 'post')
    @mock.patch.object(TaskMonitor, 'wait_for_task')
    def test_wait_for_activity_on_create(self, mock_wait4task, mock_post):
        mock_post.return_value = self.task, {}
        mock_wait4task.return_value = self.task

        self.resource_client.create({"test": "test"}, timeout=60)

        mock_wait4task.assert_called_once_with(self.task, 60)

    @mock.patch.object(connection, 'patch')
    def test_patch_request_when_id_is_provided_v200(self, mock_patch):
        request_body = [{
            'op': 'replace',
            'path': '/name',
            'value': 'new_name',
        }]
        mock_patch.return_value = {}, {}

        self.connection._apiVersion = 200

        self.resource_client.patch(
            '123a53cz', 'replace', '/name', 'new_name', 70)

        mock_patch.assert_called_once_with(
            '/rest/testuri/123a53cz', request_body, custom_headers={})

    @mock.patch.object(connection, 'patch')
    def test_patch_request_when_id_is_provided_v300(self, mock_patch):
        request_body = [{
            'op': 'replace',
            'path': '/name',
            'value': 'new_name',
        }]
        mock_patch.return_value = {}, {}

        resource_client = ResourceClient(self.connection, self.URI)
        resource_client.patch(
            '123a53cz', 'replace', '/name', 'new_name', 70)

        mock_patch.assert_called_once_with(
            '/rest/testuri/123a53cz', request_body, custom_headers={'Content-Type': 'application/json-patch+json'})

    @mock.patch.object(connection, 'patch')
    def test_patch_request_when_uri_is_provided(self, mock_patch):
        request_body = [{
            'op': 'replace',
            'path': '/name',
            'value': 'new_name',
        }]
        mock_patch.return_value = {}, {}

        self.resource_client.patch(
            '/rest/testuri/123a53cz', 'replace', '/name', 'new_name', 60)

        mock_patch.assert_called_once_with(
            '/rest/testuri/123a53cz', request_body, custom_headers={'Content-Type': 'application/json-patch+json'})

    @mock.patch.object(connection, 'patch')
    def test_patch_with_custom_headers_v200(self, mock_patch):
        mock_patch.return_value = {}, {}

        self.connection._apiVersion = 200

        self.resource_client.patch('/rest/testuri/123', 'operation', '/field', 'value',
                                   custom_headers=self.custom_headers)

        mock_patch.assert_called_once_with(mock.ANY, mock.ANY, custom_headers={'Accept-Language': 'en_US'})

    @mock.patch.object(connection, 'patch')
    def test_patch_with_custom_headers_v300(self, mock_patch):
        mock_patch.return_value = {}, {}

        resource_client = ResourceClient(self.connection, self.URI)
        resource_client.patch('/rest/testuri/123', 'operation', '/field', 'value',
                              custom_headers=self.custom_headers)

        mock_patch.assert_called_once_with(mock.ANY,
                                           mock.ANY,
                                           custom_headers={'Accept-Language': 'en_US',
                                                           'Content-Type': 'application/json-patch+json'})

    @mock.patch.object(connection, 'patch')
    @mock.patch.object(TaskMonitor, 'wait_for_task')
    def test_patch_return_entity(self, mock_wait4task, mock_patch):
        entity = {"resource_id": "123a53cz"}
        mock_patch.return_value = self.task, self.task
        mock_wait4task.return_value = entity

        result = self.resource_client.patch(
            '123a53cz', 'replace', '/name', 'new_name', -1)

        self.assertEqual(result, entity)

    @mock.patch.object(connection, 'patch')
    @mock.patch.object(TaskMonitor, 'get_completed_task')
    def test_patch_request_custom_headers_with_content_type(self, mock_task, mock_patch):

        dict_info = {"resource_name": "a name"}

        mock_patch.return_value = {}, {}

        headers = {'Content-Type': 'application/json',
                   'Extra': 'extra'}
        self.connection._apiVersion = 300

        resource_client = ResourceClient(self.connection, self.URI)
        resource_client.patch_request('/rest/testuri/id', body=dict_info, custom_headers=headers)

        mock_patch.assert_called_once_with('/rest/testuri/id', dict_info, custom_headers=headers)

    @mock.patch.object(connection, 'patch')
    @mock.patch.object(TaskMonitor, 'get_completed_task')
    def test_patch_request_custom_headers(self, mock_task, mock_patch):

        dict_info = {"resource_name": "a name"}

        mock_patch.return_value = {}, {}
        headers = {'Extra': 'extra'}
        self.connection._apiVersion = 300

        resource_client = ResourceClient(self.connection, self.URI)
        resource_client.patch_request('/rest/testuri/id', body=dict_info, custom_headers=headers)

        mock_patch.assert_called_once_with(
            '/rest/testuri/id',
            dict_info,
            custom_headers={'Extra': 'extra',
                            'Content-Type': 'application/json-patch+json'})

    @mock.patch.object(connection, 'patch')
    @mock.patch.object(TaskMonitor, 'wait_for_task')
    def test_wait_for_activity_on_patch(self, mock_wait4task, mock_patch):
        entity = {"resource_id": "123a53cz"}
        mock_patch.return_value = self.task, self.task
        mock_wait4task.return_value = entity

        self.resource_client.patch(
            '123a53cz', 'replace', '/name', 'new_name', -1)

        mock_wait4task.assert_called_once_with(self.task, mock.ANY)

    def test_delete_with_none(self):
        try:
            self.resource_client.delete(None)
        except ValueError as e:
            self.assertTrue("Resource" in e.args[0])
        else:
            self.fail()

    @mock.patch.object(connection, 'delete')
    def test_delete_with_dict_uri(self, mock_delete):

        resource = {"uri": "uri"}

        mock_delete.return_value = {}, {}
        delete_result = self.resource_client.delete(resource)

        self.assertTrue(delete_result)
        mock_delete.assert_called_once_with("uri", custom_headers=None)

    def test_delete_with_empty_dict(self):
        try:
            self.resource_client.delete({})
        except ValueError as e:
            self.assertTrue("Resource" in e.args[0])
        else:
            self.fail()

    def test_get_with_none(self):
        try:
            self.resource_client.get(None)
        except ValueError as e:
            self.assertTrue("id" in e.args[0])
        else:
            self.fail()

    def test_get_collection_with_none(self):
        try:
            self.resource_client.get_collection(None)
        except ValueError as e:
            self.assertTrue("id" in e.args[0])
        else:
            self.fail()

    def test_create_with_none(self):
        try:
            self.resource_client.create(None)
        except ValueError as e:
            self.assertTrue("Resource" in e.args[0])
        else:
            self.fail()

    def test_create_with_empty_dict(self):
        try:
            self.resource_client.create({})
        except ValueError as e:
            self.assertTrue("Resource" in e.args[0])
        else:
            self.fail()

    def test_update_with_none(self):
        try:
            self.resource_client.update(None)
        except ValueError as e:
            self.assertTrue("Resource" in e.args[0])
        else:
            self.fail()

    def test_update_with_empty_dict(self):
        try:
            self.resource_client.update({})
        except ValueError as e:
            self.assertTrue("Resource" in e.args[0])
        else:
            self.fail()

    def test_get_by_with_name_none(self):
        try:
            self.resource_client.get_by(None, None)
        except ValueError as e:
            self.assertTrue("field" in e.args[0])
        else:
            self.fail()

    @mock.patch.object(connection, 'get')
    def test_get_with_uri_should_work(self, mock_get):
        mock_get.return_value = {}
        uri = self.URI + "/ad28cf21-8b15-4f92-bdcf-51cb2042db32"
        self.resource_client.get(uri)

        mock_get.assert_called_once_with(uri)

    def test_get_with_uri_with_incompatible_url_shoud_fail(self):
        message = "Unrecognized URI for this resource"
        uri = "/rest/interconnects/ad28cf21-8b15-4f92-bdcf-51cb2042db32"
        try:
            self.resource_client.get(uri)
        except exceptions.HPOneViewUnknownType as exception:
            self.assertEqual(message, exception.args[0])
        else:
            self.fail("Expected Exception was not raised")

    def test_get_with_uri_from_another_resource_with_incompatible_url_shoud_fail(self):
        message = "Unrecognized URI for this resource"
        uri = "/rest/interconnects/ad28cf21-8b15-4f92-bdcf-51cb2042db32"
        fake_resource = FakeResource(None)
        try:
            fake_resource.get_fake(uri)
        except exceptions.HPOneViewUnknownType as exception:
            self.assertEqual(message, exception.args[0])
        else:
            self.fail("Expected Exception was not raised")

    @mock.patch.object(connection, 'get')
    def test_get_utilization_with_args(self, mock_get):
        self.resource_client.get_utilization('09USE7335NW3', fields='AmbientTemperature,AveragePower,PeakPower',
                                             filter='startDate=2016-05-30T03:29:42.361Z',
                                             refresh=True, view='day')

        expected_uri = '/rest/testuri/09USE7335NW3/utilization' \
                       '?filter=startDate%3D2016-05-30T03%3A29%3A42.361Z' \
                       '&fields=AmbientTemperature%2CAveragePower%2CPeakPower' \
                       '&refresh=true' \
                       '&view=day'

        mock_get.assert_called_once_with(expected_uri)

    @mock.patch.object(connection, 'get')
    def test_get_utilization_with_multiple_filters(self, mock_get):
        self.resource_client.get_utilization(
            '09USE7335NW3',
            fields='AmbientTemperature,AveragePower,PeakPower',
            filter=['startDate=2016-05-30T03:29:42.361Z',
                    'endDate=2016-05-31T03:29:42.361Z'],
            refresh=True,
            view='day')

        expected_uri = '/rest/testuri/09USE7335NW3/utilization' \
                       '?filter=startDate%3D2016-05-30T03%3A29%3A42.361Z' \
                       '&filter=endDate%3D2016-05-31T03%3A29%3A42.361Z' \
                       '&fields=AmbientTemperature%2CAveragePower%2CPeakPower' \
                       '&refresh=true' \
                       '&view=day'

        mock_get.assert_called_once_with(expected_uri)

    @mock.patch.object(connection, 'get')
    def test_get_utilization_by_id_with_defaults(self, mock_get):
        self.resource_client.get_utilization('09USE7335NW3')

        expected_uri = '/rest/testuri/09USE7335NW3/utilization'

        mock_get.assert_called_once_with(expected_uri)

    @mock.patch.object(connection, 'get')
    def test_get_utilization_by_uri_with_defaults(self, mock_get):
        self.resource_client.get_utilization('/rest/testuri/09USE7335NW3')

        expected_uri = '/rest/testuri/09USE7335NW3/utilization'

        mock_get.assert_called_once_with(expected_uri)

    def test_get_utilization_with_empty(self):

        try:
            self.resource_client.get_utilization('')
        except ValueError as exception:
            self.assertEqual(RESOURCE_CLIENT_INVALID_ID, exception.args[0])
        else:
            self.fail("Expected Exception was not raised")

    def test_build_uri_with_id_should_work(self):
        input = '09USE7335NW35'
        expected_output = '/rest/testuri/09USE7335NW35'
        result = self.resource_client.build_uri(input)
        self.assertEqual(expected_output, result)

    def test_build_uri_with_uri_should_work(self):
        input = '/rest/testuri/09USE7335NW3'
        expected_output = '/rest/testuri/09USE7335NW3'
        result = self.resource_client.build_uri(input)
        self.assertEqual(expected_output, result)

    def test_build_uri_with_none_should_raise_exception(self):
        try:
            self.resource_client.build_uri(None)
        except ValueError as exception:
            self.assertEqual(RESOURCE_CLIENT_INVALID_ID, exception.args[0])
        else:
            self.fail("Expected Exception was not raised")

    def test_build_uri_with_empty_str_should_raise_exception(self):
        try:
            self.resource_client.build_uri('')
        except ValueError as exception:
            self.assertEqual(RESOURCE_CLIENT_INVALID_ID, exception.args[0])
        else:
            self.fail("Expected Exception was not raised")

    def test_build_uri_with_different_resource_uri_should_raise_exception(self):
        try:
            self.resource_client.build_uri(
                '/rest/test/another/resource/uri/09USE7335NW3')
        except exceptions.HPOneViewUnknownType as exception:
            self.assertEqual(UNRECOGNIZED_URI, exception.args[0])
        else:
            self.fail("Expected Exception was not raised")

    def test_build_uri_with_incomplete_uri_should_raise_exception(self):
        try:
            self.resource_client.build_uri('/rest/')
        except exceptions.HPOneViewUnknownType as exception:
            self.assertEqual(UNRECOGNIZED_URI, exception.args[0])
        else:
            self.fail("Expected Exception was not raised")

    def test_build_subresource_uri(self):
        options = [
            dict(
                resource='1',
                subresource='2',
                path='sub',
                uri='/rest/testuri/1/sub/2'),
            dict(
                resource='/rest/testuri/3',
                subresource='4',
                path='sub',
                uri='/rest/testuri/3/sub/4'),
            dict(
                resource='5',
                subresource='/rest/testuri/5/sub/6',
                path='sub',
                uri='/rest/testuri/5/sub/6'),
            dict(
                resource='/rest/testuri/7',
                subresource='/rest/testuri/7/sub/8',
                path='sub',
                uri='/rest/testuri/7/sub/8'),
            dict(
                resource=None,
                subresource='/rest/testuri/9/sub/10',
                path='sub',
                uri='/rest/testuri/9/sub/10'),
            dict(
                resource='/rest/testuri/11',
                subresource='12',
                path='/sub/',
                uri='/rest/testuri/11/sub/12'),
            dict(
                resource='/rest/testuri/13',
                subresource=None,
                path='/sub/',
                uri='/rest/testuri/13/sub'),
        ]

        for option in options:
            uri = self.resource_client.build_subresource_uri(option['resource'], option['subresource'], option['path'])
            self.assertEqual(uri, option['uri'])

    def test_build_subresource_uri_with_subresourceid_and_without_resource_should_fail(self):
        try:
            self.resource_client.build_subresource_uri(None, "123456", 'sub-path')
        except exceptions.HPOneViewValueError as exception:
            self.assertEqual(RESOURCE_ID_OR_URI_REQUIRED, exception.args[0])
        else:
            self.fail("Expected Exception was not raised")

    @mock.patch.object(connection, 'post')
    @mock.patch.object(TaskMonitor, 'get_completed_task')
    def test_create_report_should_do_post_request(self, mock_get_completed_task, mock_post):
        task_with_output = self.task.copy()
        task_with_output['taskOutput'] = []

        mock_post.return_value = self.task, {}
        mock_get_completed_task.return_value = task_with_output

        self.resource_client.create_report("/rest/path/create-report")

        mock_post.assert_called_once_with("/rest/path/create-report", {})

    @mock.patch.object(connection, 'post')
    @mock.patch.object(TaskMonitor, 'get_completed_task')
    def test_create_report_should_wait_task_completion(self, mock_get_completed_task, mock_post):
        task_with_output = self.task.copy()
        task_with_output['taskOutput'] = []

        mock_post.return_value = self.task, {}
        mock_get_completed_task.return_value = task_with_output

        self.resource_client.create_report("/rest/path/create-report", timeout=60)

        mock_get_completed_task.assert_called_once_with(self.task, 60)

    @mock.patch.object(connection, 'post')
    @mock.patch.object(TaskMonitor, 'get_completed_task')
    def test_create_report_should_return_output_list_when_results(self, mock_get_completed_task, mock_post):
        task_output = [
            {"type": "FCIssueResponseV2", "created": "2015-03-24T15: 32: 50.889Z"},
            {"type": "FCIssueResponseV2", "created": "2015-03-13T14: 10: 50.322Z"}
        ]
        task_with_output = self.task.copy()
        task_with_output['taskOutput'] = task_output

        mock_post.return_value = self.task, {}
        mock_get_completed_task.return_value = task_with_output

        result = self.resource_client.create_report("/rest/path/create-report")

        self.assertEqual(result, task_output)

    @mock.patch.object(connection, 'post')
    @mock.patch.object(TaskMonitor, 'get_completed_task')
    def test_create_report_should_return_empty_list_when_output_is_empty(self, mock_get_completed_task, mock_post):
        task_with_output = self.task.copy()
        task_with_output['taskOutput'] = []

        mock_post.return_value = self.task, {}
        mock_get_completed_task.return_value = task_with_output

        result = self.resource_client.create_report("/rest/path/create-report")

        self.assertEqual(result, [])

    @mock.patch.object(connection, 'post')
    def test_create_report_should_raise_exception_when_not_task(self, mock_post):
        task_with_output = self.task.copy()
        task_with_output['taskOutput'] = []

        mock_post.return_value = None, {}

        try:
            self.resource_client.create_report("/rest/path/create-report")
        except exceptions.HPOneViewException as exception:
            self.assertEqual(RESOURCE_CLIENT_TASK_EXPECTED, exception.args[0])
        else:
            self.fail("Expected Exception was not raised")

    @mock.patch.object(connection, 'post')
    def test_create_when_the_resource_is_a_list(self, mock_post):
        dict_to_create = [{"resource_name": "a name"}]
        mock_post.return_value = {}, {}

        resource_client = ResourceClient(self.connection, self.URI)
        resource_client.create(dict_to_create, timeout=-1)

        mock_post.assert_called_once_with(self.URI, dict_to_create, custom_headers=None)

    def test_merge_api_default_values(self):
        resource = {'name': 'resource1'}
        default_values = {
            '200': {"type": "EnclosureGroupV200"},
            '300': {"type": "EnclosureGroupV300"}
        }

        expected = {'name': 'resource1', "type": "EnclosureGroupV300"}

        resource_client = ResourceClient(self.connection, self.URI)
        result = resource_client.merge_default_values(resource, default_values)

        self.assertEqual(result, expected)

    def test_should_not_merge_when_default_values_not_defined(self):
        resource = {'name': 'resource1'}
        default_values = {}

        expected = {'name': 'resource1'}

        resource_client = ResourceClient(self.connection, self.URI)
        result = resource_client.merge_default_values(resource, default_values)

        self.assertEqual(result, expected)

    @mock.patch.object(connection, 'post_multipart_with_response_handling')
    def test_upload_should_call_post_multipart(self, mock_post_multipart):
        uri = '/rest/testuri/'
        filepath = "test/SPPgen9snap6.2015_0405.81.iso"
        mock_post_multipart.return_value = None, mock.Mock()

        self.resource_client.upload(filepath, uri)

        mock_post_multipart.assert_called_once_with(uri, filepath, 'SPPgen9snap6.2015_0405.81.iso')

    @mock.patch.object(connection, 'post_multipart_with_response_handling')
    def test_upload_should_call_post_multipart_with_resource_uri_when_not_uri_provided(self, mock_post_multipart):
        filepath = "test/SPPgen9snap6.2015_0405.81.iso"
        mock_post_multipart.return_value = None, mock.Mock()

        self.resource_client.upload(filepath)

        mock_post_multipart.assert_called_once_with('/rest/testuri', mock.ANY, mock.ANY)

    @mock.patch.object(connection, 'post_multipart_with_response_handling')
    @mock.patch.object(TaskMonitor, 'wait_for_task')
    @mock.patch.object(connection, 'get')
    def test_upload_should_wait_for_task_when_response_is_task(self, mock_get, mock_wait4task, mock_post_multipart):
        uri = '/rest/testuri/'
        filepath = "test/SPPgen9snap6.2015_0405.81.iso"
        mock_post_multipart.return_value = self.task, mock.Mock()

        self.resource_client.upload(filepath, uri)

        mock_wait4task.assert_called_once_with(self.task, -1)

    @mock.patch.object(connection, 'post_multipart_with_response_handling')
    @mock.patch.object(TaskMonitor, 'wait_for_task')
    def test_upload_should_not_wait_for_task_when_response_is_not_task(self, mock_wait4task, mock_post_multipart):
        uri = '/rest/testuri/'
        filepath = "test/SPPgen9snap6.2015_0405.81.iso"
        mock_post_multipart.return_value = None, mock.Mock()

        self.resource_client.upload(filepath, uri)

        mock_wait4task.not_been_called()

    @mock.patch.object(connection, 'post_multipart_with_response_handling')
    @mock.patch.object(TaskMonitor, 'wait_for_task')
    @mock.patch.object(connection, 'get')
    def test_upload_should_return_associated_resource_when_response_is_task(self, mock_get, mock_wait4task,
                                                                            mock_post_multipart):
        fake_associated_resurce = mock.Mock()
        uri = '/rest/testuri/'
        filepath = "test/SPPgen9snap6.2015_0405.81.iso"
        mock_post_multipart.return_value = self.task, mock.Mock()
        mock_wait4task.return_value = fake_associated_resurce

        result = self.resource_client.upload(filepath, uri)

        self.assertEqual(result, fake_associated_resurce)

    @mock.patch.object(connection, 'post_multipart_with_response_handling')
    @mock.patch.object(TaskMonitor, 'wait_for_task')
    def test_upload_should_return_resource_when_response_is_not_task(self, mock_wait4task, mock_post_multipart):
        fake_response_body = mock.Mock()
        uri = '/rest/testuri/'
        filepath = "test/SPPgen9snap6.2015_0405.81.iso"
        mock_post_multipart.return_value = None, fake_response_body

        result = self.resource_client.upload(filepath, uri)

        self.assertEqual(result, fake_response_body)

    @mock.patch.object(connection, 'download_to_stream')
    @mock.patch(mock_builtin('open'))
    def test_download_should_call_download_to_stream_with_given_uri(self, mock_open, mock_download_to_stream):
        file_path = "~/archive.log"
        uri = '/rest/testuri/3ec91dd2-0ebb-4484-8b2d-90d065114315'
        mock_open.return_value = io.StringIO()

        self.resource_client.download(uri, file_path)

        mock_download_to_stream.assert_called_once_with(mock.ANY, uri, custom_headers=mock.ANY)

    @mock.patch.object(connection, 'download_to_stream')
    @mock.patch(mock_builtin('open'))
    def test_download_should_call_download_to_stream_with_open_file(self, mock_open, mock_download_to_stream):
        file_path = "~/archive.log"
        uri = '/rest/testuri/3ec91dd2-0ebb-4484-8b2d-90d065114315'
        fake_file = io.StringIO()
        mock_open.return_value = fake_file

        self.resource_client.download(uri, file_path)

        mock_open.assert_called_once_with(file_path, 'wb')
        mock_download_to_stream.assert_called_once_with(fake_file, uri, custom_headers=mock.ANY)

    @mock.patch.object(connection, 'download_to_stream')
    @mock.patch(mock_builtin('open'))
    def test_download_should_return_true_when_success(self, mock_open, mock_download_to_stream):
        file_path = "~/archive.log"
        uri = '/rest/testuri/3ec91dd2-0ebb-4484-8b2d-90d065114315'
        mock_download_to_stream.return_value = True
        mock_open.return_value = io.StringIO()

        result = self.resource_client.download(uri, file_path)

        self.assertTrue(result)

    @mock.patch.object(connection, 'download_to_stream')
    @mock.patch(mock_builtin('open'))
    def test_download_should_return_false_when_error(self, mock_open, mock_download_to_stream):
        file_path = "~/archive.log"
        uri = '/rest/testuri/3ec91dd2-0ebb-4484-8b2d-90d065114315'
        mock_download_to_stream.return_value = False
        mock_open.return_value = io.StringIO()

        result = self.resource_client.download(uri, file_path)

        self.assertFalse(result)

    def test_transform_list_to_dict(self):
        list = ['one', 'two', {'tree': 3}, 'four', 5]

        dict_transformed = transform_list_to_dict(list=list)

        self.assertEqual(dict_transformed,
                         {'5': True,
                          'four': True,
                          'one': True,
                          'tree': 3,
                          'two': True})

    def test_extract_id_from_uri(self):
        uri = '/rest/plan-scripts/3518be0e-17c1-4189-8f81-83f3724f6155'
        id = '3518be0e-17c1-4189-8f81-83f3724f6155'
        extracted_id = extract_id_from_uri(uri)
        self.assertEqual(id, extracted_id)

    def test_extract_id_from_uri_with_extra_slash(self):
        uri = '/rest/plan-scripts/3518be0e-17c1-4189-8f81-83f3724f6155/'
        extracted_id = extract_id_from_uri(uri)
        self.assertEqual(extracted_id, '')

    def test_extract_id_from_uri_passing_id(self):
        uri = '3518be0e-17c1-4189-8f81-83f3724f6155'
        extracted_id = extract_id_from_uri(uri)
        self.assertEqual(extracted_id, '3518be0e-17c1-4189-8f81-83f3724f6155')

    def test_extract_id_from_uri_unsupported(self):
        # This example is not supported yet
        uri = '/rest/plan-scripts/3518be0e-17c1-4189-8f81-83f3724f6155/otherthing'
        extracted_id = extract_id_from_uri(uri)
        self.assertEqual(extracted_id, 'otherthing')

[((88, 5, 88, 75), 'mock.patch.object', 'mock.patch.object', ({(88, 23, 88, 33): 'connection', (88, 35, 88, 74): '"""post_multipart_with_response_handling"""'}, {}), "(connection, 'post_multipart_with_response_handling')", False, 'import mock\n'), ((98, 5, 98, 75), 'mock.patch.object', 'mock.patch.object', ({(98, 23, 98, 33): 'connection', (98, 35, 98, 74): '"""post_multipart_with_response_handling"""'}, {}), "(connection, 'post_multipart_with_response_handling')", False, 'import mock\n'), ((107, 5, 107, 75), 'mock.patch.object', 'mock.patch.object', ({(107, 23, 107, 33): 'connection', (107, 35, 107, 74): '"""post_multipart_with_response_handling"""'}, {}), "(connection, 'post_multipart_with_response_handling')", False, 'import mock\n'), ((108, 5, 108, 52), 'mock.patch.object', 'mock.patch.object', ({(108, 23, 108, 34): 'TaskMonitor', (108, 36, 108, 51): '"""wait_for_task"""'}, {}), "(TaskMonitor, 'wait_for_task')", False, 'import mock\n'), ((109, 5, 109, 41), 'mock.patch.object', 'mock.patch.object', ({(109, 23, 109, 33): 'connection', (109, 35, 109, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((119, 5, 119, 75), 'mock.patch.object', 'mock.patch.object', ({(119, 23, 119, 33): 'connection', (119, 35, 119, 74): '"""post_multipart_with_response_handling"""'}, {}), "(connection, 'post_multipart_with_response_handling')", False, 'import mock\n'), ((120, 5, 120, 52), 'mock.patch.object', 'mock.patch.object', ({(120, 23, 120, 34): 'TaskMonitor', (120, 36, 120, 51): '"""wait_for_task"""'}, {}), "(TaskMonitor, 'wait_for_task')", False, 'import mock\n'), ((130, 5, 130, 75), 'mock.patch.object', 'mock.patch.object', ({(130, 23, 130, 33): 'connection', (130, 35, 130, 74): '"""post_multipart_with_response_handling"""'}, {}), "(connection, 'post_multipart_with_response_handling')", False, 'import mock\n'), ((131, 5, 131, 52), 'mock.patch.object', 'mock.patch.object', ({(131, 23, 131, 34): 'TaskMonitor', (131, 36, 131, 51): '"""wait_for_task"""'}, {}), "(TaskMonitor, 'wait_for_task')", False, 'import mock\n'), ((132, 5, 132, 41), 'mock.patch.object', 'mock.patch.object', ({(132, 23, 132, 33): 'connection', (132, 35, 132, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((145, 5, 145, 75), 'mock.patch.object', 'mock.patch.object', ({(145, 23, 145, 33): 'connection', (145, 35, 145, 74): '"""post_multipart_with_response_handling"""'}, {}), "(connection, 'post_multipart_with_response_handling')", False, 'import mock\n'), ((146, 5, 146, 52), 'mock.patch.object', 'mock.patch.object', ({(146, 23, 146, 34): 'TaskMonitor', (146, 36, 146, 51): '"""wait_for_task"""'}, {}), "(TaskMonitor, 'wait_for_task')", False, 'import mock\n'), ((157, 5, 157, 56), 'mock.patch.object', 'mock.patch.object', ({(157, 23, 157, 33): 'connection', (157, 35, 157, 55): '"""download_to_stream"""'}, {}), "(connection, 'download_to_stream')", False, 'import mock\n'), ((168, 5, 168, 56), 'mock.patch.object', 'mock.patch.object', ({(168, 23, 168, 33): 'connection', (168, 35, 168, 55): '"""download_to_stream"""'}, {}), "(connection, 'download_to_stream')", False, 'import mock\n'), ((181, 5, 181, 56), 'mock.patch.object', 'mock.patch.object', ({(181, 23, 181, 33): 'connection', (181, 35, 181, 55): '"""download_to_stream"""'}, {}), "(connection, 'download_to_stream')", False, 'import mock\n'), ((193, 5, 193, 56), 'mock.patch.object', 'mock.patch.object', ({(193, 23, 193, 33): 'connection', (193, 35, 193, 55): '"""download_to_stream"""'}, {}), "(connection, 'download_to_stream')", False, 'import mock\n'), ((213, 5, 213, 42), 'mock.patch.object', 'mock.patch.object', ({(213, 23, 213, 33): 'connection', (213, 35, 213, 41): '"""post"""'}, {}), "(connection, 'post')", False, 'import mock\n'), ((214, 5, 214, 52), 'mock.patch.object', 'mock.patch.object', ({(214, 23, 214, 34): 'TaskMonitor', (214, 36, 214, 51): '"""wait_for_task"""'}, {}), "(TaskMonitor, 'wait_for_task')", False, 'import mock\n'), ((223, 5, 223, 42), 'mock.patch.object', 'mock.patch.object', ({(223, 23, 223, 33): 'connection', (223, 35, 223, 41): '"""post"""'}, {}), "(connection, 'post')", False, 'import mock\n'), ((224, 5, 224, 52), 'mock.patch.object', 'mock.patch.object', ({(224, 23, 224, 34): 'TaskMonitor', (224, 36, 224, 51): '"""wait_for_task"""'}, {}), "(TaskMonitor, 'wait_for_task')", False, 'import mock\n'), ((233, 5, 233, 42), 'mock.patch.object', 'mock.patch.object', ({(233, 23, 233, 33): 'connection', (233, 35, 233, 41): '"""post"""'}, {}), "(connection, 'post')", False, 'import mock\n'), ((234, 5, 234, 52), 'mock.patch.object', 'mock.patch.object', ({(234, 23, 234, 34): 'TaskMonitor', (234, 36, 234, 51): '"""wait_for_task"""'}, {}), "(TaskMonitor, 'wait_for_task')", False, 'import mock\n'), ((242, 5, 242, 42), 'mock.patch.object', 'mock.patch.object', ({(242, 23, 242, 33): 'connection', (242, 35, 242, 41): '"""post"""'}, {}), "(connection, 'post')", False, 'import mock\n'), ((243, 5, 243, 52), 'mock.patch.object', 'mock.patch.object', ({(243, 23, 243, 34): 'TaskMonitor', (243, 36, 243, 51): '"""wait_for_task"""'}, {}), "(TaskMonitor, 'wait_for_task')", False, 'import mock\n'), ((254, 5, 254, 42), 'mock.patch.object', 'mock.patch.object', ({(254, 23, 254, 33): 'connection', (254, 35, 254, 41): '"""post"""'}, {}), "(connection, 'post')", False, 'import mock\n'), ((262, 5, 262, 56), 'mock.patch.object', 'mock.patch.object', ({(262, 23, 262, 31): 'Resource', (262, 33, 262, 55): '"""ensure_resource_data"""'}, {}), "(Resource, 'ensure_resource_data')", False, 'import mock\n'), ((263, 5, 263, 41), 'mock.patch.object', 'mock.patch.object', ({(263, 23, 263, 33): 'connection', (263, 35, 263, 40): '"""put"""'}, {}), "(connection, 'put')", False, 'import mock\n'), ((264, 5, 264, 52), 'mock.patch.object', 'mock.patch.object', ({(264, 23, 264, 34): 'TaskMonitor', (264, 36, 264, 51): '"""wait_for_task"""'}, {}), "(TaskMonitor, 'wait_for_task')", False, 'import mock\n'), ((276, 5, 276, 56), 'mock.patch.object', 'mock.patch.object', ({(276, 23, 276, 31): 'Resource', (276, 33, 276, 55): '"""ensure_resource_data"""'}, {}), "(Resource, 'ensure_resource_data')", False, 'import mock\n'), ((277, 5, 277, 41), 'mock.patch.object', 'mock.patch.object', ({(277, 23, 277, 33): 'connection', (277, 35, 277, 40): '"""put"""'}, {}), "(connection, 'put')", False, 'import mock\n'), ((278, 5, 278, 52), 'mock.patch.object', 'mock.patch.object', ({(278, 23, 278, 34): 'TaskMonitor', (278, 36, 278, 51): '"""wait_for_task"""'}, {}), "(TaskMonitor, 'wait_for_task')", False, 'import mock\n'), ((287, 5, 287, 56), 'mock.patch.object', 'mock.patch.object', ({(287, 23, 287, 31): 'Resource', (287, 33, 287, 55): '"""ensure_resource_data"""'}, {}), "(Resource, 'ensure_resource_data')", False, 'import mock\n'), ((288, 5, 288, 41), 'mock.patch.object', 'mock.patch.object', ({(288, 23, 288, 33): 'connection', (288, 35, 288, 40): '"""put"""'}, {}), "(connection, 'put')", False, 'import mock\n'), ((289, 5, 289, 52), 'mock.patch.object', 'mock.patch.object', ({(289, 23, 289, 34): 'TaskMonitor', (289, 36, 289, 51): '"""wait_for_task"""'}, {}), "(TaskMonitor, 'wait_for_task')", False, 'import mock\n'), ((302, 5, 302, 41), 'mock.patch.object', 'mock.patch.object', ({(302, 23, 302, 33): 'connection', (302, 35, 302, 40): '"""put"""'}, {}), "(connection, 'put')", False, 'import mock\n'), ((319, 5, 319, 56), 'mock.patch.object', 'mock.patch.object', ({(319, 23, 319, 31): 'Resource', (319, 33, 319, 55): '"""ensure_resource_data"""'}, {}), "(Resource, 'ensure_resource_data')", False, 'import mock\n'), ((320, 5, 320, 43), 'mock.patch.object', 'mock.patch.object', ({(320, 23, 320, 33): 'connection', (320, 35, 320, 42): '"""patch"""'}, {}), "(connection, 'patch')", False, 'import mock\n'), ((335, 5, 335, 56), 'mock.patch.object', 'mock.patch.object', ({(335, 23, 335, 31): 'Resource', (335, 33, 335, 55): '"""ensure_resource_data"""'}, {}), "(Resource, 'ensure_resource_data')", False, 'import mock\n'), ((336, 5, 336, 43), 'mock.patch.object', 'mock.patch.object', ({(336, 23, 336, 33): 'connection', (336, 35, 336, 42): '"""patch"""'}, {}), "(connection, 'patch')", False, 'import mock\n'), ((349, 5, 349, 56), 'mock.patch.object', 'mock.patch.object', ({(349, 23, 349, 31): 'Resource', (349, 33, 349, 55): '"""ensure_resource_data"""'}, {}), "(Resource, 'ensure_resource_data')", False, 'import mock\n'), ((350, 5, 350, 43), 'mock.patch.object', 'mock.patch.object', ({(350, 23, 350, 33): 'connection', (350, 35, 350, 42): '"""patch"""'}, {}), "(connection, 'patch')", False, 'import mock\n'), ((363, 5, 363, 56), 'mock.patch.object', 'mock.patch.object', ({(363, 23, 363, 31): 'Resource', (363, 33, 363, 55): '"""ensure_resource_data"""'}, {}), "(Resource, 'ensure_resource_data')", False, 'import mock\n'), ((364, 5, 364, 43), 'mock.patch.object', 'mock.patch.object', ({(364, 23, 364, 33): 'connection', (364, 35, 364, 42): '"""patch"""'}, {}), "(connection, 'patch')", False, 'import mock\n'), ((374, 5, 374, 56), 'mock.patch.object', 'mock.patch.object', ({(374, 23, 374, 31): 'Resource', (374, 33, 374, 55): '"""ensure_resource_data"""'}, {}), "(Resource, 'ensure_resource_data')", False, 'import mock\n'), ((375, 5, 375, 43), 'mock.patch.object', 'mock.patch.object', ({(375, 23, 375, 33): 'connection', (375, 35, 375, 42): '"""patch"""'}, {}), "(connection, 'patch')", False, 'import mock\n'), ((386, 5, 386, 56), 'mock.patch.object', 'mock.patch.object', ({(386, 23, 386, 31): 'Resource', (386, 33, 386, 55): '"""ensure_resource_data"""'}, {}), "(Resource, 'ensure_resource_data')", False, 'import mock\n'), ((387, 5, 387, 43), 'mock.patch.object', 'mock.patch.object', ({(387, 23, 387, 33): 'connection', (387, 35, 387, 42): '"""patch"""'}, {}), "(connection, 'patch')", False, 'import mock\n'), ((388, 5, 388, 52), 'mock.patch.object', 'mock.patch.object', ({(388, 23, 388, 34): 'TaskMonitor', (388, 36, 388, 51): '"""wait_for_task"""'}, {}), "(TaskMonitor, 'wait_for_task')", False, 'import mock\n'), ((397, 5, 397, 56), 'mock.patch.object', 'mock.patch.object', ({(397, 23, 397, 31): 'Resource', (397, 33, 397, 55): '"""ensure_resource_data"""'}, {}), "(Resource, 'ensure_resource_data')", False, 'import mock\n'), ((398, 5, 398, 43), 'mock.patch.object', 'mock.patch.object', ({(398, 23, 398, 33): 'connection', (398, 35, 398, 42): '"""patch"""'}, {}), "(connection, 'patch')", False, 'import mock\n'), ((399, 5, 399, 57), 'mock.patch.object', 'mock.patch.object', ({(399, 23, 399, 34): 'TaskMonitor', (399, 36, 399, 56): '"""get_completed_task"""'}, {}), "(TaskMonitor, 'get_completed_task')", False, 'import mock\n'), ((412, 5, 412, 56), 'mock.patch.object', 'mock.patch.object', ({(412, 23, 412, 31): 'Resource', (412, 33, 412, 55): '"""ensure_resource_data"""'}, {}), "(Resource, 'ensure_resource_data')", False, 'import mock\n'), ((413, 5, 413, 43), 'mock.patch.object', 'mock.patch.object', ({(413, 23, 413, 33): 'connection', (413, 35, 413, 42): '"""patch"""'}, {}), "(connection, 'patch')", False, 'import mock\n'), ((414, 5, 414, 57), 'mock.patch.object', 'mock.patch.object', ({(414, 23, 414, 34): 'TaskMonitor', (414, 36, 414, 56): '"""get_completed_task"""'}, {}), "(TaskMonitor, 'get_completed_task')", False, 'import mock\n'), ((430, 5, 430, 56), 'mock.patch.object', 'mock.patch.object', ({(430, 23, 430, 31): 'Resource', (430, 33, 430, 55): '"""ensure_resource_data"""'}, {}), "(Resource, 'ensure_resource_data')", False, 'import mock\n'), ((431, 5, 431, 43), 'mock.patch.object', 'mock.patch.object', ({(431, 23, 431, 33): 'connection', (431, 35, 431, 42): '"""patch"""'}, {}), "(connection, 'patch')", False, 'import mock\n'), ((432, 5, 432, 52), 'mock.patch.object', 'mock.patch.object', ({(432, 23, 432, 34): 'TaskMonitor', (432, 36, 432, 51): '"""wait_for_task"""'}, {}), "(TaskMonitor, 'wait_for_task')", False, 'import mock\n'), ((449, 5, 449, 56), 'mock.patch.object', 'mock.patch.object', ({(449, 23, 449, 31): 'Resource', (449, 33, 449, 55): '"""ensure_resource_data"""'}, {}), "(Resource, 'ensure_resource_data')", False, 'import mock\n'), ((450, 5, 450, 41), 'mock.patch.object', 'mock.patch.object', ({(450, 23, 450, 33): 'connection', (450, 35, 450, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((464, 5, 464, 56), 'mock.patch.object', 'mock.patch.object', ({(464, 23, 464, 31): 'Resource', (464, 33, 464, 55): '"""ensure_resource_data"""'}, {}), "(Resource, 'ensure_resource_data')", False, 'import mock\n'), ((465, 5, 465, 41), 'mock.patch.object', 'mock.patch.object', ({(465, 23, 465, 33): 'connection', (465, 35, 465, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((482, 5, 482, 56), 'mock.patch.object', 'mock.patch.object', ({(482, 23, 482, 31): 'Resource', (482, 33, 482, 55): '"""ensure_resource_data"""'}, {}), "(Resource, 'ensure_resource_data')", False, 'import mock\n'), ((483, 5, 483, 41), 'mock.patch.object', 'mock.patch.object', ({(483, 23, 483, 33): 'connection', (483, 35, 483, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((491, 5, 491, 56), 'mock.patch.object', 'mock.patch.object', ({(491, 23, 491, 31): 'Resource', (491, 33, 491, 55): '"""ensure_resource_data"""'}, {}), "(Resource, 'ensure_resource_data')", False, 'import mock\n'), ((492, 5, 492, 41), 'mock.patch.object', 'mock.patch.object', ({(492, 23, 492, 33): 'connection', (492, 35, 492, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((508, 5, 508, 41), 'mock.patch.object', 'mock.patch.object', ({(508, 23, 508, 33): 'connection', (508, 35, 508, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((522, 5, 522, 48), 'mock.patch.object', 'mock.patch.object', ({(522, 23, 522, 37): 'ResourceHelper', (522, 39, 522, 47): '"""do_put"""'}, {}), "(ResourceHelper, 'do_put')", False, 'import mock\n'), ((523, 5, 523, 56), 'mock.patch.object', 'mock.patch.object', ({(523, 23, 523, 31): 'Resource', (523, 33, 523, 55): '"""ensure_resource_data"""'}, {}), "(Resource, 'ensure_resource_data')", False, 'import mock\n'), ((535, 5, 535, 48), 'mock.patch.object', 'mock.patch.object', ({(535, 23, 535, 37): 'ResourceHelper', (535, 39, 535, 47): '"""do_get"""'}, {}), "(ResourceHelper, 'do_get')", False, 'import mock\n'), ((542, 5, 542, 42), 'mock.patch.object', 'mock.patch.object', ({(542, 23, 542, 31): 'Resource', (542, 33, 542, 41): '"""get_by"""'}, {}), "(Resource, 'get_by')", False, 'import mock\n'), ((549, 5, 549, 48), 'mock.patch.object', 'mock.patch.object', ({(549, 23, 549, 37): 'ResourceHelper', (549, 39, 549, 47): '"""do_get"""'}, {}), "(ResourceHelper, 'do_get')", False, 'import mock\n'), ((550, 5, 550, 42), 'mock.patch.object', 'mock.patch.object', ({(550, 23, 550, 31): 'Resource', (550, 33, 550, 41): '"""get_by"""'}, {}), "(Resource, 'get_by')", False, 'import mock\n'), ((559, 5, 559, 42), 'mock.patch.object', 'mock.patch.object', ({(559, 23, 559, 31): 'Resource', (559, 33, 559, 41): '"""get_by"""'}, {}), "(Resource, 'get_by')", False, 'import mock\n'), ((566, 5, 566, 41), 'mock.patch.object', 'mock.patch.object', ({(566, 23, 566, 33): 'connection', (566, 35, 566, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((586, 5, 586, 41), 'mock.patch.object', 'mock.patch.object', ({(586, 23, 586, 33): 'connection', (586, 35, 586, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((593, 5, 593, 41), 'mock.patch.object', 'mock.patch.object', ({(593, 23, 593, 33): 'connection', (593, 35, 593, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((600, 5, 600, 41), 'mock.patch.object', 'mock.patch.object', ({(600, 23, 600, 33): 'connection', (600, 35, 600, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((607, 5, 607, 41), 'mock.patch.object', 'mock.patch.object', ({(607, 23, 607, 33): 'connection', (607, 35, 607, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((616, 5, 616, 41), 'mock.patch.object', 'mock.patch.object', ({(616, 23, 616, 33): 'connection', (616, 35, 616, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((633, 5, 633, 41), 'mock.patch.object', 'mock.patch.object', ({(633, 23, 633, 33): 'connection', (633, 35, 633, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((650, 5, 650, 41), 'mock.patch.object', 'mock.patch.object', ({(650, 23, 650, 33): 'connection', (650, 35, 650, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((667, 5, 667, 41), 'mock.patch.object', 'mock.patch.object', ({(667, 23, 667, 33): 'connection', (667, 35, 667, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((684, 5, 684, 41), 'mock.patch.object', 'mock.patch.object', ({(684, 23, 684, 33): 'connection', (684, 35, 684, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((704, 5, 704, 41), 'mock.patch.object', 'mock.patch.object', ({(704, 23, 704, 33): 'connection', (704, 35, 704, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((720, 5, 720, 41), 'mock.patch.object', 'mock.patch.object', ({(720, 23, 720, 33): 'connection', (720, 35, 720, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((728, 5, 728, 41), 'mock.patch.object', 'mock.patch.object', ({(728, 23, 728, 33): 'connection', (728, 35, 728, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((736, 5, 736, 48), 'mock.patch.object', 'mock.patch.object', ({(736, 23, 736, 37): 'ResourceHelper', (736, 39, 736, 47): '"""do_get"""'}, {}), "(ResourceHelper, 'do_get')", False, 'import mock\n'), ((743, 5, 743, 42), 'mock.patch.object', 'mock.patch.object', ({(743, 23, 743, 33): 'connection', (743, 35, 743, 41): '"""post"""'}, {}), "(connection, 'post')", False, 'import mock\n'), ((752, 5, 752, 42), 'mock.patch.object', 'mock.patch.object', ({(752, 23, 752, 33): 'connection', (752, 35, 752, 41): '"""post"""'}, {}), "(connection, 'post')", False, 'import mock\n'), ((764, 5, 764, 42), 'mock.patch.object', 'mock.patch.object', ({(764, 23, 764, 33): 'connection', (764, 35, 764, 41): '"""post"""'}, {}), "(connection, 'post')", False, 'import mock\n'), ((773, 5, 773, 42), 'mock.patch.object', 'mock.patch.object', ({(773, 23, 773, 33): 'connection', (773, 35, 773, 41): '"""post"""'}, {}), "(connection, 'post')", False, 'import mock\n'), ((782, 5, 782, 42), 'mock.patch.object', 'mock.patch.object', ({(782, 23, 782, 33): 'connection', (782, 35, 782, 41): '"""post"""'}, {}), "(connection, 'post')", False, 'import mock\n'), ((792, 5, 792, 42), 'mock.patch.object', 'mock.patch.object', ({(792, 23, 792, 33): 'connection', (792, 35, 792, 41): '"""post"""'}, {}), "(connection, 'post')", False, 'import mock\n'), ((801, 5, 801, 42), 'mock.patch.object', 'mock.patch.object', ({(801, 23, 801, 33): 'connection', (801, 35, 801, 41): '"""post"""'}, {}), "(connection, 'post')", False, 'import mock\n'), ((807, 5, 807, 42), 'mock.patch.object', 'mock.patch.object', ({(807, 23, 807, 33): 'connection', (807, 35, 807, 41): '"""post"""'}, {}), "(connection, 'post')", False, 'import mock\n'), ((808, 5, 808, 52), 'mock.patch.object', 'mock.patch.object', ({(808, 23, 808, 34): 'TaskMonitor', (808, 36, 808, 51): '"""wait_for_task"""'}, {}), "(TaskMonitor, 'wait_for_task')", False, 'import mock\n'), ((817, 5, 817, 56), 'mock.patch.object', 'mock.patch.object', ({(817, 23, 817, 31): 'Resource', (817, 33, 817, 55): '"""ensure_resource_data"""'}, {}), "(Resource, 'ensure_resource_data')", False, 'import mock\n'), ((818, 5, 818, 44), 'mock.patch.object', 'mock.patch.object', ({(818, 23, 818, 33): 'connection', (818, 35, 818, 43): '"""delete"""'}, {}), "(connection, 'delete')", False, 'import mock\n'), ((825, 5, 825, 44), 'mock.patch.object', 'mock.patch.object', ({(825, 23, 825, 33): 'connection', (825, 35, 825, 43): '"""delete"""'}, {}), "(connection, 'delete')", False, 'import mock\n'), ((833, 5, 833, 56), 'mock.patch.object', 'mock.patch.object', ({(833, 23, 833, 31): 'Resource', (833, 33, 833, 55): '"""ensure_resource_data"""'}, {}), "(Resource, 'ensure_resource_data')", False, 'import mock\n'), ((834, 5, 834, 44), 'mock.patch.object', 'mock.patch.object', ({(834, 23, 834, 33): 'connection', (834, 35, 834, 43): '"""delete"""'}, {}), "(connection, 'delete')", False, 'import mock\n'), ((835, 5, 835, 52), 'mock.patch.object', 'mock.patch.object', ({(835, 23, 835, 34): 'TaskMonitor', (835, 36, 835, 51): '"""wait_for_task"""'}, {}), "(TaskMonitor, 'wait_for_task')", False, 'import mock\n'), ((844, 5, 844, 56), 'mock.patch.object', 'mock.patch.object', ({(844, 23, 844, 31): 'Resource', (844, 33, 844, 55): '"""ensure_resource_data"""'}, {}), "(Resource, 'ensure_resource_data')", False, 'import mock\n'), ((845, 5, 845, 44), 'mock.patch.object', 'mock.patch.object', ({(845, 23, 845, 33): 'connection', (845, 35, 845, 43): '"""delete"""'}, {}), "(connection, 'delete')", False, 'import mock\n'), ((846, 5, 846, 52), 'mock.patch.object', 'mock.patch.object', ({(846, 23, 846, 34): 'TaskMonitor', (846, 36, 846, 51): '"""wait_for_task"""'}, {}), "(TaskMonitor, 'wait_for_task')", False, 'import mock\n'), ((855, 5, 855, 56), 'mock.patch.object', 'mock.patch.object', ({(855, 23, 855, 31): 'Resource', (855, 33, 855, 55): '"""ensure_resource_data"""'}, {}), "(Resource, 'ensure_resource_data')", False, 'import mock\n'), ((856, 5, 856, 41), 'mock.patch.object', 'mock.patch.object', ({(856, 23, 856, 33): 'connection', (856, 35, 856, 40): '"""put"""'}, {}), "(connection, 'put')", False, 'import mock\n'), ((869, 5, 869, 56), 'mock.patch.object', 'mock.patch.object', ({(869, 23, 869, 31): 'Resource', (869, 33, 869, 55): '"""ensure_resource_data"""'}, {}), "(Resource, 'ensure_resource_data')", False, 'import mock\n'), ((870, 5, 870, 41), 'mock.patch.object', 'mock.patch.object', ({(870, 23, 870, 33): 'connection', (870, 35, 870, 40): '"""put"""'}, {}), "(connection, 'put')", False, 'import mock\n'), ((878, 5, 878, 56), 'mock.patch.object', 'mock.patch.object', ({(878, 23, 878, 31): 'Resource', (878, 33, 878, 55): '"""ensure_resource_data"""'}, {}), "(Resource, 'ensure_resource_data')", False, 'import mock\n'), ((879, 5, 879, 41), 'mock.patch.object', 'mock.patch.object', ({(879, 23, 879, 33): 'connection', (879, 35, 879, 40): '"""put"""'}, {}), "(connection, 'put')", False, 'import mock\n'), ((891, 5, 891, 56), 'mock.patch.object', 'mock.patch.object', ({(891, 23, 891, 31): 'Resource', (891, 33, 891, 55): '"""ensure_resource_data"""'}, {}), "(Resource, 'ensure_resource_data')", False, 'import mock\n'), ((892, 5, 892, 41), 'mock.patch.object', 'mock.patch.object', ({(892, 23, 892, 33): 'connection', (892, 35, 892, 40): '"""put"""'}, {}), "(connection, 'put')", False, 'import mock\n'), ((902, 5, 902, 56), 'mock.patch.object', 'mock.patch.object', ({(902, 23, 902, 31): 'Resource', (902, 33, 902, 55): '"""ensure_resource_data"""'}, {}), "(Resource, 'ensure_resource_data')", False, 'import mock\n'), ((903, 5, 903, 41), 'mock.patch.object', 'mock.patch.object', ({(903, 23, 903, 33): 'connection', (903, 35, 903, 40): '"""put"""'}, {}), "(connection, 'put')", False, 'import mock\n'), ((913, 5, 913, 56), 'mock.patch.object', 'mock.patch.object', ({(913, 23, 913, 31): 'Resource', (913, 33, 913, 55): '"""ensure_resource_data"""'}, {}), "(Resource, 'ensure_resource_data')", False, 'import mock\n'), ((914, 5, 914, 41), 'mock.patch.object', 'mock.patch.object', ({(914, 23, 914, 33): 'connection', (914, 35, 914, 40): '"""put"""'}, {}), "(connection, 'put')", False, 'import mock\n'), ((924, 5, 924, 56), 'mock.patch.object', 'mock.patch.object', ({(924, 23, 924, 31): 'Resource', (924, 33, 924, 55): '"""ensure_resource_data"""'}, {}), "(Resource, 'ensure_resource_data')", False, 'import mock\n'), ((925, 5, 925, 41), 'mock.patch.object', 'mock.patch.object', ({(925, 23, 925, 33): 'connection', (925, 35, 925, 40): '"""put"""'}, {}), "(connection, 'put')", False, 'import mock\n'), ((926, 5, 926, 52), 'mock.patch.object', 'mock.patch.object', ({(926, 23, 926, 34): 'TaskMonitor', (926, 36, 926, 51): '"""wait_for_task"""'}, {}), "(TaskMonitor, 'wait_for_task')", False, 'import mock\n'), ((938, 5, 938, 56), 'mock.patch.object', 'mock.patch.object', ({(938, 23, 938, 31): 'Resource', (938, 33, 938, 55): '"""ensure_resource_data"""'}, {}), "(Resource, 'ensure_resource_data')", False, 'import mock\n'), ((939, 5, 939, 41), 'mock.patch.object', 'mock.patch.object', ({(939, 23, 939, 33): 'connection', (939, 35, 939, 40): '"""put"""'}, {}), "(connection, 'put')", False, 'import mock\n'), ((940, 5, 940, 52), 'mock.patch.object', 'mock.patch.object', ({(940, 23, 940, 34): 'TaskMonitor', (940, 36, 940, 51): '"""wait_for_task"""'}, {}), "(TaskMonitor, 'wait_for_task')", False, 'import mock\n'), ((951, 5, 951, 42), 'mock.patch.object', 'mock.patch.object', ({(951, 23, 951, 31): 'Resource', (951, 33, 951, 41): '"""get_by"""'}, {}), "(Resource, 'get_by')", False, 'import mock\n'), ((956, 5, 956, 42), 'mock.patch.object', 'mock.patch.object', ({(956, 23, 956, 31): 'Resource', (956, 33, 956, 41): '"""get_by"""'}, {}), "(Resource, 'get_by')", False, 'import mock\n'), ((963, 5, 963, 41), 'mock.patch.object', 'mock.patch.object', ({(963, 23, 963, 33): 'connection', (963, 35, 963, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((968, 5, 968, 41), 'mock.patch.object', 'mock.patch.object', ({(968, 23, 968, 33): 'connection', (968, 35, 968, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((973, 5, 973, 41), 'mock.patch.object', 'mock.patch.object', ({(973, 23, 973, 33): 'connection', (973, 35, 973, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((980, 5, 980, 41), 'mock.patch.object', 'mock.patch.object', ({(980, 23, 980, 33): 'connection', (980, 35, 980, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((988, 5, 988, 41), 'mock.patch.object', 'mock.patch.object', ({(988, 23, 988, 33): 'connection', (988, 35, 988, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((996, 5, 996, 41), 'mock.patch.object', 'mock.patch.object', ({(996, 23, 996, 33): 'connection', (996, 35, 996, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((1004, 5, 1004, 41), 'mock.patch.object', 'mock.patch.object', ({(1004, 23, 1004, 33): 'connection', (1004, 35, 1004, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((1012, 5, 1012, 41), 'mock.patch.object', 'mock.patch.object', ({(1012, 23, 1012, 33): 'connection', (1012, 35, 1012, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((1173, 5, 1173, 41), 'mock.patch.object', 'mock.patch.object', ({(1173, 23, 1173, 33): 'connection', (1173, 35, 1173, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((1198, 5, 1198, 41), 'mock.patch.object', 'mock.patch.object', ({(1198, 23, 1198, 33): 'connection', (1198, 35, 1198, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((1205, 5, 1205, 41), 'mock.patch.object', 'mock.patch.object', ({(1205, 23, 1205, 33): 'connection', (1205, 35, 1205, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((1212, 5, 1212, 41), 'mock.patch.object', 'mock.patch.object', ({(1212, 23, 1212, 33): 'connection', (1212, 35, 1212, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((1219, 5, 1219, 41), 'mock.patch.object', 'mock.patch.object', ({(1219, 23, 1219, 33): 'connection', (1219, 35, 1219, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((1228, 5, 1228, 41), 'mock.patch.object', 'mock.patch.object', ({(1228, 23, 1228, 33): 'connection', (1228, 35, 1228, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((1245, 5, 1245, 41), 'mock.patch.object', 'mock.patch.object', ({(1245, 23, 1245, 33): 'connection', (1245, 35, 1245, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((1262, 5, 1262, 41), 'mock.patch.object', 'mock.patch.object', ({(1262, 23, 1262, 33): 'connection', (1262, 35, 1262, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((1279, 5, 1279, 41), 'mock.patch.object', 'mock.patch.object', ({(1279, 23, 1279, 33): 'connection', (1279, 35, 1279, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((1296, 5, 1296, 41), 'mock.patch.object', 'mock.patch.object', ({(1296, 23, 1296, 33): 'connection', (1296, 35, 1296, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((1316, 5, 1316, 41), 'mock.patch.object', 'mock.patch.object', ({(1316, 23, 1316, 33): 'connection', (1316, 35, 1316, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((1332, 5, 1332, 41), 'mock.patch.object', 'mock.patch.object', ({(1332, 23, 1332, 33): 'connection', (1332, 35, 1332, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((1340, 5, 1340, 41), 'mock.patch.object', 'mock.patch.object', ({(1340, 23, 1340, 33): 'connection', (1340, 35, 1340, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((1348, 5, 1348, 44), 'mock.patch.object', 'mock.patch.object', ({(1348, 23, 1348, 33): 'connection', (1348, 35, 1348, 43): '"""delete"""'}, {}), "(connection, 'delete')", False, 'import mock\n'), ((1349, 5, 1349, 52), 'mock.patch.object', 'mock.patch.object', ({(1349, 23, 1349, 34): 'TaskMonitor', (1349, 36, 1349, 51): '"""wait_for_task"""'}, {}), "(TaskMonitor, 'wait_for_task')", False, 'import mock\n'), ((1360, 5, 1360, 44), 'mock.patch.object', 'mock.patch.object', ({(1360, 23, 1360, 33): 'connection', (1360, 35, 1360, 43): '"""delete"""'}, {}), "(connection, 'delete')", False, 'import mock\n'), ((1369, 5, 1369, 44), 'mock.patch.object', 'mock.patch.object', ({(1369, 23, 1369, 33): 'connection', (1369, 35, 1369, 43): '"""delete"""'}, {}), "(connection, 'delete')", False, 'import mock\n'), ((1370, 5, 1370, 52), 'mock.patch.object', 'mock.patch.object', ({(1370, 23, 1370, 34): 'TaskMonitor', (1370, 36, 1370, 51): '"""wait_for_task"""'}, {}), "(TaskMonitor, 'wait_for_task')", False, 'import mock\n'), ((1381, 5, 1381, 44), 'mock.patch.object', 'mock.patch.object', ({(1381, 23, 1381, 33): 'connection', (1381, 35, 1381, 43): '"""delete"""'}, {}), "(connection, 'delete')", False, 'import mock\n'), ((1382, 5, 1382, 52), 'mock.patch.object', 'mock.patch.object', ({(1382, 23, 1382, 34): 'TaskMonitor', (1382, 36, 1382, 51): '"""wait_for_task"""'}, {}), "(TaskMonitor, 'wait_for_task')", False, 'import mock\n'), ((1392, 5, 1392, 44), 'mock.patch.object', 'mock.patch.object', ({(1392, 23, 1392, 33): 'connection', (1392, 35, 1392, 43): '"""delete"""'}, {}), "(connection, 'delete')", False, 'import mock\n'), ((1393, 5, 1393, 52), 'mock.patch.object', 'mock.patch.object', ({(1393, 23, 1393, 34): 'TaskMonitor', (1393, 36, 1393, 51): '"""wait_for_task"""'}, {}), "(TaskMonitor, 'wait_for_task')", False, 'import mock\n'), ((1412, 5, 1412, 41), 'mock.patch.object', 'mock.patch.object', ({(1412, 23, 1412, 33): 'connection', (1412, 35, 1412, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((1417, 5, 1417, 41), 'mock.patch.object', 'mock.patch.object', ({(1417, 23, 1417, 33): 'connection', (1417, 35, 1417, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((1422, 5, 1422, 48), 'mock.patch.object', 'mock.patch.object', ({(1422, 23, 1422, 37): 'ResourceClient', (1422, 39, 1422, 47): '"""get_by"""'}, {}), "(ResourceClient, 'get_by')", False, 'import mock\n'), ((1429, 5, 1429, 48), 'mock.patch.object', 'mock.patch.object', ({(1429, 23, 1429, 37): 'ResourceClient', (1429, 39, 1429, 47): '"""get_by"""'}, {}), "(ResourceClient, 'get_by')", False, 'import mock\n'), ((1436, 5, 1436, 41), 'mock.patch.object', 'mock.patch.object', ({(1436, 23, 1436, 33): 'connection', (1436, 35, 1436, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((1444, 5, 1444, 41), 'mock.patch.object', 'mock.patch.object', ({(1444, 23, 1444, 33): 'connection', (1444, 35, 1444, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((1452, 5, 1452, 41), 'mock.patch.object', 'mock.patch.object', ({(1452, 23, 1452, 33): 'connection', (1452, 35, 1452, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((1460, 5, 1460, 41), 'mock.patch.object', 'mock.patch.object', ({(1460, 23, 1460, 33): 'connection', (1460, 35, 1460, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((1468, 5, 1468, 49), 'mock.patch.object', 'mock.patch.object', ({(1468, 23, 1468, 37): 'ResourceClient', (1468, 39, 1468, 48): '"""get_all"""'}, {}), "(ResourceClient, 'get_all')", False, 'import mock\n'), ((1473, 5, 1473, 49), 'mock.patch.object', 'mock.patch.object', ({(1473, 23, 1473, 37): 'ResourceClient', (1473, 39, 1473, 48): '"""get_all"""'}, {}), "(ResourceClient, 'get_all')", False, 'import mock\n'), ((1483, 5, 1483, 49), 'mock.patch.object', 'mock.patch.object', ({(1483, 23, 1483, 37): 'ResourceClient', (1483, 39, 1483, 48): '"""get_all"""'}, {}), "(ResourceClient, 'get_all')", False, 'import mock\n'), ((1493, 5, 1493, 49), 'mock.patch.object', 'mock.patch.object', ({(1493, 23, 1493, 37): 'ResourceClient', (1493, 39, 1493, 48): '"""get_all"""'}, {}), "(ResourceClient, 'get_all')", False, 'import mock\n'), ((1498, 5, 1498, 49), 'mock.patch.object', 'mock.patch.object', ({(1498, 23, 1498, 37): 'ResourceClient', (1498, 39, 1498, 48): '"""get_all"""'}, {}), "(ResourceClient, 'get_all')", False, 'import mock\n'), ((1507, 5, 1507, 41), 'mock.patch.object', 'mock.patch.object', ({(1507, 23, 1507, 33): 'connection', (1507, 35, 1507, 40): '"""put"""'}, {}), "(connection, 'put')", False, 'import mock\n'), ((1508, 5, 1508, 52), 'mock.patch.object', 'mock.patch.object', ({(1508, 23, 1508, 34): 'TaskMonitor', (1508, 36, 1508, 51): '"""wait_for_task"""'}, {}), "(TaskMonitor, 'wait_for_task')", False, 'import mock\n'), ((1518, 5, 1518, 41), 'mock.patch.object', 'mock.patch.object', ({(1518, 23, 1518, 33): 'connection', (1518, 35, 1518, 40): '"""put"""'}, {}), "(connection, 'put')", False, 'import mock\n'), ((1519, 5, 1519, 52), 'mock.patch.object', 'mock.patch.object', ({(1519, 23, 1519, 34): 'TaskMonitor', (1519, 36, 1519, 51): '"""wait_for_task"""'}, {}), "(TaskMonitor, 'wait_for_task')", False, 'import mock\n'), ((1527, 5, 1527, 41), 'mock.patch.object', 'mock.patch.object', ({(1527, 23, 1527, 33): 'connection', (1527, 35, 1527, 40): '"""put"""'}, {}), "(connection, 'put')", False, 'import mock\n'), ((1528, 5, 1528, 52), 'mock.patch.object', 'mock.patch.object', ({(1528, 23, 1528, 34): 'TaskMonitor', (1528, 36, 1528, 51): '"""wait_for_task"""'}, {}), "(TaskMonitor, 'wait_for_task')", False, 'import mock\n'), ((1540, 5, 1540, 41), 'mock.patch.object', 'mock.patch.object', ({(1540, 23, 1540, 33): 'connection', (1540, 35, 1540, 40): '"""put"""'}, {}), "(connection, 'put')", False, 'import mock\n'), ((1549, 5, 1549, 41), 'mock.patch.object', 'mock.patch.object', ({(1549, 23, 1549, 33): 'connection', (1549, 35, 1549, 40): '"""put"""'}, {}), "(connection, 'put')", False, 'import mock\n'), ((1560, 5, 1560, 41), 'mock.patch.object', 'mock.patch.object', ({(1560, 23, 1560, 33): 'connection', (1560, 35, 1560, 40): '"""put"""'}, {}), "(connection, 'put')", False, 'import mock\n'), ((1569, 5, 1569, 41), 'mock.patch.object', 'mock.patch.object', ({(1569, 23, 1569, 33): 'connection', (1569, 35, 1569, 40): '"""put"""'}, {}), "(connection, 'put')", False, 'import mock\n'), ((1580, 5, 1580, 41), 'mock.patch.object', 'mock.patch.object', ({(1580, 23, 1580, 33): 'connection', (1580, 35, 1580, 40): '"""put"""'}, {}), "(connection, 'put')", False, 'import mock\n'), ((1593, 5, 1593, 41), 'mock.patch.object', 'mock.patch.object', ({(1593, 23, 1593, 33): 'connection', (1593, 35, 1593, 40): '"""put"""'}, {}), "(connection, 'put')", False, 'import mock\n'), ((1605, 5, 1605, 41), 'mock.patch.object', 'mock.patch.object', ({(1605, 23, 1605, 33): 'connection', (1605, 35, 1605, 40): '"""put"""'}, {}), "(connection, 'put')", False, 'import mock\n'), ((1615, 5, 1615, 41), 'mock.patch.object', 'mock.patch.object', ({(1615, 23, 1615, 33): 'connection', (1615, 35, 1615, 40): '"""put"""'}, {}), "(connection, 'put')", False, 'import mock\n'), ((1627, 5, 1627, 41), 'mock.patch.object', 'mock.patch.object', ({(1627, 23, 1627, 33): 'connection', (1627, 35, 1627, 40): '"""put"""'}, {}), "(connection, 'put')", False, 'import mock\n'), ((1628, 5, 1628, 52), 'mock.patch.object', 'mock.patch.object', ({(1628, 23, 1628, 34): 'TaskMonitor', (1628, 36, 1628, 51): '"""wait_for_task"""'}, {}), "(TaskMonitor, 'wait_for_task')", False, 'import mock\n'), ((1640, 5, 1640, 41), 'mock.patch.object', 'mock.patch.object', ({(1640, 23, 1640, 33): 'connection', (1640, 35, 1640, 40): '"""put"""'}, {}), "(connection, 'put')", False, 'import mock\n'), ((1641, 5, 1641, 52), 'mock.patch.object', 'mock.patch.object', ({(1641, 23, 1641, 34): 'TaskMonitor', (1641, 36, 1641, 51): '"""wait_for_task"""'}, {}), "(TaskMonitor, 'wait_for_task')", False, 'import mock\n'), ((1654, 5, 1654, 42), 'mock.patch.object', 'mock.patch.object', ({(1654, 23, 1654, 33): 'connection', (1654, 35, 1654, 41): '"""post"""'}, {}), "(connection, 'post')", False, 'import mock\n'), ((1655, 5, 1655, 52), 'mock.patch.object', 'mock.patch.object', ({(1655, 23, 1655, 34): 'TaskMonitor', (1655, 36, 1655, 51): '"""wait_for_task"""'}, {}), "(TaskMonitor, 'wait_for_task')", False, 'import mock\n'), ((1665, 5, 1665, 42), 'mock.patch.object', 'mock.patch.object', ({(1665, 23, 1665, 33): 'connection', (1665, 35, 1665, 41): '"""post"""'}, {}), "(connection, 'post')", False, 'import mock\n'), ((1666, 5, 1666, 52), 'mock.patch.object', 'mock.patch.object', ({(1666, 23, 1666, 34): 'TaskMonitor', (1666, 36, 1666, 51): '"""wait_for_task"""'}, {}), "(TaskMonitor, 'wait_for_task')", False, 'import mock\n'), ((1675, 5, 1675, 42), 'mock.patch.object', 'mock.patch.object', ({(1675, 23, 1675, 33): 'connection', (1675, 35, 1675, 41): '"""post"""'}, {}), "(connection, 'post')", False, 'import mock\n'), ((1676, 5, 1676, 52), 'mock.patch.object', 'mock.patch.object', ({(1676, 23, 1676, 34): 'TaskMonitor', (1676, 36, 1676, 51): '"""wait_for_task"""'}, {}), "(TaskMonitor, 'wait_for_task')", False, 'import mock\n'), ((1684, 5, 1684, 42), 'mock.patch.object', 'mock.patch.object', ({(1684, 23, 1684, 33): 'connection', (1684, 35, 1684, 41): '"""post"""'}, {}), "(connection, 'post')", False, 'import mock\n'), ((1685, 5, 1685, 52), 'mock.patch.object', 'mock.patch.object', ({(1685, 23, 1685, 34): 'TaskMonitor', (1685, 36, 1685, 51): '"""wait_for_task"""'}, {}), "(TaskMonitor, 'wait_for_task')", False, 'import mock\n'), ((1697, 5, 1697, 42), 'mock.patch.object', 'mock.patch.object', ({(1697, 23, 1697, 33): 'connection', (1697, 35, 1697, 41): '"""post"""'}, {}), "(connection, 'post')", False, 'import mock\n'), ((1706, 5, 1706, 42), 'mock.patch.object', 'mock.patch.object', ({(1706, 23, 1706, 33): 'connection', (1706, 35, 1706, 41): '"""post"""'}, {}), "(connection, 'post')", False, 'import mock\n'), ((1714, 5, 1714, 42), 'mock.patch.object', 'mock.patch.object', ({(1714, 23, 1714, 33): 'connection', (1714, 35, 1714, 41): '"""post"""'}, {}), "(connection, 'post')", False, 'import mock\n'), ((1723, 5, 1723, 42), 'mock.patch.object', 'mock.patch.object', ({(1723, 23, 1723, 33): 'connection', (1723, 35, 1723, 41): '"""post"""'}, {}), "(connection, 'post')", False, 'import mock\n'), ((1734, 5, 1734, 42), 'mock.patch.object', 'mock.patch.object', ({(1734, 23, 1734, 33): 'connection', (1734, 35, 1734, 41): '"""post"""'}, {}), "(connection, 'post')", False, 'import mock\n'), ((1744, 5, 1744, 42), 'mock.patch.object', 'mock.patch.object', ({(1744, 23, 1744, 33): 'connection', (1744, 35, 1744, 41): '"""post"""'}, {}), "(connection, 'post')", False, 'import mock\n'), ((1753, 5, 1753, 42), 'mock.patch.object', 'mock.patch.object', ({(1753, 23, 1753, 33): 'connection', (1753, 35, 1753, 41): '"""post"""'}, {}), "(connection, 'post')", False, 'import mock\n'), ((1763, 5, 1763, 42), 'mock.patch.object', 'mock.patch.object', ({(1763, 23, 1763, 33): 'connection', (1763, 35, 1763, 41): '"""post"""'}, {}), "(connection, 'post')", False, 'import mock\n'), ((1772, 5, 1772, 42), 'mock.patch.object', 'mock.patch.object', ({(1772, 23, 1772, 33): 'connection', (1772, 35, 1772, 41): '"""post"""'}, {}), "(connection, 'post')", False, 'import mock\n'), ((1773, 5, 1773, 52), 'mock.patch.object', 'mock.patch.object', ({(1773, 23, 1773, 34): 'TaskMonitor', (1773, 36, 1773, 51): '"""wait_for_task"""'}, {}), "(TaskMonitor, 'wait_for_task')", False, 'import mock\n'), ((1790, 5, 1790, 42), 'mock.patch.object', 'mock.patch.object', ({(1790, 23, 1790, 33): 'connection', (1790, 35, 1790, 41): '"""post"""'}, {}), "(connection, 'post')", False, 'import mock\n'), ((1791, 5, 1791, 52), 'mock.patch.object', 'mock.patch.object', ({(1791, 23, 1791, 34): 'TaskMonitor', (1791, 36, 1791, 51): '"""wait_for_task"""'}, {}), "(TaskMonitor, 'wait_for_task')", False, 'import mock\n'), ((1800, 5, 1800, 43), 'mock.patch.object', 'mock.patch.object', ({(1800, 23, 1800, 33): 'connection', (1800, 35, 1800, 42): '"""patch"""'}, {}), "(connection, 'patch')", False, 'import mock\n'), ((1817, 5, 1817, 43), 'mock.patch.object', 'mock.patch.object', ({(1817, 23, 1817, 33): 'connection', (1817, 35, 1817, 42): '"""patch"""'}, {}), "(connection, 'patch')", False, 'import mock\n'), ((1833, 5, 1833, 43), 'mock.patch.object', 'mock.patch.object', ({(1833, 23, 1833, 33): 'connection', (1833, 35, 1833, 42): '"""patch"""'}, {}), "(connection, 'patch')", False, 'import mock\n'), ((1848, 5, 1848, 43), 'mock.patch.object', 'mock.patch.object', ({(1848, 23, 1848, 33): 'connection', (1848, 35, 1848, 42): '"""patch"""'}, {}), "(connection, 'patch')", False, 'import mock\n'), ((1859, 5, 1859, 43), 'mock.patch.object', 'mock.patch.object', ({(1859, 23, 1859, 33): 'connection', (1859, 35, 1859, 42): '"""patch"""'}, {}), "(connection, 'patch')", False, 'import mock\n'), ((1872, 5, 1872, 43), 'mock.patch.object', 'mock.patch.object', ({(1872, 23, 1872, 33): 'connection', (1872, 35, 1872, 42): '"""patch"""'}, {}), "(connection, 'patch')", False, 'import mock\n'), ((1873, 5, 1873, 52), 'mock.patch.object', 'mock.patch.object', ({(1873, 23, 1873, 34): 'TaskMonitor', (1873, 36, 1873, 51): '"""wait_for_task"""'}, {}), "(TaskMonitor, 'wait_for_task')", False, 'import mock\n'), ((1884, 5, 1884, 43), 'mock.patch.object', 'mock.patch.object', ({(1884, 23, 1884, 33): 'connection', (1884, 35, 1884, 42): '"""patch"""'}, {}), "(connection, 'patch')", False, 'import mock\n'), ((1885, 5, 1885, 57), 'mock.patch.object', 'mock.patch.object', ({(1885, 23, 1885, 34): 'TaskMonitor', (1885, 36, 1885, 56): '"""get_completed_task"""'}, {}), "(TaskMonitor, 'get_completed_task')", False, 'import mock\n'), ((1901, 5, 1901, 43), 'mock.patch.object', 'mock.patch.object', ({(1901, 23, 1901, 33): 'connection', (1901, 35, 1901, 42): '"""patch"""'}, {}), "(connection, 'patch')", False, 'import mock\n'), ((1902, 5, 1902, 57), 'mock.patch.object', 'mock.patch.object', ({(1902, 23, 1902, 34): 'TaskMonitor', (1902, 36, 1902, 56): '"""get_completed_task"""'}, {}), "(TaskMonitor, 'get_completed_task')", False, 'import mock\n'), ((1920, 5, 1920, 43), 'mock.patch.object', 'mock.patch.object', ({(1920, 23, 1920, 33): 'connection', (1920, 35, 1920, 42): '"""patch"""'}, {}), "(connection, 'patch')", False, 'import mock\n'), ((1921, 5, 1921, 52), 'mock.patch.object', 'mock.patch.object', ({(1921, 23, 1921, 34): 'TaskMonitor', (1921, 36, 1921, 51): '"""wait_for_task"""'}, {}), "(TaskMonitor, 'wait_for_task')", False, 'import mock\n'), ((1940, 5, 1940, 44), 'mock.patch.object', 'mock.patch.object', ({(1940, 23, 1940, 33): 'connection', (1940, 35, 1940, 43): '"""delete"""'}, {}), "(connection, 'delete')", False, 'import mock\n'), ((2015, 5, 2015, 41), 'mock.patch.object', 'mock.patch.object', ({(2015, 23, 2015, 33): 'connection', (2015, 35, 2015, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((2044, 5, 2044, 41), 'mock.patch.object', 'mock.patch.object', ({(2044, 23, 2044, 33): 'connection', (2044, 35, 2044, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((2058, 5, 2058, 41), 'mock.patch.object', 'mock.patch.object', ({(2058, 23, 2058, 33): 'connection', (2058, 35, 2058, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((2077, 5, 2077, 41), 'mock.patch.object', 'mock.patch.object', ({(2077, 23, 2077, 33): 'connection', (2077, 35, 2077, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((2085, 5, 2085, 41), 'mock.patch.object', 'mock.patch.object', ({(2085, 23, 2085, 33): 'connection', (2085, 35, 2085, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((2198, 5, 2198, 42), 'mock.patch.object', 'mock.patch.object', ({(2198, 23, 2198, 33): 'connection', (2198, 35, 2198, 41): '"""post"""'}, {}), "(connection, 'post')", False, 'import mock\n'), ((2199, 5, 2199, 57), 'mock.patch.object', 'mock.patch.object', ({(2199, 23, 2199, 34): 'TaskMonitor', (2199, 36, 2199, 56): '"""get_completed_task"""'}, {}), "(TaskMonitor, 'get_completed_task')", False, 'import mock\n'), ((2211, 5, 2211, 42), 'mock.patch.object', 'mock.patch.object', ({(2211, 23, 2211, 33): 'connection', (2211, 35, 2211, 41): '"""post"""'}, {}), "(connection, 'post')", False, 'import mock\n'), ((2212, 5, 2212, 57), 'mock.patch.object', 'mock.patch.object', ({(2212, 23, 2212, 34): 'TaskMonitor', (2212, 36, 2212, 56): '"""get_completed_task"""'}, {}), "(TaskMonitor, 'get_completed_task')", False, 'import mock\n'), ((2224, 5, 2224, 42), 'mock.patch.object', 'mock.patch.object', ({(2224, 23, 2224, 33): 'connection', (2224, 35, 2224, 41): '"""post"""'}, {}), "(connection, 'post')", False, 'import mock\n'), ((2225, 5, 2225, 57), 'mock.patch.object', 'mock.patch.object', ({(2225, 23, 2225, 34): 'TaskMonitor', (2225, 36, 2225, 56): '"""get_completed_task"""'}, {}), "(TaskMonitor, 'get_completed_task')", False, 'import mock\n'), ((2241, 5, 2241, 42), 'mock.patch.object', 'mock.patch.object', ({(2241, 23, 2241, 33): 'connection', (2241, 35, 2241, 41): '"""post"""'}, {}), "(connection, 'post')", False, 'import mock\n'), ((2242, 5, 2242, 57), 'mock.patch.object', 'mock.patch.object', ({(2242, 23, 2242, 34): 'TaskMonitor', (2242, 36, 2242, 56): '"""get_completed_task"""'}, {}), "(TaskMonitor, 'get_completed_task')", False, 'import mock\n'), ((2254, 5, 2254, 42), 'mock.patch.object', 'mock.patch.object', ({(2254, 23, 2254, 33): 'connection', (2254, 35, 2254, 41): '"""post"""'}, {}), "(connection, 'post')", False, 'import mock\n'), ((2268, 5, 2268, 42), 'mock.patch.object', 'mock.patch.object', ({(2268, 23, 2268, 33): 'connection', (2268, 35, 2268, 41): '"""post"""'}, {}), "(connection, 'post')", False, 'import mock\n'), ((2303, 5, 2303, 75), 'mock.patch.object', 'mock.patch.object', ({(2303, 23, 2303, 33): 'connection', (2303, 35, 2303, 74): '"""post_multipart_with_response_handling"""'}, {}), "(connection, 'post_multipart_with_response_handling')", False, 'import mock\n'), ((2313, 5, 2313, 75), 'mock.patch.object', 'mock.patch.object', ({(2313, 23, 2313, 33): 'connection', (2313, 35, 2313, 74): '"""post_multipart_with_response_handling"""'}, {}), "(connection, 'post_multipart_with_response_handling')", False, 'import mock\n'), ((2322, 5, 2322, 75), 'mock.patch.object', 'mock.patch.object', ({(2322, 23, 2322, 33): 'connection', (2322, 35, 2322, 74): '"""post_multipart_with_response_handling"""'}, {}), "(connection, 'post_multipart_with_response_handling')", False, 'import mock\n'), ((2323, 5, 2323, 52), 'mock.patch.object', 'mock.patch.object', ({(2323, 23, 2323, 34): 'TaskMonitor', (2323, 36, 2323, 51): '"""wait_for_task"""'}, {}), "(TaskMonitor, 'wait_for_task')", False, 'import mock\n'), ((2324, 5, 2324, 41), 'mock.patch.object', 'mock.patch.object', ({(2324, 23, 2324, 33): 'connection', (2324, 35, 2324, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((2334, 5, 2334, 75), 'mock.patch.object', 'mock.patch.object', ({(2334, 23, 2334, 33): 'connection', (2334, 35, 2334, 74): '"""post_multipart_with_response_handling"""'}, {}), "(connection, 'post_multipart_with_response_handling')", False, 'import mock\n'), ((2335, 5, 2335, 52), 'mock.patch.object', 'mock.patch.object', ({(2335, 23, 2335, 34): 'TaskMonitor', (2335, 36, 2335, 51): '"""wait_for_task"""'}, {}), "(TaskMonitor, 'wait_for_task')", False, 'import mock\n'), ((2345, 5, 2345, 75), 'mock.patch.object', 'mock.patch.object', ({(2345, 23, 2345, 33): 'connection', (2345, 35, 2345, 74): '"""post_multipart_with_response_handling"""'}, {}), "(connection, 'post_multipart_with_response_handling')", False, 'import mock\n'), ((2346, 5, 2346, 52), 'mock.patch.object', 'mock.patch.object', ({(2346, 23, 2346, 34): 'TaskMonitor', (2346, 36, 2346, 51): '"""wait_for_task"""'}, {}), "(TaskMonitor, 'wait_for_task')", False, 'import mock\n'), ((2347, 5, 2347, 41), 'mock.patch.object', 'mock.patch.object', ({(2347, 23, 2347, 33): 'connection', (2347, 35, 2347, 40): '"""get"""'}, {}), "(connection, 'get')", False, 'import mock\n'), ((2360, 5, 2360, 75), 'mock.patch.object', 'mock.patch.object', ({(2360, 23, 2360, 33): 'connection', (2360, 35, 2360, 74): '"""post_multipart_with_response_handling"""'}, {}), "(connection, 'post_multipart_with_response_handling')", False, 'import mock\n'), ((2361, 5, 2361, 52), 'mock.patch.object', 'mock.patch.object', ({(2361, 23, 2361, 34): 'TaskMonitor', (2361, 36, 2361, 51): '"""wait_for_task"""'}, {}), "(TaskMonitor, 'wait_for_task')", False, 'import mock\n'), ((2372, 5, 2372, 56), 'mock.patch.object', 'mock.patch.object', ({(2372, 23, 2372, 33): 'connection', (2372, 35, 2372, 55): '"""download_to_stream"""'}, {}), "(connection, 'download_to_stream')", False, 'import mock\n'), ((2383, 5, 2383, 56), 'mock.patch.object', 'mock.patch.object', ({(2383, 23, 2383, 33): 'connection', (2383, 35, 2383, 55): '"""download_to_stream"""'}, {}), "(connection, 'download_to_stream')", False, 'import mock\n'), ((2396, 5, 2396, 56), 'mock.patch.object', 'mock.patch.object', ({(2396, 23, 2396, 33): 'connection', (2396, 35, 2396, 55): '"""download_to_stream"""'}, {}), "(connection, 'download_to_stream')", False, 'import mock\n'), ((2408, 5, 2408, 56), 'mock.patch.object', 'mock.patch.object', ({(2408, 23, 2408, 33): 'connection', (2408, 35, 2408, 55): '"""download_to_stream"""'}, {}), "(connection, 'download_to_stream')", False, 'import mock\n'), ((84, 26, 84, 54), 'hpOneView.connection.connection', 'connection', ({(84, 37, 84, 48): '"""127.0.0.1"""', (84, 50, 84, 53): '300'}, {}), "('127.0.0.1', 300)", False, 'from hpOneView.connection import connection\n'), ((135, 34, 135, 45), 'mock.Mock', 'mock.Mock', ({}, {}), '()', False, 'import mock\n'), ((148, 29, 148, 40), 'mock.Mock', 'mock.Mock', ({}, {}), '()', False, 'import mock\n'), ((162, 33, 162, 46), 'io.StringIO', 'io.StringIO', ({}, {}), '()', False, 'import io\n'), ((158, 16, 158, 36), 'tests.test_utils.mock_builtin', 'mock_builtin', ({(158, 29, 158, 35): '"""open"""'}, {}), "('open')", False, 'from tests.test_utils import mock_builtin\n'), ((173, 20, 173, 33), 'io.StringIO', 'io.StringIO', ({}, {}), '()', False, 'import io\n'), ((169, 16, 169, 36), 'tests.test_utils.mock_builtin', 'mock_builtin', ({(169, 29, 169, 35): '"""open"""'}, {}), "('open')", False, 'from tests.test_utils import mock_builtin\n'), ((187, 33, 187, 46), 'io.StringIO', 'io.StringIO', ({}, {}), '()', False, 'import io\n'), ((182, 16, 182, 36), 'tests.test_utils.mock_builtin', 'mock_builtin', ({(182, 29, 182, 35): '"""open"""'}, {}), "('open')", False, 'from tests.test_utils import mock_builtin\n'), ((199, 33, 199, 46), 'io.StringIO', 'io.StringIO', ({}, {}), '()', False, 'import io\n'), ((194, 16, 194, 36), 'tests.test_utils.mock_builtin', 'mock_builtin', ({(194, 29, 194, 35): '"""open"""'}, {}), "('open')", False, 'from tests.test_utils import mock_builtin\n'), ((209, 26, 209, 54), 'hpOneView.connection.connection', 'connection', ({(209, 37, 209, 48): '"""127.0.0.1"""', (209, 50, 209, 53): '300'}, {}), "('127.0.0.1', 300)", False, 'from hpOneView.connection import connection\n'), ((315, 26, 315, 54), 'hpOneView.connection.connection', 'connection', ({(315, 37, 315, 48): '"""127.0.0.1"""', (315, 50, 315, 53): '300'}, {}), "('127.0.0.1', 300)", False, 'from hpOneView.connection import connection\n'), ((445, 26, 445, 54), 'hpOneView.connection.connection', 'connection', ({(445, 37, 445, 48): '"""127.0.0.1"""', (445, 50, 445, 53): '300'}, {}), "('127.0.0.1', 300)", False, 'from hpOneView.connection import connection\n'), ((504, 26, 504, 54), 'hpOneView.connection.connection', 'connection', ({(504, 37, 504, 48): '"""127.0.0.1"""', (504, 50, 504, 53): '300'}, {}), "('127.0.0.1', 300)", False, 'from hpOneView.connection import connection\n'), ((517, 26, 517, 54), 'hpOneView.connection.connection', 'connection', ({(517, 37, 517, 48): '"""127.0.0.1"""', (517, 50, 517, 53): '300'}, {}), "('127.0.0.1', 300)", False, 'from hpOneView.connection import connection\n'), ((520, 31, 520, 78), 'hpOneView.resources.resource.ResourceHelper', 'ResourceHelper', ({(520, 46, 520, 54): 'self.URI', (520, 56, 520, 71): 'self.connection', (520, 73, 520, 77): 'None'}, {}), '(self.URI, self.connection, None)', False, 'from hpOneView.resources.resource import ResourceClient, ResourceHelper, ResourceFileHandlerMixin, ResourceZeroBodyMixin, ResourcePatchMixin, ResourceUtilizationMixin, ResourceSchemaMixin, Resource, RESOURCE_CLIENT_INVALID_ID, UNRECOGNIZED_URI, TaskMonitor, RESOURCE_CLIENT_TASK_EXPECTED, RESOURCE_ID_OR_URI_REQUIRED, transform_list_to_dict, extract_id_from_uri, merge_resources, merge_default_values, unavailable_method\n'), ((787, 26, 787, 67), 'hpOneView.resources.resource.ResourceClient', 'ResourceClient', ({(787, 41, 787, 56): 'self.connection', (787, 58, 787, 66): 'self.URI'}, {}), '(self.connection, self.URI)', False, 'from hpOneView.resources.resource import ResourceClient, ResourceHelper, ResourceFileHandlerMixin, ResourceZeroBodyMixin, ResourcePatchMixin, ResourceUtilizationMixin, ResourceSchemaMixin, Resource, RESOURCE_CLIENT_INVALID_ID, UNRECOGNIZED_URI, TaskMonitor, RESOURCE_CLIENT_TASK_EXPECTED, RESOURCE_ID_OR_URI_REQUIRED, transform_list_to_dict, extract_id_from_uri, merge_resources, merge_default_values, unavailable_method\n'), ((1122, 26, 1122, 63), 'hpOneView.resources.resource.merge_resources', 'merge_resources', ({(1122, 42, 1122, 51): 'resource1', (1122, 53, 1122, 62): 'resource2'}, {}), '(resource1, resource2)', False, 'from hpOneView.resources.resource import ResourceClient, ResourceHelper, ResourceFileHandlerMixin, ResourceZeroBodyMixin, ResourcePatchMixin, ResourceUtilizationMixin, ResourceSchemaMixin, Resource, RESOURCE_CLIENT_INVALID_ID, UNRECOGNIZED_URI, TaskMonitor, RESOURCE_CLIENT_TASK_EXPECTED, RESOURCE_ID_OR_URI_REQUIRED, transform_list_to_dict, extract_id_from_uri, merge_resources, merge_default_values, unavailable_method\n'), ((1130, 22, 1130, 80), 'hpOneView.resources.resource.merge_default_values', 'merge_default_values', ({(1130, 43, 1130, 65): '[resource1, resource2]', (1130, 67, 1130, 79): 'default_type'}, {}), '([resource1, resource2], default_type)', False, 'from hpOneView.resources.resource import ResourceClient, ResourceHelper, ResourceFileHandlerMixin, ResourceZeroBodyMixin, ResourcePatchMixin, ResourceUtilizationMixin, ResourceSchemaMixin, Resource, RESOURCE_CLIENT_INVALID_ID, UNRECOGNIZED_URI, TaskMonitor, RESOURCE_CLIENT_TASK_EXPECTED, RESOURCE_ID_OR_URI_REQUIRED, transform_list_to_dict, extract_id_from_uri, merge_resources, merge_default_values, unavailable_method\n'), ((1147, 23, 1147, 65), 'hpOneView.resources.resource.ResourceClient', 'ResourceClient', ({(1147, 38, 1147, 41): 'con', (1147, 43, 1147, 64): '"""/rest/fake/resource"""'}, {}), "(con, '/rest/fake/resource')", False, 'from hpOneView.resources.resource import ResourceClient, ResourceHelper, ResourceFileHandlerMixin, ResourceZeroBodyMixin, ResourcePatchMixin, ResourceUtilizationMixin, ResourceSchemaMixin, Resource, RESOURCE_CLIENT_INVALID_ID, UNRECOGNIZED_URI, TaskMonitor, RESOURCE_CLIENT_TASK_EXPECTED, RESOURCE_ID_OR_URI_REQUIRED, transform_list_to_dict, extract_id_from_uri, merge_resources, merge_default_values, unavailable_method\n'), ((1167, 26, 1167, 52), 'hpOneView.connection.connection', 'connection', ({(1167, 37, 1167, 46): 'self.host', (1167, 48, 1167, 51): '300'}, {}), '(self.host, 300)', False, 'from hpOneView.connection import connection\n'), ((1168, 31, 1168, 72), 'hpOneView.resources.resource.ResourceClient', 'ResourceClient', ({(1168, 46, 1168, 61): 'self.connection', (1168, 63, 1168, 71): 'self.URI'}, {}), '(self.connection, self.URI)', False, 'from hpOneView.resources.resource import ResourceClient, ResourceHelper, ResourceFileHandlerMixin, ResourceZeroBodyMixin, ResourcePatchMixin, ResourceUtilizationMixin, ResourceSchemaMixin, Resource, RESOURCE_CLIENT_INVALID_ID, UNRECOGNIZED_URI, TaskMonitor, RESOURCE_CLIENT_TASK_EXPECTED, RESOURCE_ID_OR_URI_REQUIRED, transform_list_to_dict, extract_id_from_uri, merge_resources, merge_default_values, unavailable_method\n'), ((1622, 26, 1622, 67), 'hpOneView.resources.resource.ResourceClient', 'ResourceClient', ({(1622, 41, 1622, 56): 'self.connection', (1622, 58, 1622, 66): 'self.URI'}, {}), '(self.connection, self.URI)', False, 'from hpOneView.resources.resource import ResourceClient, ResourceHelper, ResourceFileHandlerMixin, ResourceZeroBodyMixin, ResourcePatchMixin, ResourceUtilizationMixin, ResourceSchemaMixin, Resource, RESOURCE_CLIENT_INVALID_ID, UNRECOGNIZED_URI, TaskMonitor, RESOURCE_CLIENT_TASK_EXPECTED, RESOURCE_ID_OR_URI_REQUIRED, transform_list_to_dict, extract_id_from_uri, merge_resources, merge_default_values, unavailable_method\n'), ((1758, 26, 1758, 67), 'hpOneView.resources.resource.ResourceClient', 'ResourceClient', ({(1758, 41, 1758, 56): 'self.connection', (1758, 58, 1758, 66): 'self.URI'}, {}), '(self.connection, self.URI)', False, 'from hpOneView.resources.resource import ResourceClient, ResourceHelper, ResourceFileHandlerMixin, ResourceZeroBodyMixin, ResourcePatchMixin, ResourceUtilizationMixin, ResourceSchemaMixin, Resource, RESOURCE_CLIENT_INVALID_ID, UNRECOGNIZED_URI, TaskMonitor, RESOURCE_CLIENT_TASK_EXPECTED, RESOURCE_ID_OR_URI_REQUIRED, transform_list_to_dict, extract_id_from_uri, merge_resources, merge_default_values, unavailable_method\n'), ((1826, 26, 1826, 67), 'hpOneView.resources.resource.ResourceClient', 'ResourceClient', ({(1826, 41, 1826, 56): 'self.connection', (1826, 58, 1826, 66): 'self.URI'}, {}), '(self.connection, self.URI)', False, 'from hpOneView.resources.resource import ResourceClient, ResourceHelper, ResourceFileHandlerMixin, ResourceZeroBodyMixin, ResourcePatchMixin, ResourceUtilizationMixin, ResourceSchemaMixin, Resource, RESOURCE_CLIENT_INVALID_ID, UNRECOGNIZED_URI, TaskMonitor, RESOURCE_CLIENT_TASK_EXPECTED, RESOURCE_ID_OR_URI_REQUIRED, transform_list_to_dict, extract_id_from_uri, merge_resources, merge_default_values, unavailable_method\n'), ((1863, 26, 1863, 67), 'hpOneView.resources.resource.ResourceClient', 'ResourceClient', ({(1863, 41, 1863, 56): 'self.connection', (1863, 58, 1863, 66): 'self.URI'}, {}), '(self.connection, self.URI)', False, 'from hpOneView.resources.resource import ResourceClient, ResourceHelper, ResourceFileHandlerMixin, ResourceZeroBodyMixin, ResourcePatchMixin, ResourceUtilizationMixin, ResourceSchemaMixin, Resource, RESOURCE_CLIENT_INVALID_ID, UNRECOGNIZED_URI, TaskMonitor, RESOURCE_CLIENT_TASK_EXPECTED, RESOURCE_ID_OR_URI_REQUIRED, transform_list_to_dict, extract_id_from_uri, merge_resources, merge_default_values, unavailable_method\n'), ((1896, 26, 1896, 67), 'hpOneView.resources.resource.ResourceClient', 'ResourceClient', ({(1896, 41, 1896, 56): 'self.connection', (1896, 58, 1896, 66): 'self.URI'}, {}), '(self.connection, self.URI)', False, 'from hpOneView.resources.resource import ResourceClient, ResourceHelper, ResourceFileHandlerMixin, ResourceZeroBodyMixin, ResourcePatchMixin, ResourceUtilizationMixin, ResourceSchemaMixin, Resource, RESOURCE_CLIENT_INVALID_ID, UNRECOGNIZED_URI, TaskMonitor, RESOURCE_CLIENT_TASK_EXPECTED, RESOURCE_ID_OR_URI_REQUIRED, transform_list_to_dict, extract_id_from_uri, merge_resources, merge_default_values, unavailable_method\n'), ((1911, 26, 1911, 67), 'hpOneView.resources.resource.ResourceClient', 'ResourceClient', ({(1911, 41, 1911, 56): 'self.connection', (1911, 58, 1911, 66): 'self.URI'}, {}), '(self.connection, self.URI)', False, 'from hpOneView.resources.resource import ResourceClient, ResourceHelper, ResourceFileHandlerMixin, ResourceZeroBodyMixin, ResourcePatchMixin, ResourceUtilizationMixin, ResourceSchemaMixin, Resource, RESOURCE_CLIENT_INVALID_ID, UNRECOGNIZED_URI, TaskMonitor, RESOURCE_CLIENT_TASK_EXPECTED, RESOURCE_ID_OR_URI_REQUIRED, transform_list_to_dict, extract_id_from_uri, merge_resources, merge_default_values, unavailable_method\n'), ((2273, 26, 2273, 67), 'hpOneView.resources.resource.ResourceClient', 'ResourceClient', ({(2273, 41, 2273, 56): 'self.connection', (2273, 58, 2273, 66): 'self.URI'}, {}), '(self.connection, self.URI)', False, 'from hpOneView.resources.resource import ResourceClient, ResourceHelper, ResourceFileHandlerMixin, ResourceZeroBodyMixin, ResourcePatchMixin, ResourceUtilizationMixin, ResourceSchemaMixin, Resource, RESOURCE_CLIENT_INVALID_ID, UNRECOGNIZED_URI, TaskMonitor, RESOURCE_CLIENT_TASK_EXPECTED, RESOURCE_ID_OR_URI_REQUIRED, transform_list_to_dict, extract_id_from_uri, merge_resources, merge_default_values, unavailable_method\n'), ((2287, 26, 2287, 67), 'hpOneView.resources.resource.ResourceClient', 'ResourceClient', ({(2287, 41, 2287, 56): 'self.connection', (2287, 58, 2287, 66): 'self.URI'}, {}), '(self.connection, self.URI)', False, 'from hpOneView.resources.resource import ResourceClient, ResourceHelper, ResourceFileHandlerMixin, ResourceZeroBodyMixin, ResourcePatchMixin, ResourceUtilizationMixin, ResourceSchemaMixin, Resource, RESOURCE_CLIENT_INVALID_ID, UNRECOGNIZED_URI, TaskMonitor, RESOURCE_CLIENT_TASK_EXPECTED, RESOURCE_ID_OR_URI_REQUIRED, transform_list_to_dict, extract_id_from_uri, merge_resources, merge_default_values, unavailable_method\n'), ((2298, 26, 2298, 67), 'hpOneView.resources.resource.ResourceClient', 'ResourceClient', ({(2298, 41, 2298, 56): 'self.connection', (2298, 58, 2298, 66): 'self.URI'}, {}), '(self.connection, self.URI)', False, 'from hpOneView.resources.resource import ResourceClient, ResourceHelper, ResourceFileHandlerMixin, ResourceZeroBodyMixin, ResourcePatchMixin, ResourceUtilizationMixin, ResourceSchemaMixin, Resource, RESOURCE_CLIENT_INVALID_ID, UNRECOGNIZED_URI, TaskMonitor, RESOURCE_CLIENT_TASK_EXPECTED, RESOURCE_ID_OR_URI_REQUIRED, transform_list_to_dict, extract_id_from_uri, merge_resources, merge_default_values, unavailable_method\n'), ((2350, 34, 2350, 45), 'mock.Mock', 'mock.Mock', ({}, {}), '()', False, 'import mock\n'), ((2363, 29, 2363, 40), 'mock.Mock', 'mock.Mock', ({}, {}), '()', False, 'import mock\n'), ((2377, 33, 2377, 46), 'io.StringIO', 'io.StringIO', ({}, {}), '()', False, 'import io\n'), ((2373, 16, 2373, 36), 'tests.test_utils.mock_builtin', 'mock_builtin', ({(2373, 29, 2373, 35): '"""open"""'}, {}), "('open')", False, 'from tests.test_utils import mock_builtin\n'), ((2388, 20, 2388, 33), 'io.StringIO', 'io.StringIO', ({}, {}), '()', False, 'import io\n'), ((2384, 16, 2384, 36), 'tests.test_utils.mock_builtin', 'mock_builtin', ({(2384, 29, 2384, 35): '"""open"""'}, {}), "('open')", False, 'from tests.test_utils import mock_builtin\n'), ((2402, 33, 2402, 46), 'io.StringIO', 'io.StringIO', ({}, {}), '()', False, 'import io\n'), ((2397, 16, 2397, 36), 'tests.test_utils.mock_builtin', 'mock_builtin', ({(2397, 29, 2397, 35): '"""open"""'}, {}), "('open')", False, 'from tests.test_utils import mock_builtin\n'), ((2414, 33, 2414, 46), 'io.StringIO', 'io.StringIO', ({}, {}), '()', False, 'import io\n'), ((2409, 16, 2409, 36), 'tests.test_utils.mock_builtin', 'mock_builtin', ({(2409, 29, 2409, 35): '"""open"""'}, {}), "('open')", False, 'from tests.test_utils import mock_builtin\n'), ((2423, 27, 2423, 60), 'hpOneView.resources.resource.transform_list_to_dict', 'transform_list_to_dict', (), '', False, 'from hpOneView.resources.resource import ResourceClient, ResourceHelper, ResourceFileHandlerMixin, ResourceZeroBodyMixin, ResourcePatchMixin, ResourceUtilizationMixin, ResourceSchemaMixin, Resource, RESOURCE_CLIENT_INVALID_ID, UNRECOGNIZED_URI, TaskMonitor, RESOURCE_CLIENT_TASK_EXPECTED, RESOURCE_ID_OR_URI_REQUIRED, transform_list_to_dict, extract_id_from_uri, merge_resources, merge_default_values, unavailable_method\n'), ((2435, 23, 2435, 47), 'hpOneView.resources.resource.extract_id_from_uri', 'extract_id_from_uri', ({(2435, 43, 2435, 46): 'uri'}, {}), '(uri)', False, 'from hpOneView.resources.resource import ResourceClient, ResourceHelper, ResourceFileHandlerMixin, ResourceZeroBodyMixin, ResourcePatchMixin, ResourceUtilizationMixin, ResourceSchemaMixin, Resource, RESOURCE_CLIENT_INVALID_ID, UNRECOGNIZED_URI, TaskMonitor, RESOURCE_CLIENT_TASK_EXPECTED, RESOURCE_ID_OR_URI_REQUIRED, transform_list_to_dict, extract_id_from_uri, merge_resources, merge_default_values, unavailable_method\n'), ((2440, 23, 2440, 47), 'hpOneView.resources.resource.extract_id_from_uri', 'extract_id_from_uri', ({(2440, 43, 2440, 46): 'uri'}, {}), '(uri)', False, 'from hpOneView.resources.resource import ResourceClient, ResourceHelper, ResourceFileHandlerMixin, ResourceZeroBodyMixin, ResourcePatchMixin, ResourceUtilizationMixin, ResourceSchemaMixin, Resource, RESOURCE_CLIENT_INVALID_ID, UNRECOGNIZED_URI, TaskMonitor, RESOURCE_CLIENT_TASK_EXPECTED, RESOURCE_ID_OR_URI_REQUIRED, transform_list_to_dict, extract_id_from_uri, merge_resources, merge_default_values, unavailable_method\n'), ((2445, 23, 2445, 47), 'hpOneView.resources.resource.extract_id_from_uri', 'extract_id_from_uri', ({(2445, 43, 2445, 46): 'uri'}, {}), '(uri)', False, 'from hpOneView.resources.resource import ResourceClient, ResourceHelper, ResourceFileHandlerMixin, ResourceZeroBodyMixin, ResourcePatchMixin, ResourceUtilizationMixin, ResourceSchemaMixin, Resource, RESOURCE_CLIENT_INVALID_ID, UNRECOGNIZED_URI, TaskMonitor, RESOURCE_CLIENT_TASK_EXPECTED, RESOURCE_ID_OR_URI_REQUIRED, transform_list_to_dict, extract_id_from_uri, merge_resources, merge_default_values, unavailable_method\n'), ((2451, 23, 2451, 47), 'hpOneView.resources.resource.extract_id_from_uri', 'extract_id_from_uri', ({(2451, 43, 2451, 46): 'uri'}, {}), '(uri)', False, 'from hpOneView.resources.resource import ResourceClient, ResourceHelper, ResourceFileHandlerMixin, ResourceZeroBodyMixin, ResourcePatchMixin, ResourceUtilizationMixin, ResourceSchemaMixin, Resource, RESOURCE_CLIENT_INVALID_ID, UNRECOGNIZED_URI, TaskMonitor, RESOURCE_CLIENT_TASK_EXPECTED, RESOURCE_ID_OR_URI_REQUIRED, transform_list_to_dict, extract_id_from_uri, merge_resources, merge_default_values, unavailable_method\n'), ((92, 49, 92, 60), 'mock.Mock', 'mock.Mock', ({}, {}), '()', False, 'import mock\n'), ((101, 49, 101, 60), 'mock.Mock', 'mock.Mock', ({}, {}), '()', False, 'import mock\n'), ((113, 54, 113, 65), 'mock.Mock', 'mock.Mock', ({}, {}), '()', False, 'import mock\n'), ((124, 49, 124, 60), 'mock.Mock', 'mock.Mock', ({}, {}), '()', False, 'import mock\n'), ((138, 54, 138, 65), 'mock.Mock', 'mock.Mock', ({}, {}), '()', False, 'import mock\n'), ((630, 26, 630, 43), 'mock.call', 'call', ({(630, 31, 630, 42): 'uri_list[0]'}, {}), '(uri_list[0])', False, 'from mock import call\n'), ((630, 45, 630, 62), 'mock.call', 'call', ({(630, 50, 630, 61): 'uri_list[1]'}, {}), '(uri_list[1])', False, 'from mock import call\n'), ((630, 64, 630, 81), 'mock.call', 'call', ({(630, 69, 630, 80): 'uri_list[2]'}, {}), '(uri_list[2])', False, 'from mock import call\n'), ((647, 26, 647, 43), 'mock.call', 'call', ({(647, 31, 647, 42): 'uri_list[0]'}, {}), '(uri_list[0])', False, 'from mock import call\n'), ((647, 45, 647, 62), 'mock.call', 'call', ({(647, 50, 647, 61): 'uri_list[1]'}, {}), '(uri_list[1])', False, 'from mock import call\n'), ((647, 64, 647, 81), 'mock.call', 'call', ({(647, 69, 647, 80): 'uri_list[2]'}, {}), '(uri_list[2])', False, 'from mock import call\n'), ((1242, 26, 1242, 43), 'mock.call', 'call', ({(1242, 31, 1242, 42): 'uri_list[0]'}, {}), '(uri_list[0])', False, 'from mock import call\n'), ((1242, 45, 1242, 62), 'mock.call', 'call', ({(1242, 50, 1242, 61): 'uri_list[1]'}, {}), '(uri_list[1])', False, 'from mock import call\n'), ((1242, 64, 1242, 81), 'mock.call', 'call', ({(1242, 69, 1242, 80): 'uri_list[2]'}, {}), '(uri_list[2])', False, 'from mock import call\n'), ((1259, 26, 1259, 43), 'mock.call', 'call', ({(1259, 31, 1259, 42): 'uri_list[0]'}, {}), '(uri_list[0])', False, 'from mock import call\n'), ((1259, 45, 1259, 62), 'mock.call', 'call', ({(1259, 50, 1259, 61): 'uri_list[1]'}, {}), '(uri_list[1])', False, 'from mock import call\n'), ((1259, 64, 1259, 81), 'mock.call', 'call', ({(1259, 69, 1259, 80): 'uri_list[2]'}, {}), '(uri_list[2])', False, 'from mock import call\n'), ((2307, 49, 2307, 60), 'mock.Mock', 'mock.Mock', ({}, {}), '()', False, 'import mock\n'), ((2316, 49, 2316, 60), 'mock.Mock', 'mock.Mock', ({}, {}), '()', False, 'import mock\n'), ((2328, 54, 2328, 65), 'mock.Mock', 'mock.Mock', ({}, {}), '()', False, 'import mock\n'), ((2339, 49, 2339, 60), 'mock.Mock', 'mock.Mock', ({}, {}), '()', False, 'import mock\n'), ((2353, 54, 2353, 65), 'mock.Mock', 'mock.Mock', ({}, {}), '()', False, 'import mock\n')]