Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-293

test_uuid_subtype (test.test_collection.TestCollection) - Test Failure

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.1
    • Affects Version/s: 2.1
    • Component/s: Tests
    • Labels:
      None
    • Environment:
      Mac OS X 10.7.1 using default Python 2.7.1 interpreter and MongoDB v2.0.1 64-bit binary

      I get the following failure when running "nosetests -v --pdb --pdb-failures":

      test_uuid_subtype (test.test_collection.TestCollection) ... > /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/case.py(487)_baseAssertEqual()
      -> raise self.failureException(msg)
      (Pdb) where
      /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/case.py(318)run()
      -> testMethod()
      /InstantGeo/src/mongodb-mongo-python-driver-c59db8c/test/test_collection.py(1399)test_uuid_subtype()
      -> self.assertEqual(1, coll.find_one(

      {'_id': uu}

      )['i'])
      /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/case.py(494)assertEqual()
      -> assertion_func(first, second, msg=msg)
      > /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/case.py(487)_baseAssertEqual()
      -> raise self.failureException(msg)
      (Pdb) up
      > /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/case.py(494)assertEqual()
      -> assertion_func(first, second, msg=msg)
      (Pdb) up
      > /InstantGeo/src/mongodb-mongo-python-driver-c59db8c/test/test_collection.py(1399)test_uuid_subtype()
      -> self.assertEqual(1, coll.find_one(

      {'_id': uu}

      )['i'])
      (Pdb) p uu
      UUID('4beb69a5-874e-4f10-91df-b2dd0392f77c')
      (Pdb) p coll
      Collection(Database(Connection('localhost', 27017), u'pymongo_test'), u'uuid')
      (Pdb) coll.find_one(

      {'_id': uu}

      )

      {u'i': 0, u'_id': UUID('4beb69a5-874e-4f10-91df-b2dd0392f77c')}

      (Pdb) l
      1394 coll.insert(

      {'_id': uu, 'i': 0}

      )
      1395 self.assertEqual(0, coll.find_one(

      {'_id': uu}

      )['i'])
      1396 doc = coll.find_one(

      {'_id': uu}

      )
      1397 doc['i'] = 1
      1398 coll.save(doc)
      1399 -> self.assertEqual(1, coll.find_one(

      {'_id': uu}

      )['i'])
      1400
      1401 # Test update
      1402 coll.uuid_subtype = UUID_SUBTYPE
      1403 coll.update(

      {'_id': uu}

      , {'$set': {'i': 2}})
      1404 coll.uuid_subtype = OLD_UUID_SUBTYPE
      (Pdb) doc

      {u'i': 1, u'_id': UUID('4beb69a5-874e-4f10-91df-b2dd0392f77c')}

      (Pdb) coll.save(doc)
      UUID('4beb69a5-874e-4f10-91df-b2dd0392f77c')
      (Pdb) coll.find_one(

      {'_id': uu}

      )

      {u'i': 0, u'_id': UUID('4beb69a5-874e-4f10-91df-b2dd0392f77c')}

      (Pdb) doc

      {u'i': 1, u'_id': UUID('4beb69a5-874e-4f10-91df-b2dd0392f77c')}

      The MongoDB log shows:

      Mon Nov 21 17:50:19 [conn2979] User Assertion: 11000:E11000 duplicate key error index: pymongo_test.uuid.$id dup key: { : BinData }
      Mon Nov 21 17:50:19 [conn2979] update pymongo_test.uuid query:

      { _id: BinData }

      update:

      { _id: BinData, i: 1 }

      upsert:1 exception: E11000 duplicate key error index: pymongo_test.uuid.$id dup key: { : BinData } code:11000 0ms
      Mon Nov 21 17:50:19 [journal] lsn set 2920169

      Trying an update with upsert=True give the same error:

      (Pdb) coll.update(

      { '_id': uu}

      , doc, True)
      (Pdb) coll.find_one(

      {'_id': uu}

      )

      {u'i': 0, u'_id': UUID('4beb69a5-874e-4f10-91df-b2dd0392f77c')}

      MongoDB Log:

      Mon Nov 21 17:57:24 [conn2979] User Assertion: 11000:E11000 duplicate key error index: pymongo_test.uuid.$id dup key: { : BinData }
      Mon Nov 21 17:57:24 [conn2979] update pymongo_test.uuid query:

      { _id: BinData }

      update:

      { _id: BinData, i: 1 }

      upsert:1 exception: E11000 duplicate key error index: pymongo_test.uuid.$id dup key: { : BinData } code:11000 0ms

      Trying an update with upsert=False does not give an error but does not update the document:

      (Pdb) coll.update(

      { '_id': uu}

      , doc, False)
      (Pdb) coll.find_one(

      {'_id': uu}

      )

      {u'i': 0, u'_id': UUID('4beb69a5-874e-4f10-91df-b2dd0392f77c')}

      MongoDB Log:

      Mon Nov 21 17:57:38 [conn2979] update pymongo_test.uuid query:

      { _id: BinData }

      update:

      { _id: BinData, i: 1 }

      0ms

      I am unsure what to make of this.

            Assignee:
            bernie@mongodb.com Bernie Hackett
            Reporter:
            mponton Marco Ponton
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: