yuppie, on 2007-03-02:
> Maurits van Rees wrote:
>> So here are some points, with suggested changes to the _initIndexes
>> function in exportimport.py.  The tests even run after this, so it
>> seems these changes do not break anything.  But I have not *added*
>> tests for this.
> To get your patches accepted it would be useful to have new tests that
> fail without the patches.

Okay, I have a patch with such a test for the first point that I
raised: removing an index in an extension profile and then making sure
that reapplying that profile does not throw an error.

The patch is for

[EMAIL PROTECTED]:~/svn/plone25-zope29/GenericSetup/ZCatalog $ svn diff
Index: tests/test_exportimport.py
--- tests/test_exportimport.py  (revision 73446)
+++ tests/test_exportimport.py  (working copy)
@@ -77,6 +77,7 @@
   <extra name="index_type" value="Okapi BM25 Rank"/>
   <extra name="lexicon_id" value="foo_plexicon"/>
+ <index name="non_existing" remove="True"/>
Index: exportimport.py
--- exportimport.py     (revision 73446)
+++ exportimport.py     (working copy)
@@ -94,7 +94,12 @@
             idx_id = str(child.getAttribute('name'))
             if child.hasAttribute('remove'):
-                zcatalog.delIndex(idx_id)
+                # Remove index if it is there; then continue to the
+                # next index.  Removing a non existing index should
+                # not cause an error, so you can apply the profile
+                # twice without problems.
+                if idx_id in zcatalog.indexes():
+                    zcatalog.delIndex(idx_id)
             if idx_id not in zcatalog.indexes():

Can this go in?  I have no commit rights, so someone else would have
to do that.

The other points are currently beyond my ability.

BTW, I am slightly freaked out by the following.  In that test file
there is this test:

        self.assertEqual(adapted.body, _CATALOG_BODY % ('', _ZCTEXT_XML))

The test passes of course.  But when I copy that line so the test is
run twice, like this:

        self.assertEqual(adapted.body, _CATALOG_BODY % ('', _ZCTEXT_XML))
        self.assertEqual(adapted.body, _CATALOG_BODY % ('', _ZCTEXT_XML))

then the second test throws an error!

Running unit tests:

Error in test test_body_set_update (Products.GenericSetup.ZCatalog.tests.\
Traceback (most recent call last):
  File "unittest.py", line 260, in run
  File "/home/maurits/instances/projects/Products/GenericSetup/ZCatalog/\
tests/test_exportimport.py", line 184, in test_body_set_update
    self.assertEqual(adapted.body, _CATALOG_BODY % ('', _ZCTEXT_XML))
  File "/home/maurits/instances/projects/Products/GenericSetup/utils.py", line\
503, in _exportBody
  File "/usr/lib/python2.4/site-packages/_xmlplus/dom/minidom.py", line 1548,\
in appendChild
    raise xml.dom.HierarchyRequestErr(
HierarchyRequestErr: two document elements disallowed

  Ran 5 tests with 0 failures and 1 errors in 0.474 seconds.

Going in with the pdb also throws that error when you try to print
adapted.body twice.

I will loan you my "Here be dragons" sign. ;-)

Maurits van Rees | http://maurits.vanrees.org/ [NL]
            Work | http://zestsoftware.nl/
"Do not worry about your difficulties in computers,
 I can assure you mine are still greater."

Zope-CMF maillist  -  Zope-CMF@lists.zope.org

See http://collector.zope.org/CMF for bug reports and feature requests

Reply via email to