Ejemplo n.º 1
0
    def parse(self):
        """ Parse the RAML file and return the InternalNode hierarchy from it """
        description = prp.load(self.file)

        root = InternalNode("", None)

        if '/' in description.resources:
            res = description.resources['/']
            del description.resources['/']

            if res is not None:
                #FIXME: this duplicate code from _parse_resource
                if res.methods is not None:
                    for method in res.methods:
                        root.add_method(method)

                root.set_doc(res.description)

        if description.resources is not None:
            for name in description.resources:
                res = description.resources[name]
                self._parse_resource(root, name, res)

        return root
Ejemplo n.º 2
0
    def test_add_method(self):
        name = "james_bond"
        node = InternalNode(name, None)

        self.assertEqual(node.methods, [])

        node.add_method("get")
        self.assertEqual(node.methods, [InternalMethod("GET")])

        #test idempotent
        node.add_method("get")
        self.assertEqual(node.methods, [InternalMethod("GET")])

        node.add_method("put")
        self.assertEqual(node.methods,
                         [InternalMethod("GET"),
                          InternalMethod("PUT")])