Example #1
0
def execute_translations(ir, filename, samples_path):
    """Execute the translations against the IR"""

    # collapse nested resources into just the leaf node
    collapse_resources(ir)

    # resolve the internal references in the tree
    resolve_internal(ir)

    # make sure all the code elements are wrapped in samples
    wrap_code_elements(ir)

    # resolve the external code references
    path = os.path.abspath(os.path.dirname(filename))
    resolve_external_code(path, ir, samples_path)

    # make the resources children of the methods
    invert_method(ir)

    # make sure the param nodes have good parents
    wrap_param_elements(ir)

    # make sure the response nodes have good parents
    wrap_response_elements(ir)

    # remove any resource type nodes
    cleanup_application_node(ir)
    def test_wrapped_no_params(self):
        self.root_node = tree.xml_string_to_tree(test_no_params_xml)
        wrap_param_elements(self.root_node)

        parameters = self.root_node.find_first("params")
        self.assertTrue(parameters is not None)

        names = [c.attributes.get("name", None) for c in parameters.children]
        self.assertIn("foo", names)
        self.assertIn("bar", names)
    def test_wrapped_no_params(self):
        self.root_node = tree.xml_string_to_tree(test_no_params_xml)
        wrap_param_elements(self.root_node)

        parameters = self.root_node.find_first("params")
        self.assertTrue(parameters is not None)

        names = [c.attributes.get("name", None) for c in parameters.children]
        self.assertIn("foo", names)
        self.assertIn("bar", names)
Example #4
0
def execute_translations(ir, filename):
    """Execute the translations against the IR"""

    # collapse nested resources into just the leaf node
    collapse_resources(ir)

    # resolve the internal references in the tree
    resolve_internal(ir)

    # resolve the external code references
    path = os.path.abspath(os.path.dirname(filename))
    resolve_external_code(path, ir)

    # make the resources children of the methods
    invert_method(ir)

    # make sure the param nodes have good parents
    wrap_param_elements(ir)

    # make sure the response nodes have good parents
    wrap_response_elements(ir)

    # remove any resource type nodes
    cleanup_application_node(ir)