示例#1
0
def tearDown(**kwargs):
    """
       tearDown basic test environment with database
       proxy to paramid.testing.tearDown(**kwargs)
    """
    graph = get_graph()
    tx = graph.start_transaction()
    graph.clear()
    graph.stop_transaction(tx)
    testing.tearDown(**kwargs)
示例#2
0
def adhocracyroot_factory():
    graph = get_graph()
    root = graph.get_root_vertex()
    if not IAdhocracyRootMarker.providedBy(root):
        tx = graph.start_transaction()
        root.set_property("main_interface",\
                IAdhocracyRootMarker.__identifier__)
        directlyProvides(root, IAdhocracyRootMarker)
        graph.stop_transaction(tx)
    return root
示例#3
0
def tearDown(**kwargs):
    """
       tearDown basic test environment with database
       proxy to paramid.testing.tearDown(**kwargs)
    """
    graph = get_graph()
    tx = graph.start_transaction()
    graph.clear()
    graph.stop_transaction(tx)
    testing.tearDown(**kwargs)
示例#4
0
 def __delitem__(self, key):
     edges = filter(lambda edge: IChild(edge).child_name == key,\
                                 self.context.in_edges("child"))
     if len(edges) == 1:
         edge = edges[0]
         graph = get_graph()
         graph.remove_edge(edge)
     elif len(edges) == 0:
         raise KeyError
     else:
         raise KeyError("multiple child nodes with key %s" % (key))
    def setUp(self, **kwargs):
        tools = setUpFunctional()
        self.browser = tools["browser"]
        self.app = tools["app"]
        self.root = self.app.root_factory(None)

        from adhocracy.dbgraph.embeddedgraph import get_graph
        self.graph = get_graph()
        global_registry = component.getGlobalSiteManager()
        from adhocracy.core.models.relations import NodeChildsDictAdapter
        global_registry.registerAdapter(NodeChildsDictAdapter)

        from repoze.lemonade.testing import registerContentFactory
        from adhocracy.core.models.references import child_factory
        from adhocracy.core.models.references import IChildMarker
        registerContentFactory(child_factory, IChildMarker)

        from adhocracy.core.models.container import container_factory
        from adhocracy.core.models.container import IContainerMarker
        registerContentFactory(container_factory, IContainerMarker)

        from adhocracy.core.models.references import Child
        global_registry.registerAdapter(Child)
    def setUp(self, **kwargs):
        tools = setUpFunctional()
        self.browser = tools["browser"]
        self.app = tools["app"]
        self.root = self.app.root_factory(None)

        from adhocracy.dbgraph.embeddedgraph import get_graph
        self.graph = get_graph()
        global_registry = component.getGlobalSiteManager()
        from adhocracy.core.models.relations import NodeChildsDictAdapter
        global_registry.registerAdapter(NodeChildsDictAdapter)

        from repoze.lemonade.testing import registerContentFactory
        from adhocracy.core.models.references import child_factory
        from adhocracy.core.models.references import IChildMarker
        registerContentFactory(child_factory, IChildMarker)

        from adhocracy.core.models.container import container_factory
        from adhocracy.core.models.container import IContainerMarker
        registerContentFactory(container_factory, IContainerMarker)

        from adhocracy.core.models.references import Child
        global_registry.registerAdapter(Child)
示例#7
0
def container_factory():
    graph = get_graph()
    content = graph.add_vertex(IContainerMarker)
    return content
示例#8
0
def child_factory(child, parent, child_name):
    graph = get_graph()
    content = graph.add_edge(child, parent, "child", \
                             main_interface=IChildMarker)
    content.set_property("child_name", child_name)
    return content