[Checkins] SVN: Sandbox/luciano/kirbi/src/kirbi/ftests/ fixed functional test setup with lessons learned these past days,

Luciano Ramalho luciano at ramalho.org
Sun Aug 12 18:20:22 EDT 2007


Log message for revision 78781:
  fixed functional test setup with lessons learned these past days,
  updated xmlrpc tests for the new API
  

Changed:
  U   Sandbox/luciano/kirbi/src/kirbi/ftests/test_functional.py
  D   Sandbox/luciano/kirbi/src/kirbi/ftests/xmlrpc.py
  A   Sandbox/luciano/kirbi/src/kirbi/ftests/xmlrpc.txt

-=-
Modified: Sandbox/luciano/kirbi/src/kirbi/ftests/test_functional.py
===================================================================
--- Sandbox/luciano/kirbi/src/kirbi/ftests/test_functional.py	2007-08-12 21:30:43 UTC (rev 78780)
+++ Sandbox/luciano/kirbi/src/kirbi/ftests/test_functional.py	2007-08-12 22:20:22 UTC (rev 78781)
@@ -3,10 +3,14 @@
 import kirbi
 from zope.testing import doctest
 from zope.app.testing.functional import (FunctionalTestSetup, ZCMLLayer,
-                                         HTTPCaller, sync, getRootFolder)
+                                         FunctionalDocFileSuite,
+                                         getRootFolder, HTTPCaller, sync)
+import zope.testbrowser.browser
+import zope.testbrowser.testing
 
 ftesting_zcml = os.path.join(os.path.dirname(kirbi.__file__), 'ftesting.zcml')
-KirbiFunctionalLayer = ZCMLLayer(ftesting_zcml, __name__, 'KirbiFunctionalLayer')
+KirbiFunctionalLayer = ZCMLLayer(ftesting_zcml, __name__,
+                                 'KirbiFunctionalLayer')
 
 def setUp(test):
     FunctionalTestSetup().setUp()
@@ -16,19 +20,20 @@
 
 def test_suite():
     suite = unittest.TestSuite()
-    test_modules = ['xmlrpc']
+    docfiles = ['xmlrpc.txt']
 
-    for module in test_modules:
-        module_name = 'kirbi.ftests.' + module
-        test = doctest.DocTestSuite(
-             module_name, setUp=setUp, tearDown=tearDown,
-             extraglobs=dict(http=HTTPCaller(),
-                             getRootFolder=getRootFolder,
-                             sync=sync),
-             optionflags=(doctest.ELLIPSIS+
-                          doctest.NORMALIZE_WHITESPACE+
-                          doctest.REPORT_NDIFF)
-             )
+    for docfile in docfiles:
+        test = FunctionalDocFileSuite(
+                    docfile, 
+                    setUp=setUp, tearDown=tearDown,
+                    globs=dict(http=HTTPCaller(),
+                        getRootFolder=getRootFolder,
+                        Browser=zope.testbrowser.testing.Browser,
+                        sync=sync),
+                    optionflags=(doctest.ELLIPSIS
+                        | doctest.NORMALIZE_WHITESPACE
+                        | doctest.REPORT_NDIFF)
+               )
         test.layer = KirbiFunctionalLayer
         suite.addTest(test)
 

Deleted: Sandbox/luciano/kirbi/src/kirbi/ftests/xmlrpc.py
===================================================================
--- Sandbox/luciano/kirbi/src/kirbi/ftests/xmlrpc.py	2007-08-12 21:30:43 UTC (rev 78780)
+++ Sandbox/luciano/kirbi/src/kirbi/ftests/xmlrpc.py	2007-08-12 22:20:22 UTC (rev 78781)
@@ -1,42 +0,0 @@
-"""
-======================
-Testing XML-RPC access
-======================
-
-First we setup the app and XML-RPC proxy::
-
-  >>> from grok.ftests.xmlrpc_helper import ServerProxy
-  >>> from kirbi.app import Kirbi
-  >>> root = getRootFolder()
-  >>> root['kirbi'] = Kirbi()
-  >>> server = ServerProxy("http://localhost/kirbi/pac")
-
-Now we use the proxy to add books::
-
-  >>> server.add(dict(title="One Flew Over the Cuckoo's Nest"))
-  'k0001'
-  >>> server.add(dict(isbn13='9780684833392'))
-  '9780684833392'
-  >>> server.add(dict(isbn13='9780486273471'))
-  '9780486273471'
-  >>> server.add(dict(title=u'Utopia', isbn13='9780140449105'))
-  '9780140449105'
-  >>> sorted(server.list())
-  ['9780140449105', '9780486273471', '9780684833392', 'k0001']
-
-The second and third books added have ISBN but no title, so they are added to
-the pending dict for remote metadata fetching::
-
-  >> sorted(server.list_pending_isbns())
-  ['9780486273471', '9780684833392']
-
-The fetch script can remove pending ISBNs (the number of ISBNs actually
-removed is returned)::
-
-  >> server.delPending(['9780684833392','9780486273471','not-an-isbn'])
-  999
-  >> sorted(server.list_pending_isbns())
-  []
-
-
-"""

Copied: Sandbox/luciano/kirbi/src/kirbi/ftests/xmlrpc.txt (from rev 78750, Sandbox/luciano/kirbi/src/kirbi/ftests/xmlrpc.py)
===================================================================
--- Sandbox/luciano/kirbi/src/kirbi/ftests/xmlrpc.txt	                        (rev 0)
+++ Sandbox/luciano/kirbi/src/kirbi/ftests/xmlrpc.txt	2007-08-12 22:20:22 UTC (rev 78781)
@@ -0,0 +1,60 @@
+======================
+Testing XML-RPC access
+======================
+
+    def updateBooks(self, book_dict_list):
+        return self.context.updateBooks(book_dict_list)
+
+    def dumpIncomplete(self):
+        return self.context.dumpIncomplete()
+
+First we setup the app and XML-RPC proxy to the PAC (the public access
+book catalog)::
+
+  >>> from grok.ftests.xmlrpc_helper import ServerProxy
+  >>> from kirbi.app import Kirbi
+  >>> root = getRootFolder()
+  >>> root['kirbi'] = Kirbi()
+  >>> pac = ServerProxy("http://localhost/kirbi/pac")
+
+Now we use the proxy to add books to the PAC::
+
+  >>> pac.add(dict(title="One Flew Over the Cuckoo's Nest"))
+  'k0001'
+  >>> pac.add(dict(isbn13='9780684833392'))
+  '9780684833392'
+  >>> pac.add(dict(isbn13='9780486273471'))
+  '9780486273471'
+  >>> pac.add(dict(title=u'Utopia', isbn13='9780140449105'))
+  '9780140449105'
+  >>> sorted(pac.list())
+  ['9780140449105', '9780486273471', '9780684833392', 'k0001']
+
+The second and third books added have ISBN but no title, so they are added to
+the incomplete attribute of the PAC, to be retrieved by Kirbifetch::
+
+  >>> sorted(pac.dumpIncomplete())
+  ['9780486273471', '9780684833392']
+
+Once retrieved, they are moved from the incomplete to the pending attribute
+of the pac::
+
+  >>> sorted(pac.dumpIncomplete())
+  []
+
+When the metadata is found at an external source, the book record can be
+updated (the number of books updated is returned)::
+
+  >>> metadata = [dict(isbn13='9780684833392',title=u'Catch-22',creators=[u'Joseph Heller'])]
+  >>> pac.updateBooks(metadata)
+  1
+
+But only pending books may be updated by this API::
+
+  >>> metadata = [dict(title=u'Utopia', isbn13='9780140449105')]
+  >>> pac.updateBooks(metadata)
+  Traceback (most recent call last):
+    ...
+  Fault: <Fault -1: 'Unexpected Zope exception: LookupError: 9780140449105
+  not in pending ISBNs; update not allowed.'>
+



More information about the Checkins mailing list