# 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

@pytest.fixture
def CreateSaveSideEffect(F5SysSave):
    F5SysSave.get_bigip()
    F5SysSave.bigip.tm.sys.config.exec_cmd.side_effect = Exception()
    return F5SysSave


# Tests


def test_handle_create(F5SysSave):
    create_result = F5SysSave.handle_create()
    assert create_result is None
    assert F5SysSave.bigip.tm.sys.config.exec_cmd.call_args == \
        mock.call('save')


def test_handle_create_error(CreateSaveSideEffect):
    '''Currently, test exists to satisfy 100% code coverage.'''
    with pytest.raises(exception.ResourceFailure):
        CreateSaveSideEffect.handle_create()


def test_handle_delete(F5SysSave):
    delete_result = F5SysSave.handle_delete()
    assert delete_result is True


def test_resource_mapping():

# 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


@pytest.fixture
def CreateSaveSideEffect(F5SysSave):
    F5SysSave.get_bigip()
    F5SysSave.bigip.tm.sys.config.exec_cmd.side_effect = Exception()
    return F5SysSave


# Tests


def test_handle_create(F5SysSave):
    create_result = F5SysSave.handle_create()
    assert create_result is None
    assert F5SysSave.bigip.tm.sys.config.exec_cmd.call_args == \
        mock.call('save')


def test_handle_create_error(CreateSaveSideEffect):
    '''Currently, test exists to satisfy 100% code coverage.'''
    with pytest.raises(exception.ResourceFailure):
        CreateSaveSideEffect.handle_create()


def test_handle_delete(F5SysSave):
    delete_result = F5SysSave.handle_delete()
    assert delete_result is True


def test_resource_mapping():

    rsrc_map = f5_sys_save.resource_mapping()