# Path: cloudify_resources/tasks.py
# def _refresh_source_and_target_runtime_props(ctx, **kwargs):
# def _update_source_and_target_runtime_props(ctx, **kwargs):
# def create_list(ctx, **kwargs):
# def create_list_item(ctx, **kwargs):
# def delete_list_item(ctx, **kwargs):
# def delete_list(ctx, **kwargs):
# def reserve_list_item(ctx, **kwargs):
# def return_list_item(ctx, **kwargs):
# 
# Path: cloudify_resources/constants.py
# RESOURCES_LIST_PROPERTY = 'resource_config'
# 
# FREE_RESOURCES_LIST_PROPERTY = 'free_resources'
# 
# RESERVATIONS_PROPERTY = 'reservations'
# 
# SINGLE_RESERVATION_PROPERTY = 'reservation'


import unittest
from cloudify.state import current_ctx
from cloudify.mocks import (
    MockCloudifyContext,
    MockNodeContext,
    MockNodeInstanceContext,
    MockRelationshipContext,
    MockRelationshipSubjectContext
)
from cloudify_resources import tasks
from cloudify_resources.constants import (
    RESOURCES_LIST_PROPERTY,
    FREE_RESOURCES_LIST_PROPERTY,
    RESERVATIONS_PROPERTY,
    SINGLE_RESERVATION_PROPERTY
)
    def test_create_delete_resources_list(self):
        ctx = self._mock_resource_list_ctx()

        # when (create)
        tasks.create_list(ctx)

        # then (create)
        self.assertTrue(
            RESOURCES_LIST_PROPERTY in ctx.instance.runtime_properties)
        self.assertTrue(
            FREE_RESOURCES_LIST_PROPERTY in ctx.instance.runtime_properties)
        self.assertTrue(
            RESERVATIONS_PROPERTY in ctx.instance.runtime_properties)

        self.assertEquals(
            ctx.instance.runtime_properties[RESOURCES_LIST_PROPERTY],
            ctx.node.properties['resource_config']
        )

        self.assertEquals(
            ctx.instance.runtime_properties[FREE_RESOURCES_LIST_PROPERTY],
            ctx.instance.runtime_properties[RESOURCES_LIST_PROPERTY]
        )

        self.assertEquals(
            ctx.instance.runtime_properties[RESERVATIONS_PROPERTY],
            {}
        )

        # when (delete)

# Path: cloudify_resources/tasks.py
# def _refresh_source_and_target_runtime_props(ctx, **kwargs):
# def _update_source_and_target_runtime_props(ctx, **kwargs):
# def create_list(ctx, **kwargs):
# def create_list_item(ctx, **kwargs):
# def delete_list_item(ctx, **kwargs):
# def delete_list(ctx, **kwargs):
# def reserve_list_item(ctx, **kwargs):
# def return_list_item(ctx, **kwargs):
# 
# Path: cloudify_resources/constants.py
# RESOURCES_LIST_PROPERTY = 'resource_config'
# 
# FREE_RESOURCES_LIST_PROPERTY = 'free_resources'
# 
# RESERVATIONS_PROPERTY = 'reservations'
# 
# SINGLE_RESERVATION_PROPERTY = 'reservation'


# Path: cloudify_resources/tests/test_tasks.py
import unittest
from cloudify.state import current_ctx
from cloudify.mocks import (
    MockCloudifyContext,
    MockNodeContext,
    MockNodeInstanceContext,
    MockRelationshipContext,
    MockRelationshipSubjectContext
)
from cloudify_resources import tasks
from cloudify_resources.constants import (
    RESOURCES_LIST_PROPERTY,
    FREE_RESOURCES_LIST_PROPERTY,
    RESERVATIONS_PROPERTY,
    SINGLE_RESERVATION_PROPERTY
)

    def test_create_delete_resources_list(self):
        ctx = self._mock_resource_list_ctx()

        # when (create)
        tasks.create_list(ctx)

        # then (create)
        self.assertTrue(
            RESOURCES_LIST_PROPERTY in ctx.instance.runtime_properties)
        self.assertTrue(
            FREE_RESOURCES_LIST_PROPERTY in ctx.instance.runtime_properties)
        self.assertTrue(
            RESERVATIONS_PROPERTY in ctx.instance.runtime_properties)

        self.assertEquals(
            ctx.instance.runtime_properties[RESOURCES_LIST_PROPERTY],
            ctx.node.properties['resource_config']
        )

        self.assertEquals(
            ctx.instance.runtime_properties[FREE_RESOURCES_LIST_PROPERTY],
            ctx.instance.runtime_properties[RESOURCES_LIST_PROPERTY]
        )

        self.assertEquals(
            ctx.instance.runtime_properties[RESERVATIONS_PROPERTY],
            {}
        )

        # when (delete)

        tasks.delete_list(ctx)