# Path: f5_heat/resources/f5_sys_save.py
# class F5SysSave(resource.Resource, F5BigIPMixin):
#     PROPERTIES = (
#         BIGIP_SERVER
#     ) = (
#         'bigip_server'
#     )
#     def handle_create(self):
#     def handle_delete(self):
# def resource_mapping():


from f5_heat.resources import f5_sys_save
from heat.common import exception
from heat.common import template_format
from heat.engine.hot.template import HOTemplate20150430
from heat.engine import rsrc_defn
from heat.engine import template
import mock
import pytest
versions = ('2015-04-30', '2015-04-30')


@mock.patch.object(template, 'get_version', return_value=versions)
@mock.patch.object(
    template,
    'get_template_class',
    return_value=HOTemplate20150430
)
def mock_template(templ_vers, templ_class, test_templ=save_defn):
    '''Mock a Heat template for the Kilo version.'''
    templ_dict = template_format.parse(test_templ)
    return templ_dict


def create_resource_definition(templ_dict):
    '''Create resource definition.'''
    rsrc_def = rsrc_defn.ResourceDefinition(
        'test_stack',
        templ_dict['resources']['save_rsrc']['type'],
        properties=templ_dict['resources']['save_rsrc']['properties']
    )
    return rsrc_def


@pytest.fixture
def F5SysSave():
    '''Instantiate the F5SysSave resource.'''
    template_dict = mock_template()
    rsrc_def = create_resource_definition(template_dict)

# Path: f5_heat/resources/f5_sys_save.py
# class F5SysSave(resource.Resource, F5BigIPMixin):
#     PROPERTIES = (
#         BIGIP_SERVER
#     ) = (
#         'bigip_server'
#     )
#     def handle_create(self):
#     def handle_delete(self):
# def resource_mapping():


# Path: f5_heat/resources/test/test_f5_sys_save.py
from f5_heat.resources import f5_sys_save
from heat.common import exception
from heat.common import template_format
from heat.engine.hot.template import HOTemplate20150430
from heat.engine import rsrc_defn
from heat.engine import template
import mock
import pytest

versions = ('2015-04-30', '2015-04-30')


@mock.patch.object(template, 'get_version', return_value=versions)
@mock.patch.object(
    template,
    'get_template_class',
    return_value=HOTemplate20150430
)
def mock_template(templ_vers, templ_class, test_templ=save_defn):
    '''Mock a Heat template for the Kilo version.'''
    templ_dict = template_format.parse(test_templ)
    return templ_dict


def create_resource_definition(templ_dict):
    '''Create resource definition.'''
    rsrc_def = rsrc_defn.ResourceDefinition(
        'test_stack',
        templ_dict['resources']['save_rsrc']['type'],
        properties=templ_dict['resources']['save_rsrc']['properties']
    )
    return rsrc_def


@pytest.fixture
def F5SysSave():
    '''Instantiate the F5SysSave resource.'''
    template_dict = mock_template()
    rsrc_def = create_resource_definition(template_dict)

    return f5_sys_save.F5SysSave(