# Path: cloudify_deployment_proxy/tests/base.py
# class DeploymentProxyTestBase(testtools.TestCase):
# 
#     def tearDown(self):
#         current_ctx.clear()
#         super(DeploymentProxyTestBase, self).tearDown()
# 
#     def get_mock_ctx(self,
#                      test_name,
#                      test_properties=DEPLOYMENT_PROXY_PROPS,
#                      node_type=DEPLOYMENT_PROXY_TYPE,
#                      retry_number=0):
# 
#         test_node_id = test_name
#         test_properties = test_properties
# 
#         operation = json.loads(json.dumps({
#             'retry_number': retry_number
#         }))
#         ctx = MockCloudifyContext(
#             node_id=test_node_id,
#             deployment_id=test_name,
#             operation=operation,
#             properties=test_properties
#         )
# 
#         ctx.operation._operation_context = json.loads(json.dumps(
#             {'name': 'some.test'}))
#         ctx.node.type_hierarchy = \
#             json.loads(json.dumps(['cloudify.nodes.Root', node_type]))
#         try:
#             ctx.node.type = node_type
#         except AttributeError:
#             ctx.logger.error('Failed to set node type attribute.')
# 
#         return ctx


import tempfile
import os
import cloudify_deployment_proxy.utils as utils
from cloudify.state import current_ctx
from .base import DeploymentProxyTestBase
# 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.




class TestUtils(DeploymentProxyTestBase):

    def test_zip_files(self):
        _ctx = self.get_mock_ctx(__name__)
        current_ctx.set(_ctx)
        fd, destination = tempfile.mkstemp()
        os.close(fd)
        zip_file = utils.zip_files([destination])
        self.assertTrue(zip_file)
        os.remove(zip_file)
        os.remove(destination)

    def test_get_local_path_local(self):
        _ctx = self.get_mock_ctx(__name__)
        current_ctx.set(_ctx)
        fd, destination = tempfile.mkstemp()
        os.close(fd)
        copy_file = utils.get_local_path(destination, create_temp=True)
        self.assertTrue(copy_file)
        os.remove(copy_file)
        os.remove(destination)


# Path: cloudify_deployment_proxy/tests/base.py
# class DeploymentProxyTestBase(testtools.TestCase):
# 
#     def tearDown(self):
#         current_ctx.clear()
#         super(DeploymentProxyTestBase, self).tearDown()
# 
#     def get_mock_ctx(self,
#                      test_name,
#                      test_properties=DEPLOYMENT_PROXY_PROPS,
#                      node_type=DEPLOYMENT_PROXY_TYPE,
#                      retry_number=0):
# 
#         test_node_id = test_name
#         test_properties = test_properties
# 
#         operation = json.loads(json.dumps({
#             'retry_number': retry_number
#         }))
#         ctx = MockCloudifyContext(
#             node_id=test_node_id,
#             deployment_id=test_name,
#             operation=operation,
#             properties=test_properties
#         )
# 
#         ctx.operation._operation_context = json.loads(json.dumps(
#             {'name': 'some.test'}))
#         ctx.node.type_hierarchy = \
#             json.loads(json.dumps(['cloudify.nodes.Root', node_type]))
#         try:
#             ctx.node.type = node_type
#         except AttributeError:
#             ctx.logger.error('Failed to set node type attribute.')
# 
#         return ctx


# Path: cloudify_deployment_proxy/tests/test_utils.py
import tempfile
import os
import cloudify_deployment_proxy.utils as utils
from cloudify.state import current_ctx
from .base import DeploymentProxyTestBase

# 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.




class TestUtils(DeploymentProxyTestBase):

    def test_zip_files(self):
        _ctx = self.get_mock_ctx(__name__)
        current_ctx.set(_ctx)
        fd, destination = tempfile.mkstemp()
        os.close(fd)
        zip_file = utils.zip_files([destination])
        self.assertTrue(zip_file)
        os.remove(zip_file)
        os.remove(destination)

    def test_get_local_path_local(self):
        _ctx = self.get_mock_ctx(__name__)
        current_ctx.set(_ctx)
        fd, destination = tempfile.mkstemp()
        os.close(fd)
        copy_file = utils.get_local_path(destination, create_temp=True)
        self.assertTrue(copy_file)
        os.remove(copy_file)
        os.remove(destination)


    def test_get_local_path_https(self):