def merge_relationship_type_interfaces(overriding_relationship_type,
                                       overridden_relationship_type):
    # using this pattern for the sake of
    # code coverage tools

    overriding_source_interfaces = overriding_relationship_type.get(
        SOURCE_INTERFACES)
    if not overriding_source_interfaces:
        overriding_source_interfaces = {}

    overridden_source_interfaces = overridden_relationship_type.get(
        SOURCE_INTERFACES)
    if not overridden_source_interfaces:
        overridden_source_interfaces = {}

    overriding_target_interfaces = overriding_relationship_type.get(
        TARGET_INTERFACES)
    if not overriding_target_interfaces:
        overriding_target_interfaces = {}

    overridden_target_interfaces = overridden_relationship_type.get(
        TARGET_INTERFACES)
    if not overridden_target_interfaces:
        overridden_target_interfaces = {}

    source_interfaces_merger = InterfacesMerger(
        overriding_interfaces=overriding_source_interfaces,
        overridden_interfaces=overridden_source_interfaces,
        operation_merger=RelationshipTypeRelationshipTypeOperationMerger
    )
    target_interfaces_merger = InterfacesMerger(
        overriding_interfaces=overriding_target_interfaces,
        overridden_interfaces=overridden_target_interfaces,
        operation_merger=RelationshipTypeRelationshipTypeOperationMerger
    )

    merged_source_interfaces = source_interfaces_merger.merge()
    merged_target_interfaces = target_interfaces_merger.merge()

    for interface_name, interface in merged_source_interfaces.iteritems():
        validate_operations_executor(interface, interface_name)

    for interface_name, interface in merged_target_interfaces.iteritems():
        validate_operations_executor(interface, interface_name)

    return {
        SOURCE_INTERFACES: merged_source_interfaces,
        TARGET_INTERFACES: merged_target_interfaces
    }
Example #2
0
    def _assert_interfaces(self, overriding_interfaces, overridden_interfaces,
                           expected_merged_interfaces_keys):
        class MockOperationMerger(OperationMerger):
            def __init__(self, overriding_operation, overridden_operation):
                pass

            def merge(self):
                return None

        merger = InterfacesMerger(overriding_interfaces=overriding_interfaces,
                                  overridden_interfaces=overridden_interfaces,
                                  operation_merger=MockOperationMerger)
        actual_merged_interfaces_keys = set(merger.merge().keys())
        self.assertEqual(expected_merged_interfaces_keys,
                         actual_merged_interfaces_keys)
def merge_relationship_type_and_instance_interfaces(
        relationship_type_interfaces, relationship_instance_interfaces):
    return InterfacesMerger(
        overriding_interfaces=relationship_instance_interfaces,
        overridden_interfaces=relationship_type_interfaces,
        operation_merger=RelationshipTypeRelationshipInstanceOperationMerger
    ).merge()
def merge_relationship_type_interfaces(overriding_interfaces,
                                       overridden_interfaces):
    return InterfacesMerger(
        overriding_interfaces=overriding_interfaces,
        overridden_interfaces=overridden_interfaces,
        operation_merger=RelationshipTypeRelationshipTypeOperationMerger
    ).merge()
    def _assert_interfaces(self,
                           overriding_interfaces,
                           overridden_interfaces,
                           expected_merged_interfaces_keys):

        class MockOperationMerger(OperationMerger):

            def __init__(self,
                         overriding_operation,
                         overridden_operation):
                pass

            def merge(self):
                return None

        merger = InterfacesMerger(
            overriding_interfaces=overriding_interfaces,
            overridden_interfaces=overridden_interfaces,
            operation_merger=MockOperationMerger
        )
        actual_merged_interfaces_keys = set(merger.merge().keys())
        self.assertEqual(expected_merged_interfaces_keys,
                         actual_merged_interfaces_keys)
def merge_node_type_and_node_template_interfaces(node_type,
                                                 node_template):

    # using this pattern for the sake of
    # code coverage tools

    overriding_interfaces = node_template.get(INTERFACES)
    if not overriding_interfaces:
        overriding_interfaces = {}

    overridden_interfaces = node_type.get(INTERFACES)
    if not overridden_interfaces:
        overridden_interfaces = {}

    merger = InterfacesMerger(
        overriding_interfaces=overriding_interfaces,
        overridden_interfaces=overridden_interfaces,
        operation_merger=NodeTemplateNodeTypeOperationMerger
    )
    merged_interfaces = merger.merge()
    for interface_name, interface in merged_interfaces.iteritems():
        validate_operations_executor(interface, interface_name)
    return merged_interfaces
def merge_node_type_and_node_template_interfaces(node_type_interfaces,
                                                 node_template_interfaces):
    return InterfacesMerger(
        overriding_interfaces=node_template_interfaces,
        overridden_interfaces=node_type_interfaces,
        operation_merger=NodeTemplateNodeTypeOperationMerger).merge()
def merge_node_type_interfaces(overriding_interfaces, overridden_interfaces):
    return InterfacesMerger(
        overriding_interfaces=overriding_interfaces,
        overridden_interfaces=overridden_interfaces,
        operation_merger=NodeTypeNodeTypeOperationMerger).merge()