lanto03 / couchdb-python

Automatically exported from code.google.com/p/couchdb-python
Other
0 stars 0 forks source link

doctests fail on rev 143 #75

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
the following demonstrates the problem:

>>> import couchdb, doctest
>>> doctest.testmod(couchdb.client)
**********************************************************************
File "/usr/lib/python2.6/site-packages/couchdb/client.py", line 337, in
couchdb.client.Database.delete
Failed example:
    db.delete(doc)
Expected:
    Traceback (most recent call last):
      ...
    PreconditionFailed: ('conflict', 'Document update conflict.')
Got:
    Traceback (most recent call last):
      File "/usr/lib/python2.6/doctest.py", line 1241, in __run
        compileflags, 1) in test.globs
      File "<doctest couchdb.client.Database.delete[7]>", line 1, in <module>
        db.delete(doc)
      File "/usr/lib/python2.6/site-packages/couchdb/client.py", line 348,
in delete
        self.resource.delete(doc['_id'], rev=doc['_rev'])
      File "/usr/lib/python2.6/site-packages/couchdb/client.py", line 829,
in delete
        return self._request('DELETE', path, headers=headers, **params)
      File "/usr/lib/python2.6/site-packages/couchdb/client.py", line 886,
in _request
        raise ResourceConflict(error)
    ResourceConflict: ('conflict', 'Document update conflict.')
**********************************************************************
File "/usr/lib/python2.6/site-packages/couchdb/client.py", line 494, in
couchdb.client.Database.update
Failed example:
    for doc in db.update([
        Document(type='Person', name='John Doe'),
        Document(type='Person', name='Mary Jane'),
        Document(type='City', name='Gotham City')
    ]):
        print repr(doc) #doctest: +ELLIPSIS
Exception raised:
    Traceback (most recent call last):
      File "/usr/lib/python2.6/doctest.py", line 1241, in __run
        compileflags, 1) in test.globs
      File "<doctest couchdb.client.Database.update[2]>", line 4, in <module>
        Document(type='City', name='Gotham City')
      File "/usr/lib/python2.6/site-packages/couchdb/client.py", line 529,
in update
        assert data['ok'] # FIXME: Should probably raise a proper exception
    TypeError: list indices must be integers, not str
**********************************************************************
2 items had failures:
   1 of   9 in couchdb.client.Database.delete
   1 of   4 in couchdb.client.Database.update
***Test Failed*** 2 failures.
TestResults(failed=2, attempted=71)

i found one of the errors is simple enough to fix, change client.py:340 from
  PreconditionFailed: ('conflict', 'Document update conflict.')
to
  ResourceConflict: ('conflict', 'Document update conflict.')

the second one seems to be a functional error in the update() function,
maybe the change of couchdb 0.9 with the doc.rev having to be passed for
updates?

Original issue reported on code.google.com by sor...@gmail.com on 1 May 2009 at 10:33

GoogleCodeExporter commented 8 years ago
the second one seems to be a problem with the return of the new couchdb, it 
returns a
list of dicts with {'rev': 'newrev', 'id': 'doc.id'}, so the assert in line 529 
isn't
true (it expects a return in the form {'ok': true} i guess. (as far as i can 
tell..)
thanks,
John

Original comment by sor...@gmail.com on 1 May 2009 at 10:59

GoogleCodeExporter commented 8 years ago
I assume you're using the 0.5 release, which isn't compatible with CouchDB 0.9, 
unfortunately. Trunk should 
work, and there should be a 0.6 release this week.

Original comment by cmlenz on 26 May 2009 at 9:14

GoogleCodeExporter commented 8 years ago

Original comment by cmlenz on 26 May 2009 at 9:14

GoogleCodeExporter commented 8 years ago
Hi,

I'm getting the same issue using the trunk (see below). Any suggestions?

Thanks in advance.

-- Nicolas

% python -c "import couchdb, doctest; print couchdb.__version__;
doctest.testmod(couchdb.client)"
0.5dev-r150
**********************************************************************
File
"/usr/lib/python2.5/site-packages/CouchDB-0.5dev_r150-py2.5.egg/couchdb/client.p
y",
line 8, in couchdb.client
Failed example:
    doc['type']
Expected:
    'Person'
Got:
    u'Person'
**********************************************************************
File
"/usr/lib/python2.5/site-packages/CouchDB-0.5dev_r150-py2.5.egg/couchdb/client.p
y",
line 10, in couchdb.client
Failed example:
    doc['name']
Expected:
    'John Doe'
Got:
    u'John Doe'
**********************************************************************
File
"/usr/lib/python2.5/site-packages/CouchDB-0.5dev_r150-py2.5.egg/couchdb/client.p
y",
line ?, in couchdb.client.Database
Failed example:
    doc                 #doctest: +ELLIPSIS
Expected:
    <Document '...'@... {...}>
Got:
    <Document u'065595add24c7a46d2e9b5aba9b668e9'@u'1-915012133' {u'type': u'Person',
u'name': u'John Doe'}>
**********************************************************************
File
"/usr/lib/python2.5/site-packages/CouchDB-0.5dev_r150-py2.5.egg/couchdb/client.p
y",
line ?, in couchdb.client.Database
Failed example:
    doc.id, doc.rev     #doctest: +ELLIPSIS
Expected:
    ('...', ...)
Got:
    (u'065595add24c7a46d2e9b5aba9b668e9', u'1-915012133')
**********************************************************************
File
"/usr/lib/python2.5/site-packages/CouchDB-0.5dev_r150-py2.5.egg/couchdb/client.p
y",
line ?, in couchdb.client.Database
Failed example:
    doc['type']
Expected:
    'Person'
Got:
    u'Person'
**********************************************************************
File
"/usr/lib/python2.5/site-packages/CouchDB-0.5dev_r150-py2.5.egg/couchdb/client.p
y",
line ?, in couchdb.client.Database
Failed example:
    doc['name']
Expected:
    'John Doe'
Got:
    u'John Doe'
**********************************************************************
File
"/usr/lib/python2.5/site-packages/CouchDB-0.5dev_r150-py2.5.egg/couchdb/client.p
y",
line 365, in couchdb.client.Database.delete
Failed example:
    db.delete(doc)
Expected:
    Traceback (most recent call last):
      ...
    ResourceConflict: ('conflict', 'Document update conflict.')
Got:
    Traceback (most recent call last):
      File "/usr/lib/python2.5/doctest.py", line 1228, in __run
        compileflags, 1) in test.globs
      File "<doctest couchdb.client.Database.delete[7]>", line 1, in <module>
        db.delete(doc)
      File "build/bdist.linux-x86_64/egg/couchdb/client.py", line 376, in delete
        self.resource.delete(doc['_id'], rev=doc['_rev'])
      File "build/bdist.linux-x86_64/egg/couchdb/client.py", line 878, in delete
        return self._request('DELETE', path, headers=headers, **params)
      File "build/bdist.linux-x86_64/egg/couchdb/client.py", line 935, in _request
        raise ResourceConflict(error)
    ResourceConflict: (u'conflict', u'Document update conflict.')
**********************************************************************
File
"/usr/lib/python2.5/site-packages/CouchDB-0.5dev_r150-py2.5.egg/couchdb/client.p
y",
line 530, in couchdb.client.Database.update
Failed example:
    for doc in db.update([
        Document(type='Person', name='John Doe'),
        Document(type='Person', name='Mary Jane'),
        Document(type='City', name='Gotham City')
    ]):
        print repr(doc) #doctest: +ELLIPSIS
Expected:
    <Document '...'@'...' {'type': 'Person', 'name': 'John Doe'}>
    <Document '...'@'...' {'type': 'Person', 'name': 'Mary Jane'}>
    <Document '...'@'...' {'type': 'City', 'name': 'Gotham City'}>
Got:
    <Document u'f576acb81788b668deaa811cd4500c25'@u'1-463203970' {'type': 'Person',
'name': 'John Doe'}>
    <Document u'8389589fd66de337c2ce7fb3b0466efc'@u'1-3132972907' {'type': 'Person',
'name': 'Mary Jane'}>
    <Document u'f059616936699d21cd2355581b225710'@u'1-4008764187' {'type': 'City',
'name': 'Gotham City'}>
**********************************************************************
File
"/usr/lib/python2.5/site-packages/CouchDB-0.5dev_r150-py2.5.egg/couchdb/client.p
y",
line ?, in couchdb.client.ViewResults
Failed example:
    list(results[['City', 'Gotham City']])
Expected:
    [<Row id='gotham', key=['City', 'Gotham City'], value='Gotham City'>]
Got:
    [<Row id=u'gotham', key=[u'City', u'Gotham City'], value=u'Gotham City'>]
**********************************************************************
5 items had failures:
   2 of   9 in couchdb.client
   4 of  14 in couchdb.client.Database
   1 of   9 in couchdb.client.Database.delete
   1 of   4 in couchdb.client.Database.update
   1 of  13 in couchdb.client.ViewResults
***Test Failed*** 9 failures.

Original comment by nicolas....@gmail.com on 13 Jun 2009 at 10:49