Пример #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)
Пример #2
0
    def test_wrapped_no_responses(self):
        self.root_node = tree.xml_string_to_tree(test_no_responses_xml)
        wrap_response_elements(self.root_node)

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

        names = [c.attributes.get("name", None) for c in responses.children]
        self.assertIn("foo", names)
        self.assertIn("bar", names)