Author: jvloothuis
Date: Mon Nov 12 18:31:11 2007
New Revision: 48605

Modified:
   kukit/kss.base/trunk/kss/base/commands.txt
Log:

Updated the test suite. It now has some validation for the response document.


Modified: kukit/kss.base/trunk/kss/base/commands.txt
==============================================================================
--- kukit/kss.base/trunk/kss/base/commands.txt  (original)
+++ kukit/kss.base/trunk/kss/base/commands.txt  Mon Nov 12 18:31:11 2007
@@ -1,3 +1,4 @@
+============
 KSS Commands
 ============
 
@@ -38,14 +39,44 @@
   >>> commands.render()
   '...some value...some arg...'
 
-The response is an XML document where each parameter value is put
-within CDATA blocks.
+
+Response format
+===============
+
+The response is an XML document.
+
+  >>> from xml.dom import minidom
+  >>> doc = minidom.parseString(commands.render())
+
+In this case there are two commands in the response (because of the
+previous examples). They are represented as command nodes.
+
+  >>> doc.getElementsByTagName('command')
+  [<DOM Element: command at ...>, <DOM Element: command at ...>]
+
+Each parameter is represented by a child node in a command. Their name
+is stored in the attribute and their value is put within CDATA blocks.
+
+  >>> replace_command = doc.getElementsByTagName('command')[0]
+
+  >>> params = replace_command.getElementsByTagName('param')
+  >>> html_value = params[0]
+  >>> html_value.attributes['name'].nodeValue
+  u'html'
+
+  >>> html_value.childNodes[0].nodeType == doc.CDATA_SECTION_NODE
+  True
 
   >>> commands.render()
   '...<![CDATA[some value]]>...'
 
 We are using CDATA because Firefox chops text nodes at 4KB blocks
-(which makes the client side handling more difficult).
+(which makes the client side handling more difficult). Using CDATA
+avoids the chopping.
+
+
+String representation
+=====================
 
 It is also possible to get a string representation of the
 commandset. This can be used in doctests like this.
@@ -79,6 +110,10 @@
   replaceHTML(css('#someid'), a_arg='cheese', b_arg='some data')
   otherCommand(css('#something'))
 
+
+Features for working with commands
+==================================
+
 If we add a parameter with a `None` value it will not be put into the
 response.
 
_______________________________________________
Kukit-checkins mailing list
[email protected]
http://codespeak.net/mailman/listinfo/kukit-checkins

Reply via email to