[z3-checkins] r33820 - in z3/deliverance/branches/packaged/deliverance: . test-data

cabraham at codespeak.net cabraham at codespeak.net
Fri Oct 27 18:01:15 CEST 2006


Author: cabraham
Date: Fri Oct 27 18:01:11 2006
New Revision: 33820

Modified:
   z3/deliverance/branches/packaged/deliverance/interpreter.py
   z3/deliverance/branches/packaged/deliverance/test-data/test_drop.xml
   z3/deliverance/branches/packaged/deliverance/test-data/test_replace.xml
Log:
fixed tail handling in apply_drop; added failing tests for drop and replace

Modified: z3/deliverance/branches/packaged/deliverance/interpreter.py
==============================================================================
--- z3/deliverance/branches/packaged/deliverance/interpreter.py	(original)
+++ z3/deliverance/branches/packaged/deliverance/interpreter.py	Fri Oct 27 18:01:11 2006
@@ -347,6 +347,7 @@
             document = locals()[context]
             removed = False
             for el in document.xpath(rule.attrib[context]):
+                self.attach_text_to_previous(el, el.tail)
                 el.getparent().remove(el)
                 removed = True
             if not removed and rule.attrib.get(self.NOCONTENT_KEY) != 'ignore':

Modified: z3/deliverance/branches/packaged/deliverance/test-data/test_drop.xml
==============================================================================
--- z3/deliverance/branches/packaged/deliverance/test-data/test_drop.xml	(original)
+++ z3/deliverance/branches/packaged/deliverance/test-data/test_drop.xml	Fri Oct 27 18:01:11 2006
@@ -189,5 +189,43 @@
   </output>
 </deliverance-test>
 
+<!-- drop a div tag but maintain the tails  --> 
+<deliverance-test>
+  <rules xmlns="http://www.plone.org/deliverance">
+    <drop theme="//div[@id='foo']"/>
+  </rules>
+
+  <theme base="http://example.com"> 
+     <html><head><title>Blah</title></head><body>before<div id="foo">Dummy Content</div>after</body></html>
+  </theme>
+
+  <content> 
+     <html><body>Real Content</body></html>
+  </content>
+ 
+  <output>
+     <html><head><title>Blah</title></head><body>beforeafter</body></html>
+  </output> 
+</deliverance-test>
+
+<!-- drop an element that is just text  --> 
+<!--<deliverance-test>
+  <rules xmlns="http://www.plone.org/deliverance">
+    <drop theme="//div[@id='foo']/child::node()" />
+  </rules>
+
+  <theme base="http://example.com"> 
+     <html><head><title>Blah</title></head><body>before<div id="foo">Dummy Content</div>after</body></html>
+  </theme>
+
+  <content> 
+     <html><body>Real Content</body></html>
+  </content>
+ 
+  <output>
+     <html><head><title>Blah</title></head><body>before<div id="foo"></div>after</body></html>
+  </output> 
+</deliverance-test>-->
+
 </deliverance-test-suite>
 

Modified: z3/deliverance/branches/packaged/deliverance/test-data/test_replace.xml
==============================================================================
--- z3/deliverance/branches/packaged/deliverance/test-data/test_replace.xml	(original)
+++ z3/deliverance/branches/packaged/deliverance/test-data/test_replace.xml	Fri Oct 27 18:01:11 2006
@@ -211,6 +211,24 @@
   </output> 
 </deliverance-test>
 
+<!-- a test that replaces text with a mixture of elements and text -->
+<!-- <deliverance-test>
+  <rules xmlns="http://www.plone.org/deliverance">
+    <replace theme="//div[@id='foo']/child::node()" content="//div[@id='bar']/child::node()" />
+  </rules>
+
+  <theme base="http://example.com"> 
+     <html><head><title>Blah</title></head><body><p>some text</p><div id="foo">Dummy Content</div>theme tail</body></html>
+  </theme>
+
+  <content> 
+     <html><body><div id="bar">Real Content<p>a nice p tag</p>mid text<i>some i text</i>end tail</div></body></html>
+  </content>
+ 
+  <output>
+     <html><head><title>Blah</title></head><body><p>some text</p><div id="foo">Real Content<p>a nice p tag</p>mid text<i>some i text</i>end tail</div>theme tail</body></html>
+  </output> 
+</deliverance-test>-->
 
 </deliverance-test-suite>
 


More information about the z3-checkins mailing list