def test_it(self):
        from statics.configuration import query_script
        from statics.configuration import add_script

        class Script(object):
            pass

        add_script("name", Script)
        self.assertEqual(query_script("name"), Script)
        self.assertEqual(query_script("name2"), None)
Beispiel #2
0
def build(site, root, locations=None):
    """ Build `site`."""
    if locations is None:
        locations = site.locations # pragma: nocover
    if not "/" in [l for l, c, s in locations]:
        raise ValueError("No script found for root (/) location.")

    builded = []
    for location, script_config, script_name in ordered_locations(locations):
        view = TreeView(root,
            exclude=[l for l, n, c in locations if not l == location])
        item = view.locate(location)
        script = query_script(script_name)
        if script is None:
            raise ValueError("No script registered for name '%s'" % script_name)
        builded.append((location, script(site, script_config, item)))

    root_element = builded.pop()[1]
    for location, element in reversed(builded):
        root_element.setlocation(location, element)

    return root_element