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

Update MockupDB for PyMongo 3.6

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.6
    • Affects Version/s: None
    • Component/s: Tests
    • None

      Database.collection_names and Collection.options now use the aggregate command on MongoDB 2.6. The following MockupDB tests are failing:

       [2017/11/28 12:19:01.480] FAIL: test_collection_names (tests.test_mixed_version_sharded.TestMixedVersionSharded)
       [2017/11/28 12:19:01.480] ----------------------------------------------------------------------
       [2017/11/28 12:19:01.480] Traceback (most recent call last):
       [2017/11/28 12:19:01.480]   File "/data/mci/f6c82c2c7948e1a6f601ee84c57ffadd/pymongo-mockup-tests/tests/test_mixed_version_sharded.py", line 72, in test
       [2017/11/28 12:19:01.480]     else upgrade.new)
       [2017/11/28 12:19:01.480]   File "/data/mci/f6c82c2c7948e1a6f601ee84c57ffadd/pymongo-mockup-tests/.eggs/mockupdb-1.3.0.dev0-py2.7.egg/mockupdb/__init__.py", line 408, in assert_matches
       [2017/11/28 12:19:01.480]     raise AssertionError('%r does not match %r' % (self, matcher))
       [2017/11/28 12:19:01.480] AssertionError: Command({"aggregate": "system.namespaces", "pipeline": [{"$project": {"name": {"$substr": ["$name", 3, -1]}, "options": 1}}, {"$match": {"name": {"$regex": "^(?!.*\\$)"}}}], "cursor": {}}, namespace="db") does not match Matcher(OpQuery({}, namespace="db.system.namespaces"))
       [2017/11/28 12:19:01.480] ======================================================================
       [2017/11/28 12:19:01.480] FAIL: test_options (tests.test_mixed_version_sharded.TestMixedVersionSharded)
       [2017/11/28 12:19:01.480] ----------------------------------------------------------------------
       [2017/11/28 12:19:01.480] Traceback (most recent call last):
       [2017/11/28 12:19:01.480]   File "/data/mci/f6c82c2c7948e1a6f601ee84c57ffadd/pymongo-mockup-tests/tests/test_mixed_version_sharded.py", line 72, in test
       [2017/11/28 12:19:01.480]     else upgrade.new)
       [2017/11/28 12:19:01.480]   File "/data/mci/f6c82c2c7948e1a6f601ee84c57ffadd/pymongo-mockup-tests/.eggs/mockupdb-1.3.0.dev0-py2.7.egg/mockupdb/__init__.py", line 408, in assert_matches
       [2017/11/28 12:19:01.480]     raise AssertionError('%r does not match %r' % (self, matcher))
       [2017/11/28 12:19:01.480] AssertionError: Command({"aggregate": "system.namespaces", "pipeline": [{"$project": {"name": {"$substr": ["$name", 3, -1]}, "options": 1}}, {"$match": {"$and": [{"name": {"$regex": "^(?!.*\\$)"}}, {"name": "collection"}]}}], "cursor": {}}, namespace="db") does not match Matcher(OpQuery({}, namespace="db.system.namespaces"))
      

      Additionally, the following test fails because Pymongo 3.6 (correctly) assumes an acknowledged bulk update response always includes "nModified":

      test_bulk (tests.test_cluster_time.TestClusterTime) ...
      error in going(<function callback at 0x110f0a140>, MongoClient(host=['localhost:54094'], document_class=dict, tz_aware=False, connect=True), ):
      Traceback (most recent call last):
        File "/Users/shane/git/pymongo-mockup-tests/.eggs/mockupdb-1.2.0.dev0-py2.7.egg/mockupdb/__init__.py", line 194, in going
          future(timeout=1)
        File "/Users/shane/git/pymongo-mockup-tests/.eggs/mockupdb-1.2.0.dev0-py2.7.egg/mockupdb/__init__.py", line 157, in get_result
          reraise(*error)
        File "/Users/shane/git/pymongo-mockup-tests/.eggs/mockupdb-1.2.0.dev0-py2.7.egg/mockupdb/__init__.py", line 142, in target
          result[0] = fn(*args, **kwargs)
        File "/Users/shane/git/pymongo-mockup-tests/tests/test_cluster_time.py", line 64, in callback
          DeleteMany({})])
        File "/Users/shane/git/mongo-python-driver/pymongo/collection.py", line 491, in bulk_write
          bulk_api_result = blk.execute(self.write_concern.document, session)
        File "/Users/shane/git/mongo-python-driver/pymongo/bulk.py", line 432, in execute
          return self.execute_command(generator, write_concern, session)
        File "/Users/shane/git/mongo-python-driver/pymongo/bulk.py", line 323, in execute_command
          self.is_retryable, retryable_bulk, s, self)
        File "/Users/shane/git/mongo-python-driver/pymongo/mongo_client.py", line 1074, in _retry_with_session
          return func(session, sock_info, retryable)
        File "/Users/shane/git/mongo-python-driver/pymongo/bulk.py", line 318, in retryable_bulk
          retryable, full_result)
        File "/Users/shane/git/mongo-python-driver/pymongo/bulk.py", line 290, in _execute_command
          _merge_command(run, full_result, results)
        File "/Users/shane/git/mongo-python-driver/pymongo/bulk.py", line 115, in _merge_command
          full_result["nModified"] += result["nModified"]
      KeyError: "'nModified'"
      FAIL
      
      ======================================================================
      FAIL: test_bulk (tests.test_cluster_time.TestClusterTime)
      ----------------------------------------------------------------------
      Traceback (most recent call last):
        File "/Users/shane/git/pymongo-mockup-tests/tests/test_cluster_time.py", line 66, in test_bulk
          self.cluster_time_conversation(callback, [{'ok': 1}] * 3)
        File "/Users/shane/git/pymongo-mockup-tests/tests/test_cluster_time.py", line 47, in cluster_time_conversation
          request.reply(reply)
        File "/usr/local/Cellar/python/2.7.13_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/contextlib.py", line 35, in __exit__
          self.gen.throw(type, value, traceback)
        File "/Users/shane/git/pymongo-mockup-tests/.eggs/mockupdb-1.2.0.dev0-py2.7.egg/mockupdb/__init__.py", line 201, in going
          reraise(*exc_info)
        File "/Users/shane/git/pymongo-mockup-tests/.eggs/mockupdb-1.2.0.dev0-py2.7.egg/mockupdb/__init__.py", line 188, in going
          yield future
        File "/Users/shane/git/pymongo-mockup-tests/tests/test_cluster_time.py", line 40, in cluster_time_conversation
          request = server.receives()
        File "/Users/shane/git/pymongo-mockup-tests/.eggs/mockupdb-1.2.0.dev0-py2.7.egg/mockupdb/__init__.py", line 1181, in receives
          % matcher.prototype)
      AssertionError: expected to receive Request(), got nothing
      

            Assignee:
            shane.harvey@mongodb.com Shane Harvey
            Reporter:
            shane.harvey@mongodb.com Shane Harvey
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: