# Path: cloudify/exceptions.py
# class NonRecoverableError(Exception):
# class RecoverableError(Exception):
# class OperationRetry(RecoverableError):
# class HttpException(NonRecoverableError):
# class CommandExecutionError(RuntimeError):
# class CommandExecutionException(Exception):
# class TimeoutException(Exception):
# class ProcessExecutionError(RuntimeError):
# class ClosedAMQPClientException(Exception):
#     def __init__(self, *args, **kwargs):
#     def __init__(self, message='', retry_after=None, causes=None, **kwargs):
#     def __init__(self, url, code, message, causes=None, **kwargs):
#     def __str__(self):
#     def __init__(self, command, error=None):
#     def __str__(self):
#     def __init__(self, command, error, output, code):
#     def __str__(self):
#     def __init__(self, message, error_type=None, traceback=None, causes=None,
#                  **kwargs):
#     def __str__(self):
# 
# Path: cloudify/manager.py
# class NodeInstance(object):
#     """
#     Represents a deployment node instance.
#     An instance of this class contains runtime information retrieved
#     from Cloudify's runtime storage as well as the node's state.
#     """
#     def __init__(self,
#                  node_instance_id,
#                  node_id,
#                  runtime_properties=None,
#                  state=None,
#                  version=None,
#                  host_id=None,
#                  relationships=None):
#         self.id = node_instance_id
#         self._node_id = node_id
#         self._runtime_properties = \
#             DirtyTrackingDict((runtime_properties or {}).copy())
#         self._state = state
#         self._version = version
#         self._host_id = host_id
#         self._relationships = relationships
# 
#     def get(self, key):
#         return self._runtime_properties.get(key)
# 
#     def put(self, key, value):
#         self._runtime_properties[key] = value
# 
#     def delete(self, key):
#         del(self._runtime_properties[key])
# 
#     __setitem__ = put
# 
#     __getitem__ = get
# 
#     __delitem__ = delete
# 
#     def __contains__(self, key):
#         return key in self._runtime_properties
# 
#     @property
#     def runtime_properties(self):
#         """
#         The node instance runtime properties.
# 
#         To update the properties, make changes on the returned dict and call
#         ``update_node_instance`` with the modified instance.
#         """
#         return self._runtime_properties
# 
#     @runtime_properties.setter
#     def runtime_properties(self, new_properties):
#         # notify the old object of the changes - trigger a .modifiable check
#         self._runtime_properties._set_changed()
# 
#         self._runtime_properties = DirtyTrackingDict(new_properties)
#         self._runtime_properties._set_changed()
# 
#     @property
#     def version(self):
#         return self._version
# 
#     @property
#     def state(self):
#         """
#         The node instance state.
# 
#         To update the node instance state, change this property value and
#         call ``update_node_instance`` with the modified instance.
#         """
#         return self._state
# 
#     @state.setter
#     def state(self, value):
#         self._state = value
# 
#     @property
#     def dirty(self):
#         return self._runtime_properties.dirty
# 
#     @property
#     def host_id(self):
#         return self._host_id
# 
#     @property
#     def node_id(self):
#         return self._node_id
# 
#     @property
#     def relationships(self):
#         return self._relationships


import testtools
from cloudify import exceptions
from cloudify.manager import NodeInstance
        self.assertRaises(KeyError, node.delete, 'key')

    def test_delete_makes_properties_dirty(self):
        node = NodeInstance('instance_id', 'node_id',
                            runtime_properties={'preexisting-key': 'val'})
        self.assertFalse(node.dirty)
        del(node['preexisting-key'])
        self.assertTrue(node.dirty)

    def test_setting_runtime_properties(self):
        """Assignment to .runtime_properties is possible and stores them."""
        node = NodeInstance('instance_id', 'node_id',
                            runtime_properties={'preexisting-key': 'val'})
        node.runtime_properties = {'other key': 'other val'}
        self.assertEqual({'other key': 'other val'}, node.runtime_properties)

    def test_setting_runtime_properties_sets_dirty(self):
        """Assignment to .runtime_properties sets the dirty flag."""
        node = NodeInstance('instance_id', 'node_id',
                            runtime_properties={'preexisting-key': 'val'})
        node.runtime_properties = {'other key': 'other val'}
        self.assertTrue(node.runtime_properties.dirty)

    def test_setting_runtime_properties_checks_modifiable(self):
        """Cannot assign to .runtime_properties if modifiable is false."""
        node = NodeInstance('instance_id', 'node_id',
                            runtime_properties={'preexisting-key': 'val'})
        node.runtime_properties.modifiable = False
        try:
            node.runtime_properties = {'other key': 'other val'}

# Path: cloudify/exceptions.py
# class NonRecoverableError(Exception):
# class RecoverableError(Exception):
# class OperationRetry(RecoverableError):
# class HttpException(NonRecoverableError):
# class CommandExecutionError(RuntimeError):
# class CommandExecutionException(Exception):
# class TimeoutException(Exception):
# class ProcessExecutionError(RuntimeError):
# class ClosedAMQPClientException(Exception):
#     def __init__(self, *args, **kwargs):
#     def __init__(self, message='', retry_after=None, causes=None, **kwargs):
#     def __init__(self, url, code, message, causes=None, **kwargs):
#     def __str__(self):
#     def __init__(self, command, error=None):
#     def __str__(self):
#     def __init__(self, command, error, output, code):
#     def __str__(self):
#     def __init__(self, message, error_type=None, traceback=None, causes=None,
#                  **kwargs):
#     def __str__(self):
# 
# Path: cloudify/manager.py
# class NodeInstance(object):
#     """
#     Represents a deployment node instance.
#     An instance of this class contains runtime information retrieved
#     from Cloudify's runtime storage as well as the node's state.
#     """
#     def __init__(self,
#                  node_instance_id,
#                  node_id,
#                  runtime_properties=None,
#                  state=None,
#                  version=None,
#                  host_id=None,
#                  relationships=None):
#         self.id = node_instance_id
#         self._node_id = node_id
#         self._runtime_properties = \
#             DirtyTrackingDict((runtime_properties or {}).copy())
#         self._state = state
#         self._version = version
#         self._host_id = host_id
#         self._relationships = relationships
# 
#     def get(self, key):
#         return self._runtime_properties.get(key)
# 
#     def put(self, key, value):
#         self._runtime_properties[key] = value
# 
#     def delete(self, key):
#         del(self._runtime_properties[key])
# 
#     __setitem__ = put
# 
#     __getitem__ = get
# 
#     __delitem__ = delete
# 
#     def __contains__(self, key):
#         return key in self._runtime_properties
# 
#     @property
#     def runtime_properties(self):
#         """
#         The node instance runtime properties.
# 
#         To update the properties, make changes on the returned dict and call
#         ``update_node_instance`` with the modified instance.
#         """
#         return self._runtime_properties
# 
#     @runtime_properties.setter
#     def runtime_properties(self, new_properties):
#         # notify the old object of the changes - trigger a .modifiable check
#         self._runtime_properties._set_changed()
# 
#         self._runtime_properties = DirtyTrackingDict(new_properties)
#         self._runtime_properties._set_changed()
# 
#     @property
#     def version(self):
#         return self._version
# 
#     @property
#     def state(self):
#         """
#         The node instance state.
# 
#         To update the node instance state, change this property value and
#         call ``update_node_instance`` with the modified instance.
#         """
#         return self._state
# 
#     @state.setter
#     def state(self, value):
#         self._state = value
# 
#     @property
#     def dirty(self):
#         return self._runtime_properties.dirty
# 
#     @property
#     def host_id(self):
#         return self._host_id
# 
#     @property
#     def node_id(self):
#         return self._node_id
# 
#     @property
#     def relationships(self):
#         return self._relationships


# Path: cloudify/tests/test_node_state.py
import testtools
from cloudify import exceptions
from cloudify.manager import NodeInstance

        self.assertRaises(KeyError, node.delete, 'key')

    def test_delete_makes_properties_dirty(self):
        node = NodeInstance('instance_id', 'node_id',
                            runtime_properties={'preexisting-key': 'val'})
        self.assertFalse(node.dirty)
        del(node['preexisting-key'])
        self.assertTrue(node.dirty)

    def test_setting_runtime_properties(self):
        """Assignment to .runtime_properties is possible and stores them."""
        node = NodeInstance('instance_id', 'node_id',
                            runtime_properties={'preexisting-key': 'val'})
        node.runtime_properties = {'other key': 'other val'}
        self.assertEqual({'other key': 'other val'}, node.runtime_properties)

    def test_setting_runtime_properties_sets_dirty(self):
        """Assignment to .runtime_properties sets the dirty flag."""
        node = NodeInstance('instance_id', 'node_id',
                            runtime_properties={'preexisting-key': 'val'})
        node.runtime_properties = {'other key': 'other val'}
        self.assertTrue(node.runtime_properties.dirty)

    def test_setting_runtime_properties_checks_modifiable(self):
        """Cannot assign to .runtime_properties if modifiable is false."""
        node = NodeInstance('instance_id', 'node_id',
                            runtime_properties={'preexisting-key': 'val'})
        node.runtime_properties.modifiable = False
        try:
            node.runtime_properties = {'other key': 'other val'}

        except exceptions.NonRecoverableError: