def test_pd_has_at_gnxs_node(self): c, pd = self.c, self.c.persistenceController # Set up the tree. root = self.root_p root.h = '@auto root' # Make root look like an @auto node. inner_clone = root.insertAsLastChild() inner_clone.h = 'clone' outer_clone = inner_clone.clone() outer_clone.moveAfter(root) # Test the tree. persistence = g.findNodeAnywhere(c, '@persistence') assert persistence assert pd.has_at_persistence_node() # Update the tree. persistence.deleteAllChildren() # Required assert persistence pd.update_before_write_foreign_file(root) data = g.findNodeInTree(c, persistence, '@data:@auto root') assert data data2 = pd.has_at_data_node(root) assert data2 self.assertEqual(data, data2, (data, data2)) gnxs = g.findNodeInTree(c, persistence, '@gnxs') assert gnxs gnxs2 = pd.has_at_gnxs_node(root) assert gnxs2 self.assertEqual(gnxs, gnxs2, (gnxs, gnxs2))
def findNode(self, c, p, headline): """Return the node in p's subtree with given headline.""" p = g.findNodeInTree(c, p, headline) if not p: g.es_print('can not find', headline) assert False return p
def findNode(self,c,p,headline): '''Return the node in p's subtree with given headline.''' p = g.findNodeInTree(c,p,headline) if not p: g.es_print('can not find',headline) assert False return p
def find_node(self, headline): '''Return the node whose headline is given.''' c = self.c if self.root: p = g.findNodeInTree(c, self.root, headline) else: p = g.findNodeAnywhere(c, headline) return p
def has_at_uas_node(self, root): """ Find the @uas node for an @data node with the given unl. Return None if it does not exist. """ if self.at_persistence: p = self.has_at_data_node(root) return p and g.findNodeInTree(self.c, p, '@uas') return None
def has_at_gnxs_node(self, root): ''' Find the @gnxs node for an @data node with the given unl. Return None if it does not exist. ''' if self.at_persistence: p = self.has_at_data_node(root) return p and g.findNodeInTree(self.c, p, '@gnxs') return None
def has_at_uas_node(self,root): ''' Find the @uas node for an @data node with the given unl. Return None if it does not exist. ''' if self.at_persistence: p = self.has_at_data_node(root) return p and g.findNodeInTree(self.c,p,'@uas') else: return None
def has_at_gnxs_node(self,root): ''' Find the @gnxs node for an @data node with the given unl. Return None if it does not exist. ''' if self.enabled: p = self.has_at_data_node(root) return p and g.findNodeInTree(self.c,p,'@gnxs') else: return None
def find_at_gnxs_node(self,root): ''' Find the @gnxs node for root, a foreign node. Create the @gnxs node if it does not exist. ''' h = '@gnxs' data = self.find_at_data_node(root) p = g.findNodeInTree(self.c,data,h) if not p and self.enabled: p = data.insertAsLastChild() p.h = h return p
def find_at_uas_node(self,root): ''' Find the @uas node for root, a foreign node. Create the @uas node if it does not exist. ''' h = '@uas' auto_view = self.find_at_data_node(root) p = g.findNodeInTree(self.c,auto_view,h) if not p and self.enabled: p = auto_view.insertAsLastChild() p.h = h return p
def test_pd_update_before_write_foreign_file(self): c, pd = self.c, self.c.persistenceController root = self.root_p assert root persistence = pd.find_at_persistence_node() assert persistence persistence.deleteAllChildren() root.h = '@auto root' # Make root look like an @auto node. pd.update_before_write_foreign_file(root) data = g.findNodeAnywhere(c, '@data:@auto root') assert data gnxs = g.findNodeInTree(c, data, '@gnxs') assert gnxs
def find_at_uas_node(self, root): """ Find the @uas node for root, a foreign node. Create the @uas node if it does not exist. """ h = '@uas' if not self.at_persistence: return None auto_view = self.find_at_data_node(root) p = g.findNodeInTree(self.c, auto_view, h) if not p: p = auto_view.insertAsLastChild() p.h = h return p
def find_at_gnxs_node(self, root): """ Find the @gnxs node for root, a foreign node. Create the @gnxs node if it does not exist. """ h = '@gnxs' if not self.at_persistence: return None data = self.find_at_data_node(root) p = g.findNodeInTree(self.c, data, h) if not p: p = data.insertAsLastChild() p.h = h return p
def find_at_gnxs_node(self,root): ''' Find the @gnxs node for root, a foreign node. Create the @gnxs node if it does not exist. ''' h = '@gnxs' if not self.at_persistence: return None data = self.find_at_data_node(root) p = g.findNodeInTree(self.c,data,h) if not p: p = data.insertAsLastChild() p.h = h return p
def runLegacyTest(self, c, p): '''run a legacy rst test.''' rc = c.rstCommands fn = p.h source_p = g.findNodeInTree(c, p, 'source') # source_s1 = source_p.firstChild().b expected_p = g.findNodeInTree(c, p, 'expected') expected_source = expected_p.firstChild().b root = source_p.firstChild() rc.http_server_support = True # Override setting for testing. # # Compute the result. rc.nodeNumber = 0 source = rc.write_rst_tree(root, fn) html = rc.writeToDocutils(p, source, ext='.html') # # Tests... # Don't bother testing the html. It will depend on docutils. if 0: g.printObj(g.splitLines(source), tag='source') g.printObj(g.splitLines(expected_source), tag='expected source') self.assertEqual(expected_source, source, msg='expected_s != got_s') assert html and html.startswith('<?xml') and html.strip().endswith('</html>')
def findNode(self,c,p,headline): p = g.findNodeInTree(c,p,headline) if not p: g.es_print('can not find',headline) assert False return p