From a19d085a3cb55ab5ed2676ae48197c6d95d51a0e Mon Sep 17 00:00:00 2001 From: Sophia Yang Date: Fri, 12 Jun 2026 13:45:11 -0400 Subject: [PATCH 1/9] quick pass --- bson/raw_bson.py | 6 +- pymongo/_csot.py | 2 +- pymongo/asynchronous/collection.py | 112 +- pymongo/asynchronous/cursor.py | 8 +- pymongo/asynchronous/database.py | 2 +- pymongo/asynchronous/mongo_client.py | 10 +- pymongo/synchronous/collection.py | 112 +- pymongo/synchronous/cursor.py | 8 +- pymongo/synchronous/database.py | 2 +- pymongo/synchronous/mongo_client.py | 10 +- test/__init__.py | 2 +- test/asynchronous/__init__.py | 2 +- test/asynchronous/test_async_cancellation.py | 24 +- .../test_async_contextvars_reset.py | 4 +- test/asynchronous/test_auth.py | 61 +- test/asynchronous/test_auth_oidc.py | 144 +- test/asynchronous/test_bulk.py | 12 +- test/asynchronous/test_change_stream.py | 4 +- test/asynchronous/test_client.py | 218 ++-- test/asynchronous/test_client_backpressure.py | 30 +- test/asynchronous/test_collation.py | 60 +- test/asynchronous/test_collection.py | 1158 ++++++++-------- test/asynchronous/test_comment.py | 6 +- test/asynchronous/test_common.py | 20 +- test/asynchronous/test_concurrency.py | 6 +- test/asynchronous/test_csot.py | 2 +- test/asynchronous/test_cursor.py | 646 +++++---- test/asynchronous/test_custom_types.py | 40 +- test/asynchronous/test_database.py | 240 ++-- .../test_discovery_and_monitoring.py | 12 +- test/asynchronous/test_encryption.py | 30 +- test/asynchronous/test_examples.py | 20 +- test/asynchronous/test_grid_file.py | 6 +- test/asynchronous/test_gridfs.py | 4 +- test/asynchronous/test_gridfs_bucket.py | 2 +- test/asynchronous/test_index_management.py | 2 +- .../test_json_util_integration.py | 6 +- test/asynchronous/test_load_balancer.py | 12 +- test/asynchronous/test_logger.py | 18 +- test/asynchronous/test_max_staleness.py | 4 +- test/asynchronous/test_monitoring.py | 142 +- test/asynchronous/test_pooling.py | 24 +- test/asynchronous/test_raw_bson.py | 30 +- test/asynchronous/test_read_concern.py | 6 +- test/asynchronous/test_read_preferences.py | 56 +- .../test_read_write_concern_spec.py | 52 +- test/asynchronous/test_retryable_reads.py | 36 +- test/asynchronous/test_retryable_writes.py | 28 +- test/asynchronous/test_server_selection.py | 14 +- .../test_server_selection_in_window.py | 4 +- test/asynchronous/test_session.py | 152 +-- test/asynchronous/test_ssl.py | 16 +- test/asynchronous/test_transactions.py | 38 +- test/asynchronous/test_unified_format.py | 4 +- .../test_versioned_api_integration.py | 6 +- test/atlas/test_connection.py | 2 +- test/auth/unified/mongodb-oidc-no-retry.json | 4 +- test/auth_aws/test_auth_aws.py | 2 +- .../causal-consistency-clientBulkWrite.json | 4 +- .../causal-consistency-write-commands.json | 4 +- .../change-streams-pre_and_post_images.json | 40 +- .../clustered-indexes.json | 18 +- .../createCollection-pre_and_post_images.json | 8 +- .../timeseries-collection.json | 22 +- test/command_monitoring/bulkWrite.json | 4 +- test/command_monitoring/command.json | 4 +- test/command_monitoring/deleteMany.json | 4 +- test/command_monitoring/deleteOne.json | 4 +- test/command_monitoring/find.json | 8 +- test/command_monitoring/insertMany.json | 4 +- test/command_monitoring/insertOne.json | 4 +- .../unacknowledged-client-bulkWrite.json | 4 +- .../unacknowledgedBulkWrite.json | 4 +- test/command_monitoring/updateMany.json | 4 +- test/command_monitoring/updateOne.json | 4 +- .../command_monitoring/writeConcernError.json | 4 +- test/connection_string/test/valid-auth.json | 2 +- .../aggregate-merge-errorResponse.json | 4 +- test/crud/unified/bulkWrite-arrayFilters.json | 10 +- .../crud/unified/bulkWrite-errorResponse.json | 2 +- .../bulkWrite-updateMany-pipeline.json | 6 +- .../unified/bulkWrite-updateOne-pipeline.json | 6 +- .../crud/unified/deleteOne-errorResponse.json | 2 +- .../findOneAndUpdate-errorResponse.json | 6 +- .../unified/findOneAndUpdate-pipeline.json | 6 +- .../crud/unified/insertOne-errorResponse.json | 2 +- test/crud/unified/updateMany-pipeline.json | 6 +- .../crud/unified/updateOne-errorResponse.json | 2 +- test/crud/unified/updateOne-pipeline.json | 6 +- test/csot/bulkWrite.json | 10 +- test/csot/change-streams.json | 32 +- test/csot/close-cursors.json | 4 +- test/csot/command-execution.json | 20 +- test/csot/convenient-transactions.json | 8 +- test/csot/cursors.json | 4 +- test/csot/deprecated-options.json | 266 ++-- test/csot/error-transformations.json | 8 +- test/csot/global-timeoutMS.json | 248 ++-- test/csot/gridfs-advanced.json | 12 +- test/csot/gridfs-delete.json | 8 +- test/csot/gridfs-download.json | 16 +- test/csot/gridfs-find.json | 10 +- test/csot/gridfs-upload.json | 6 +- test/csot/legacy-timeouts.json | 22 +- test/csot/non-tailable-cursors.json | 26 +- test/csot/override-operation-timeoutMS.json | 124 +- test/csot/retryability-legacy-timeouts.json | 180 +-- test/csot/retryability-timeoutMS.json | 268 ++-- test/csot/sessions-inherit-timeoutMS.json | 10 +- ...sessions-override-operation-timeoutMS.json | 10 +- test/csot/sessions-override-timeoutMS.json | 10 +- test/csot/tailable-awaitData.json | 28 +- test/csot/tailable-non-awaitData.json | 14 +- test/csot/waitQueueTimeout.json | 6 +- test/data_lake/unified/aggregate.json | 4 +- .../unified/estimatedDocumentCount.json | 4 +- test/data_lake/unified/find.json | 4 +- test/data_lake/unified/getMore.json | 4 +- test/data_lake/unified/listCollections.json | 4 +- test/data_lake/unified/runCommand.json | 4 +- .../unified/metadata-not-propagated.json | 2 +- .../unified/op_msg-not-supported.json | 2 +- test/lambda/mongodb/app.py | 2 +- test/mockupdb/operations.py | 12 +- test/mockupdb/test_cluster_time.py | 14 +- test/mockupdb/test_cursor.py | 4 +- test/mockupdb/test_cursor_namespace.py | 14 +- test/mockupdb/test_getmore_sharded.py | 2 +- test/mockupdb/test_handshake.py | 2 +- test/mockupdb/test_list_indexes.py | 6 +- .../mockupdb/test_mongos_command_read_mode.py | 4 +- test/mockupdb/test_query_read_pref_sharded.py | 2 +- test/mockupdb/test_standalone_shard.py | 2 +- test/mypy_fails/insert_many_dict.py | 2 +- test/mypy_fails/insert_one_list.py | 2 +- test/mypy_fails/raw_bson_document.py | 2 +- test/mypy_fails/typedict_client.py | 2 +- .../driver-sessions-dirty-session-errors.json | 16 +- .../driver-sessions-server-support.json | 8 +- test/test_auth.py | 59 +- test/test_auth_oidc.py | 144 +- test/test_binary.py | 2 +- test/test_bulk.py | 16 +- test/test_change_stream.py | 4 +- test/test_client.py | 220 ++-- test/test_client_backpressure.py | 30 +- test/test_collation.py | 60 +- test/test_collection.py | 1162 ++++++++--------- test/test_comment.py | 6 +- test/test_common.py | 20 +- test/test_csot.py | 2 +- test/test_cursor.py | 644 ++++----- test/test_custom_types.py | 40 +- test/test_database.py | 238 ++-- test/test_decimal128.py | 2 +- test/test_discovery_and_monitoring.py | 12 +- test/test_encryption.py | 30 +- test/test_examples.py | 20 +- test/test_grid_file.py | 6 +- test/test_gridfs.py | 4 +- test/test_gridfs_bucket.py | 2 +- test/test_index_management.py | 2 +- test/test_json_util_integration.py | 6 +- test/test_load_balancer.py | 12 +- test/test_logger.py | 18 +- test/test_max_staleness.py | 4 +- test/test_monitoring.py | 142 +- test/test_pooling.py | 24 +- test/test_raw_bson.py | 30 +- test/test_read_concern.py | 6 +- test/test_read_preferences.py | 58 +- test/test_read_write_concern_spec.py | 52 +- test/test_replica_set_reconfig.py | 2 +- test/test_retryable_reads.py | 36 +- test/test_retryable_writes.py | 28 +- test/test_server_selection.py | 14 +- test/test_server_selection_in_window.py | 4 +- test/test_session.py | 152 +-- test/test_ssl.py | 16 +- test/test_threads.py | 36 +- test/test_transactions.py | 38 +- test/test_typing.py | 30 +- test/test_unified_format.py | 4 +- test/test_versioned_api_integration.py | 6 +- .../unified/callback-aborts.json | 10 +- .../unified/callback-commits.json | 8 +- .../unified/callback-retry.json | 10 +- .../unified/commit-retry-errorLabels.json | 6 +- .../unified/commit-retry.json | 10 +- .../commit-transienttransactionerror-4.2.json | 6 +- .../commit-transienttransactionerror.json | 12 +- .../unified/commit-writeconcernerror.json | 14 +- .../unified/commit.json | 8 +- .../unified/transaction-options.json | 20 +- test/transactions/unified/abort.json | 20 +- .../unified/backpressure-retryable-abort.json | 8 +- .../backpressure-retryable-commit.json | 8 +- .../unified/backpressure-retryable-reads.json | 4 +- .../backpressure-retryable-writes.json | 10 +- test/transactions/unified/bulk.json | 6 +- .../unified/causal-consistency.json | 8 +- test/transactions/unified/commit.json | 24 +- test/transactions/unified/count.json | 6 +- .../unified/create-collection.json | 26 +- test/transactions/unified/create-index.json | 18 +- test/transactions/unified/delete.json | 8 +- .../unified/error-labels-blockConnection.json | 6 +- .../unified/error-labels-errorLabels.json | 8 +- test/transactions/unified/error-labels.json | 34 +- test/transactions/unified/errors-client.json | 4 +- test/transactions/unified/errors.json | 4 +- .../unified/findOneAndDelete.json | 8 +- .../unified/findOneAndReplace.json | 8 +- .../unified/findOneAndUpdate.json | 8 +- test/transactions/unified/insert.json | 16 +- test/transactions/unified/isolation.json | 8 +- .../transactions/unified/mongos-pin-auto.json | 122 +- .../mongos-recovery-token-errorLabels.json | 6 +- .../unified/mongos-recovery-token.json | 12 +- test/transactions/unified/mongos-unpin.json | 4 +- test/transactions/unified/pin-mongos.json | 24 +- test/transactions/unified/read-concern.json | 40 +- test/transactions/unified/read-pref.json | 20 +- test/transactions/unified/reads.json | 22 +- .../unified/retryable-abort-errorLabels.json | 38 +- .../transactions/unified/retryable-abort.json | 14 +- .../unified/retryable-commit-errorLabels.json | 40 +- .../unified/retryable-commit.json | 16 +- .../unified/retryable-writes.json | 8 +- test/transactions/unified/run-command.json | 4 +- .../unified/transaction-options-repl.json | 6 +- .../unified/transaction-options.json | 40 +- test/transactions/unified/update.json | 8 +- test/transactions/unified/write-concern.json | 34 +- .../valid-fail/operator-matchAsDocument.json | 4 +- .../valid-fail/operator-matchAsRoot.json | 4 +- .../returnDocument-enum-invalid.json | 2 +- .../expectedError-errorResponse.json | 2 +- .../expectedError-isClientError.json | 2 +- .../valid-pass/operator-matchAsDocument.json | 4 +- .../valid-pass/operator-matchAsRoot.json | 4 +- .../operator-type-number_alias.json | 4 +- .../valid-pass/poc-change-streams.json | 20 +- .../valid-pass/poc-command-monitoring.json | 6 +- .../valid-pass/poc-sessions.json | 10 +- .../poc-transactions-convenient-api.json | 14 +- .../poc-transactions-mongos-pin-auto.json | 8 +- .../valid-pass/poc-transactions.json | 26 +- test/utils_shared.py | 8 +- .../crud-api-version-1-strict.json | 4 +- test/versioned-api/crud-api-version-1.json | 4 +- test/versioned-api/transaction-handling.json | 4 +- 252 files changed, 4863 insertions(+), 4887 deletions(-) diff --git a/bson/raw_bson.py b/bson/raw_bson.py index 9ead0765dc..696d003541 100644 --- a/bson/raw_bson.py +++ b/bson/raw_bson.py @@ -28,14 +28,14 @@ >>> client.drop_database("db") >>> client.drop_database("replica_db") >>> db = client.db - >>> result = db.test.insert_many( + >>> result = db.coll.insert_many( ... [{"_id": 1, "a": 1}, {"_id": 2, "b": 1}, {"_id": 3, "c": 1}, {"_id": 4, "d": 1}] ... ) >>> replica_db = client.replica_db - >>> for doc in db.test.find(): + >>> for doc in db.coll.find(): ... print(f"raw document: {doc.raw}") ... print(f"decoded document: {bson.decode(doc.raw)}") - ... result = replica_db.test.insert_one(doc) + ... result = replica_db.coll.insert_one(doc) ... raw document: b'...' decoded document: {'_id': 1, 'a': 1} diff --git a/pymongo/_csot.py b/pymongo/_csot.py index ce72a66486..41171e5482 100644 --- a/pymongo/_csot.py +++ b/pymongo/_csot.py @@ -74,7 +74,7 @@ class _TimeoutContext(AbstractContextManager[Any]): Use :func:`pymongo.timeout` instead:: with pymongo.timeout(0.5): - client.test.test.insert_one({}) + client.db.coll.insert_one({}) """ def __init__(self, timeout: Optional[float]): diff --git a/pymongo/asynchronous/collection.py b/pymongo/asynchronous/collection.py index 4fff6650f1..280662eddc 100644 --- a/pymongo/asynchronous/collection.py +++ b/pymongo/asynchronous/collection.py @@ -715,7 +715,7 @@ async def bulk_write( :class:`~pymongo.operations.DeleteOne`, or :class:`~pymongo.operations.DeleteMany`). - >>> async for doc in db.test.find({}): + >>> async for doc in db.coll.find({}): ... print(doc) ... {'x': 1, '_id': ObjectId('54f62e60fba5226811f634ef')} @@ -725,7 +725,7 @@ async def bulk_write( >>> from pymongo import InsertOne, DeleteOne, ReplaceOne >>> requests = [InsertOne({'y': 1}), DeleteOne({'x': 1}), ... ReplaceOne({'w': 1}, {'z': 1}, upsert=True)] - >>> result = await db.test.bulk_write(requests) + >>> result = await db.coll.bulk_write(requests) >>> result.inserted_count 1 >>> result.deleted_count @@ -734,7 +734,7 @@ async def bulk_write( 0 >>> result.upserted_ids {2: ObjectId('54f62ee28891e756a6e1abd5')} - >>> async for doc in db.test.find({}): + >>> async for doc in db.coll.find({}): ... print(doc) ... {'x': 1, '_id': ObjectId('54f62e60fba5226811f634f0')} @@ -845,12 +845,12 @@ async def insert_one( ) -> InsertOneResult: """Insert a single document. - >>> await db.test.count_documents({'x': 1}) + >>> await db.coll.count_documents({'x': 1}) 0 - >>> result = await db.test.insert_one({'x': 1}) + >>> result = await db.coll.insert_one({'x': 1}) >>> result.inserted_id ObjectId('54f112defba522406c9cc208') - >>> await db.test.find_one({'x': 1}) + >>> await db.coll.find_one({'x': 1}) {'x': 1, '_id': ObjectId('54f112defba522406c9cc208')} :param document: The document to insert. Must be a mutable mapping @@ -911,12 +911,12 @@ async def insert_many( ) -> InsertManyResult: """Insert an iterable of documents. - >>> await db.test.count_documents({}) + >>> await db.coll.count_documents({}) 0 - >>> result = await db.test.insert_many([{'x': i} for i in range(2)]) + >>> result = await db.coll.insert_many([{'x': i} for i in range(2)]) >>> await result.inserted_ids [ObjectId('54f113fffba522406c9cc20e'), ObjectId('54f113fffba522406c9cc20f')] - >>> await db.test.count_documents({}) + >>> await db.coll.count_documents({}) 2 :param documents: A iterable of documents to insert. @@ -1137,16 +1137,16 @@ async def replace_one( ) -> UpdateResult: """Replace a single document matching the filter. - >>> async for doc in db.test.find({}): + >>> async for doc in db.coll.find({}): ... print(doc) ... {'x': 1, '_id': ObjectId('54f4c5befba5220aa4d6dee7')} - >>> result = await db.test.replace_one({'x': 1}, {'y': 1}) + >>> result = await db.coll.replace_one({'x': 1}, {'y': 1}) >>> result.matched_count 1 >>> result.modified_count 1 - >>> async for doc in db.test.find({}): + >>> async for doc in db.coll.find({}): ... print(doc) ... {'y': 1, '_id': ObjectId('54f4c5befba5220aa4d6dee7')} @@ -1154,14 +1154,14 @@ async def replace_one( The *upsert* option can be used to insert a new document if a matching document does not exist. - >>> result = await db.test.replace_one({'x': 1}, {'x': 1}, True) + >>> result = await db.coll.replace_one({'x': 1}, {'x': 1}, True) >>> result.matched_count 0 >>> result.modified_count 0 >>> result.upserted_id ObjectId('54f11e5c8891e756a6e1abd4') - >>> await db.test.find_one({'x': 1}) + >>> await db.coll.find_one({'x': 1}) {'x': 1, '_id': ObjectId('54f11e5c8891e756a6e1abd4')} :param filter: A query that matches the document to replace. @@ -1247,18 +1247,18 @@ async def update_one( ) -> UpdateResult: """Update a single document matching the filter. - >>> async for doc in db.test.find(): + >>> async for doc in db.coll.find(): ... print(doc) ... {'x': 1, '_id': 0} {'x': 1, '_id': 1} {'x': 1, '_id': 2} - >>> result = await db.test.update_one({'x': 1}, {'$inc': {'x': 3}}) + >>> result = await db.coll.update_one({'x': 1}, {'$inc': {'x': 3}}) >>> result.matched_count 1 >>> result.modified_count 1 - >>> async for doc in db.test.find(): + >>> async for doc in db.coll.find(): ... print(doc) ... {'x': 4, '_id': 0} @@ -1268,14 +1268,14 @@ async def update_one( If ``upsert=True`` and no documents match the filter, create a new document based on the filter criteria and update modifications. - >>> result = await db.test.update_one({'x': -10}, {'$inc': {'x': 3}}, upsert=True) + >>> result = await db.coll.update_one({'x': -10}, {'$inc': {'x': 3}}, upsert=True) >>> result.matched_count 0 >>> result.modified_count 0 >>> result.upserted_id ObjectId('626a678eeaa80587d4bb3fb7') - >>> await db.test.find_one(result.upserted_id) + >>> await db.coll.find_one(result.upserted_id) {'_id': ObjectId('626a678eeaa80587d4bb3fb7'), 'x': -7} :param filter: A query that matches the document to update. @@ -1366,18 +1366,18 @@ async def update_many( ) -> UpdateResult: """Update one or more documents that match the filter. - >>> async for doc in db.test.find(): + >>> async for doc in db.coll.find(): ... print(doc) ... {'x': 1, '_id': 0} {'x': 1, '_id': 1} {'x': 1, '_id': 2} - >>> result = await db.test.update_many({'x': 1}, {'$inc': {'x': 3}}) + >>> result = await db.coll.update_many({'x': 1}, {'$inc': {'x': 3}}) >>> result.matched_count 3 >>> result.modified_count 3 - >>> async for doc in db.test.find(): + >>> async for doc in db.coll.find(): ... print(doc) ... {'x': 4, '_id': 0} @@ -1602,12 +1602,12 @@ async def delete_one( ) -> DeleteResult: """Delete a single document matching the filter. - >>> await db.test.count_documents({'x': 1}) + >>> await db.coll.count_documents({'x': 1}) 3 - >>> result = await db.test.delete_one({'x': 1}) + >>> result = await db.coll.delete_one({'x': 1}) >>> result.deleted_count 1 - >>> await db.test.count_documents({'x': 1}) + >>> await db.coll.count_documents({'x': 1}) 2 :param filter: A query that matches the document to delete. @@ -1667,12 +1667,12 @@ async def delete_many( ) -> DeleteResult: """Delete one or more documents matching the filter. - >>> await db.test.count_documents({'x': 1}) + >>> await db.coll.count_documents({'x': 1}) 3 - >>> result = await db.test.delete_many({'x': 1}) + >>> result = await db.coll.delete_many({'x': 1}) >>> result.deleted_count 3 - >>> await db.test.count_documents({'x': 1}) + >>> await db.coll.count_documents({'x': 1}) 0 :param filter: A query that matches the documents to delete. @@ -1762,7 +1762,7 @@ def find(self, *args: Any, **kwargs: Any) -> AsyncCursor[_DocumentType]: The `filter` argument is a query document that all results must match. For example: - >>> db.test.find({"hello": "world"}) + >>> db.coll.find({"hello": "world"}) only matches documents that have a key "hello" with value "world". Matches can have other keys *in addition* to @@ -1965,7 +1965,7 @@ def find_raw_batches(self, *args: Any, **kwargs: Any) -> AsyncRawBatchCursor[_Do :mod:`bson` module. >>> import bson - >>> cursor = db.test.find_raw_batches() + >>> cursor = db.coll.find_raw_batches() >>> async for batch in cursor: ... print(bson.decode_all(batch)) @@ -2191,7 +2191,7 @@ async def create_indexes( >>> index1 = IndexModel([("hello", DESCENDING), ... ("world", ASCENDING)], name="hello_world") >>> index2 = IndexModel([("goodbye", DESCENDING)]) - >>> await db.test.create_indexes([index1, index2]) + >>> await db.coll.create_indexes([index1, index2]) ["hello_world", "goodbye_-1"] :param indexes: A list of :class:`~pymongo.operations.IndexModel` @@ -2517,7 +2517,7 @@ async def list_indexes( ) -> AsyncCommandCursor[MutableMapping[str, Any]]: """Get a cursor over the index documents for this collection. - >>> async for index in await db.test.list_indexes(): + >>> async for index in await db.coll.list_indexes(): ... print(index) ... SON([('v', 2), ('key', SON([('_id', 1)])), ('name', '_id_')]) @@ -2612,9 +2612,9 @@ async def index_information( ``"name"`` keys, which are cleaned. Example output might look like this: - >>> await db.test.create_index("x", unique=True) + >>> await db.coll.create_index("x", unique=True) 'x_1' - >>> await db.test.index_information() + >>> await db.coll.index_information() {'_id_': {'key': [('_id', 1)]}, 'x_1': {'unique': True, 'key': [('x', 1)]}} @@ -3070,7 +3070,7 @@ async def aggregate_raw_batches( :mod:`bson` module. >>> import bson - >>> cursor = await db.test.aggregate_raw_batches([ + >>> cursor = await db.coll.aggregate_raw_batches([ ... {'$project': {'x': {'$multiply': [2, '$x']}}}]) >>> async for batch in cursor: ... print(bson.decode_all(batch)) @@ -3345,32 +3345,32 @@ async def find_one_and_delete( ) -> Optional[_DocumentType]: """Finds a single document and deletes it, returning the document. - >>> await db.test.count_documents({'x': 1}) + >>> await db.coll.count_documents({'x': 1}) 2 - >>> await db.test.find_one_and_delete({'x': 1}) + >>> await db.coll.find_one_and_delete({'x': 1}) {'x': 1, '_id': ObjectId('54f4e12bfba5220aa4d6dee8')} - >>> await db.test.count_documents({'x': 1}) + >>> await db.coll.count_documents({'x': 1}) 1 Returns ``None`` if no document matches the filter. - >>> await db.test.find_one_and_delete({'_exists': False}) + >>> await db.coll.find_one_and_delete({'_exists': False}) If multiple documents match *filter*, a *sort* can be applied. - >>> async for doc in db.test.find({'x': 1}): + >>> async for doc in db.coll.find({'x': 1}): ... print(doc) ... {'x': 1, '_id': 0} {'x': 1, '_id': 1} {'x': 1, '_id': 2} - >>> await db.test.find_one_and_delete( + >>> await db.coll.find_one_and_delete( ... {'x': 1}, sort=[('_id', pymongo.DESCENDING)]) {'x': 1, '_id': 2} The *projection* option can be used to limit the fields returned. - >>> await db.test.find_one_and_delete({'x': 1}, projection={'_id': False}) + >>> await db.coll.find_one_and_delete({'x': 1}, projection={'_id': False}) {'x': 1} :param filter: A query that matches the document to delete. @@ -3442,31 +3442,31 @@ async def find_one_and_replace( """Finds a single document and replaces it, returning either the original or the replaced document. - >>> await db.test.find_one({'x': 1}) + >>> await db.coll.find_one({'x': 1}) {'_id': 0, 'x': 1} - >>> await db.test.find_one_and_replace({'x': 1}, {'y': 2}) + >>> await db.coll.find_one_and_replace({'x': 1}, {'y': 2}) {'_id': 0, 'x': 1} - >>> await db.test.find_one({'x': 1}) - >>> await db.test.find_one({'y': 2}) + >>> await db.coll.find_one({'x': 1}) + >>> await db.coll.find_one({'y': 2}) {'_id': 0, 'y': 2} Returns ``None`` if no document matches the filter. - >>> await db.test.find_one_and_replace({'_exists': False}, {'x': 1}) + >>> await db.coll.find_one_and_replace({'_exists': False}, {'x': 1}) The :meth:`find_one_and_replace` method differs from :meth:`find_one_and_update` by replacing the document matched by *filter*, rather than modifying the existing document. - >>> async for doc in db.test.find({}): + >>> async for doc in db.coll.find({}): ... print(doc) ... {'x': 1, '_id': 0} {'x': 1, '_id': 1} {'x': 1, '_id': 2} - >>> await db.test.find_one_and_replace({'x': 1}, {'y': 1}) + >>> await db.coll.find_one_and_replace({'x': 1}, {'y': 1}) {'x': 1, '_id': 0} - >>> async for doc in db.test.find({}): + >>> async for doc in db.coll.find({}): ... print(doc) ... {'y': 1, '_id': 0} @@ -3562,17 +3562,17 @@ async def find_one_and_update( """Finds a single document and updates it, returning either the original or the updated document. - >>> await db.test.find_one({'_id': 665}) + >>> await db.coll.find_one({'_id': 665}) {'_id': 665, 'done': False, 'count': 25} - >>> await db.test.find_one_and_update( + >>> await db.coll.find_one_and_update( ... {'_id': 665}, {'$inc': {'count': 1}, '$set': {'done': True}}) {'_id': 665, 'done': False, 'count': 25} - >>> await db.test.find_one({'_id': 665}) + >>> await db.coll.find_one({'_id': 665}) {'_id': 665, 'done': True, 'count': 26} Returns ``None`` if no document matches the filter. - >>> await db.test.find_one_and_update( + >>> await db.coll.find_one_and_update( ... {'_exists': False}, {'$inc': {'count': 1}}) When the filter matches, by default :meth:`find_one_and_update` @@ -3612,12 +3612,12 @@ async def find_one_and_update( If multiple documents match *filter*, a *sort* can be applied. - >>> async for doc in db.test.find({'done': True}): + >>> async for doc in db.coll.find({'done': True}): ... print(doc) ... {'_id': 665, 'done': True, 'result': {'count': 26}} {'_id': 701, 'done': True, 'result': {'count': 17}} - >>> await db.test.find_one_and_update( + >>> await db.coll.find_one_and_update( ... {'done': True}, ... {'$set': {'final': True}}, ... sort=[('_id', pymongo.DESCENDING)]) diff --git a/pymongo/asynchronous/cursor.py b/pymongo/asynchronous/cursor.py index 4e3adc1809..dda926c6a8 100644 --- a/pymongo/asynchronous/cursor.py +++ b/pymongo/asynchronous/cursor.py @@ -561,7 +561,7 @@ def __getitem__( To get a single document use an integral index, e.g.:: - >>> db.test.find()[50] + >>> db.coll.find()[50] An :class:`IndexError` will be raised if the index is negative or greater than the amount of documents in this cursor. Any @@ -569,7 +569,7 @@ def __getitem__( To get a slice of documents use a slice index, e.g.:: - >>> db.test.find()[20:25] + >>> db.coll.find()[20:25] This will return this cursor with a limit of ``5`` and skip of ``20`` applied. Using a slice index will override any prior @@ -707,7 +707,7 @@ def sort( Text search results can be sorted by relevance:: - cursor = db.test.find( + cursor = db.coll.find( {'$text': {'$search': 'some words'}}, {'score': {'$meta': 'textScore'}}) @@ -815,7 +815,7 @@ def where(self, code: Union[str, Code]) -> AsyncCursor[_DocumentType]: to the object currently being scanned. For example:: # Find all documents where field "a" is less than "b" plus "c". - async for doc in db.test.find().where('this.a < (this.b + this.c)'): + async for doc in db.coll.find().where('this.a < (this.b + this.c)'): print(doc) Raises :class:`TypeError` if `code` is not an instance of diff --git a/pymongo/asynchronous/database.py b/pymongo/asynchronous/database.py index 28ed36073c..024abc04d8 100644 --- a/pymongo/asynchronous/database.py +++ b/pymongo/asynchronous/database.py @@ -266,7 +266,7 @@ def get_collection( >>> db.read_preference Primary() - >>> coll1 = db.test + >>> coll1 = db.coll >>> coll1.read_preference Primary() >>> from pymongo import ReadPreference diff --git a/pymongo/asynchronous/mongo_client.py b/pymongo/asynchronous/mongo_client.py index 412a13ec70..3d26793927 100644 --- a/pymongo/asynchronous/mongo_client.py +++ b/pymongo/asynchronous/mongo_client.py @@ -2513,7 +2513,7 @@ async def bulk_write( :class:`~pymongo.operations.DeleteOne`, or :class:`~pymongo.operations.DeleteMany`). - >>> async for doc in db.test.find({}): + >>> async for doc in db.coll.find({}): ... print(doc) ... {'x': 1, '_id': ObjectId('54f62e60fba5226811f634ef')} @@ -2526,10 +2526,10 @@ async def bulk_write( ... >>> # DeleteMany, UpdateOne, and UpdateMany are also available. >>> from pymongo import InsertOne, DeleteOne, ReplaceOne - >>> models = [InsertOne(namespace="db.test", document={'y': 1}), - ... DeleteOne(namespace="db.test", filter={'x': 1}), + >>> models = [InsertOne(namespace="db.coll", document={'y': 1}), + ... DeleteOne(namespace="db.coll", filter={'x': 1}), ... InsertOne(namespace="db.coll", document={'y': 2}), - ... ReplaceOne(namespace="db.test", filter={'w': 1}, replacement={'z': 1}, upsert=True)] + ... ReplaceOne(namespace="db.coll", filter={'w': 1}, replacement={'z': 1}, upsert=True)] >>> result = await client.bulk_write(models=models) >>> result.inserted_count 2 @@ -2539,7 +2539,7 @@ async def bulk_write( 0 >>> result.upserted_count 1 - >>> async for doc in db.test.find({}): + >>> async for doc in db.coll.find({}): ... print(doc) ... {'x': 1, '_id': ObjectId('54f62e60fba5226811f634f0')} diff --git a/pymongo/synchronous/collection.py b/pymongo/synchronous/collection.py index 1057151e59..7753371a5a 100644 --- a/pymongo/synchronous/collection.py +++ b/pymongo/synchronous/collection.py @@ -714,7 +714,7 @@ def bulk_write( :class:`~pymongo.operations.DeleteOne`, or :class:`~pymongo.operations.DeleteMany`). - >>> for doc in db.test.find({}): + >>> for doc in db.coll.find({}): ... print(doc) ... {'x': 1, '_id': ObjectId('54f62e60fba5226811f634ef')} @@ -724,7 +724,7 @@ def bulk_write( >>> from pymongo import InsertOne, DeleteOne, ReplaceOne >>> requests = [InsertOne({'y': 1}), DeleteOne({'x': 1}), ... ReplaceOne({'w': 1}, {'z': 1}, upsert=True)] - >>> result = db.test.bulk_write(requests) + >>> result = db.coll.bulk_write(requests) >>> result.inserted_count 1 >>> result.deleted_count @@ -733,7 +733,7 @@ def bulk_write( 0 >>> result.upserted_ids {2: ObjectId('54f62ee28891e756a6e1abd5')} - >>> for doc in db.test.find({}): + >>> for doc in db.coll.find({}): ... print(doc) ... {'x': 1, '_id': ObjectId('54f62e60fba5226811f634f0')} @@ -844,12 +844,12 @@ def insert_one( ) -> InsertOneResult: """Insert a single document. - >>> db.test.count_documents({'x': 1}) + >>> db.coll.count_documents({'x': 1}) 0 - >>> result = db.test.insert_one({'x': 1}) + >>> result = db.coll.insert_one({'x': 1}) >>> result.inserted_id ObjectId('54f112defba522406c9cc208') - >>> db.test.find_one({'x': 1}) + >>> db.coll.find_one({'x': 1}) {'x': 1, '_id': ObjectId('54f112defba522406c9cc208')} :param document: The document to insert. Must be a mutable mapping @@ -910,12 +910,12 @@ def insert_many( ) -> InsertManyResult: """Insert an iterable of documents. - >>> db.test.count_documents({}) + >>> db.coll.count_documents({}) 0 - >>> result = db.test.insert_many([{'x': i} for i in range(2)]) + >>> result = db.coll.insert_many([{'x': i} for i in range(2)]) >>> result.inserted_ids [ObjectId('54f113fffba522406c9cc20e'), ObjectId('54f113fffba522406c9cc20f')] - >>> db.test.count_documents({}) + >>> db.coll.count_documents({}) 2 :param documents: A iterable of documents to insert. @@ -1136,16 +1136,16 @@ def replace_one( ) -> UpdateResult: """Replace a single document matching the filter. - >>> for doc in db.test.find({}): + >>> for doc in db.coll.find({}): ... print(doc) ... {'x': 1, '_id': ObjectId('54f4c5befba5220aa4d6dee7')} - >>> result = db.test.replace_one({'x': 1}, {'y': 1}) + >>> result = db.coll.replace_one({'x': 1}, {'y': 1}) >>> result.matched_count 1 >>> result.modified_count 1 - >>> for doc in db.test.find({}): + >>> for doc in db.coll.find({}): ... print(doc) ... {'y': 1, '_id': ObjectId('54f4c5befba5220aa4d6dee7')} @@ -1153,14 +1153,14 @@ def replace_one( The *upsert* option can be used to insert a new document if a matching document does not exist. - >>> result = db.test.replace_one({'x': 1}, {'x': 1}, True) + >>> result = db.coll.replace_one({'x': 1}, {'x': 1}, True) >>> result.matched_count 0 >>> result.modified_count 0 >>> result.upserted_id ObjectId('54f11e5c8891e756a6e1abd4') - >>> db.test.find_one({'x': 1}) + >>> db.coll.find_one({'x': 1}) {'x': 1, '_id': ObjectId('54f11e5c8891e756a6e1abd4')} :param filter: A query that matches the document to replace. @@ -1246,18 +1246,18 @@ def update_one( ) -> UpdateResult: """Update a single document matching the filter. - >>> for doc in db.test.find(): + >>> for doc in db.coll.find(): ... print(doc) ... {'x': 1, '_id': 0} {'x': 1, '_id': 1} {'x': 1, '_id': 2} - >>> result = db.test.update_one({'x': 1}, {'$inc': {'x': 3}}) + >>> result = db.coll.update_one({'x': 1}, {'$inc': {'x': 3}}) >>> result.matched_count 1 >>> result.modified_count 1 - >>> for doc in db.test.find(): + >>> for doc in db.coll.find(): ... print(doc) ... {'x': 4, '_id': 0} @@ -1267,14 +1267,14 @@ def update_one( If ``upsert=True`` and no documents match the filter, create a new document based on the filter criteria and update modifications. - >>> result = db.test.update_one({'x': -10}, {'$inc': {'x': 3}}, upsert=True) + >>> result = db.coll.update_one({'x': -10}, {'$inc': {'x': 3}}, upsert=True) >>> result.matched_count 0 >>> result.modified_count 0 >>> result.upserted_id ObjectId('626a678eeaa80587d4bb3fb7') - >>> db.test.find_one(result.upserted_id) + >>> db.coll.find_one(result.upserted_id) {'_id': ObjectId('626a678eeaa80587d4bb3fb7'), 'x': -7} :param filter: A query that matches the document to update. @@ -1365,18 +1365,18 @@ def update_many( ) -> UpdateResult: """Update one or more documents that match the filter. - >>> for doc in db.test.find(): + >>> for doc in db.coll.find(): ... print(doc) ... {'x': 1, '_id': 0} {'x': 1, '_id': 1} {'x': 1, '_id': 2} - >>> result = db.test.update_many({'x': 1}, {'$inc': {'x': 3}}) + >>> result = db.coll.update_many({'x': 1}, {'$inc': {'x': 3}}) >>> result.matched_count 3 >>> result.modified_count 3 - >>> for doc in db.test.find(): + >>> for doc in db.coll.find(): ... print(doc) ... {'x': 4, '_id': 0} @@ -1601,12 +1601,12 @@ def delete_one( ) -> DeleteResult: """Delete a single document matching the filter. - >>> db.test.count_documents({'x': 1}) + >>> db.coll.count_documents({'x': 1}) 3 - >>> result = db.test.delete_one({'x': 1}) + >>> result = db.coll.delete_one({'x': 1}) >>> result.deleted_count 1 - >>> db.test.count_documents({'x': 1}) + >>> db.coll.count_documents({'x': 1}) 2 :param filter: A query that matches the document to delete. @@ -1666,12 +1666,12 @@ def delete_many( ) -> DeleteResult: """Delete one or more documents matching the filter. - >>> db.test.count_documents({'x': 1}) + >>> db.coll.count_documents({'x': 1}) 3 - >>> result = db.test.delete_many({'x': 1}) + >>> result = db.coll.delete_many({'x': 1}) >>> result.deleted_count 3 - >>> db.test.count_documents({'x': 1}) + >>> db.coll.count_documents({'x': 1}) 0 :param filter: A query that matches the documents to delete. @@ -1761,7 +1761,7 @@ def find(self, *args: Any, **kwargs: Any) -> Cursor[_DocumentType]: The `filter` argument is a query document that all results must match. For example: - >>> db.test.find({"hello": "world"}) + >>> db.coll.find({"hello": "world"}) only matches documents that have a key "hello" with value "world". Matches can have other keys *in addition* to @@ -1964,7 +1964,7 @@ def find_raw_batches(self, *args: Any, **kwargs: Any) -> RawBatchCursor[_Documen :mod:`bson` module. >>> import bson - >>> cursor = db.test.find_raw_batches() + >>> cursor = db.coll.find_raw_batches() >>> for batch in cursor: ... print(bson.decode_all(batch)) @@ -2188,7 +2188,7 @@ def create_indexes( >>> index1 = IndexModel([("hello", DESCENDING), ... ("world", ASCENDING)], name="hello_world") >>> index2 = IndexModel([("goodbye", DESCENDING)]) - >>> db.test.create_indexes([index1, index2]) + >>> db.coll.create_indexes([index1, index2]) ["hello_world", "goodbye_-1"] :param indexes: A list of :class:`~pymongo.operations.IndexModel` @@ -2512,7 +2512,7 @@ def list_indexes( ) -> CommandCursor[MutableMapping[str, Any]]: """Get a cursor over the index documents for this collection. - >>> for index in db.test.list_indexes(): + >>> for index in db.coll.list_indexes(): ... print(index) ... SON([('v', 2), ('key', SON([('_id', 1)])), ('name', '_id_')]) @@ -2607,9 +2607,9 @@ def index_information( ``"name"`` keys, which are cleaned. Example output might look like this: - >>> db.test.create_index("x", unique=True) + >>> db.coll.create_index("x", unique=True) 'x_1' - >>> db.test.index_information() + >>> db.coll.index_information() {'_id_': {'key': [('_id', 1)]}, 'x_1': {'unique': True, 'key': [('x', 1)]}} @@ -3063,7 +3063,7 @@ def aggregate_raw_batches( :mod:`bson` module. >>> import bson - >>> cursor = db.test.aggregate_raw_batches([ + >>> cursor = db.coll.aggregate_raw_batches([ ... {'$project': {'x': {'$multiply': [2, '$x']}}}]) >>> for batch in cursor: ... print(bson.decode_all(batch)) @@ -3338,32 +3338,32 @@ def find_one_and_delete( ) -> Optional[_DocumentType]: """Finds a single document and deletes it, returning the document. - >>> db.test.count_documents({'x': 1}) + >>> db.coll.count_documents({'x': 1}) 2 - >>> db.test.find_one_and_delete({'x': 1}) + >>> db.coll.find_one_and_delete({'x': 1}) {'x': 1, '_id': ObjectId('54f4e12bfba5220aa4d6dee8')} - >>> db.test.count_documents({'x': 1}) + >>> db.coll.count_documents({'x': 1}) 1 Returns ``None`` if no document matches the filter. - >>> db.test.find_one_and_delete({'_exists': False}) + >>> db.coll.find_one_and_delete({'_exists': False}) If multiple documents match *filter*, a *sort* can be applied. - >>> for doc in db.test.find({'x': 1}): + >>> for doc in db.coll.find({'x': 1}): ... print(doc) ... {'x': 1, '_id': 0} {'x': 1, '_id': 1} {'x': 1, '_id': 2} - >>> db.test.find_one_and_delete( + >>> db.coll.find_one_and_delete( ... {'x': 1}, sort=[('_id', pymongo.DESCENDING)]) {'x': 1, '_id': 2} The *projection* option can be used to limit the fields returned. - >>> db.test.find_one_and_delete({'x': 1}, projection={'_id': False}) + >>> db.coll.find_one_and_delete({'x': 1}, projection={'_id': False}) {'x': 1} :param filter: A query that matches the document to delete. @@ -3435,31 +3435,31 @@ def find_one_and_replace( """Finds a single document and replaces it, returning either the original or the replaced document. - >>> db.test.find_one({'x': 1}) + >>> db.coll.find_one({'x': 1}) {'_id': 0, 'x': 1} - >>> db.test.find_one_and_replace({'x': 1}, {'y': 2}) + >>> db.coll.find_one_and_replace({'x': 1}, {'y': 2}) {'_id': 0, 'x': 1} - >>> db.test.find_one({'x': 1}) - >>> db.test.find_one({'y': 2}) + >>> db.coll.find_one({'x': 1}) + >>> db.coll.find_one({'y': 2}) {'_id': 0, 'y': 2} Returns ``None`` if no document matches the filter. - >>> db.test.find_one_and_replace({'_exists': False}, {'x': 1}) + >>> db.coll.find_one_and_replace({'_exists': False}, {'x': 1}) The :meth:`find_one_and_replace` method differs from :meth:`find_one_and_update` by replacing the document matched by *filter*, rather than modifying the existing document. - >>> for doc in db.test.find({}): + >>> for doc in db.coll.find({}): ... print(doc) ... {'x': 1, '_id': 0} {'x': 1, '_id': 1} {'x': 1, '_id': 2} - >>> db.test.find_one_and_replace({'x': 1}, {'y': 1}) + >>> db.coll.find_one_and_replace({'x': 1}, {'y': 1}) {'x': 1, '_id': 0} - >>> for doc in db.test.find({}): + >>> for doc in db.coll.find({}): ... print(doc) ... {'y': 1, '_id': 0} @@ -3555,17 +3555,17 @@ def find_one_and_update( """Finds a single document and updates it, returning either the original or the updated document. - >>> db.test.find_one({'_id': 665}) + >>> db.coll.find_one({'_id': 665}) {'_id': 665, 'done': False, 'count': 25} - >>> db.test.find_one_and_update( + >>> db.coll.find_one_and_update( ... {'_id': 665}, {'$inc': {'count': 1}, '$set': {'done': True}}) {'_id': 665, 'done': False, 'count': 25} - >>> db.test.find_one({'_id': 665}) + >>> db.coll.find_one({'_id': 665}) {'_id': 665, 'done': True, 'count': 26} Returns ``None`` if no document matches the filter. - >>> db.test.find_one_and_update( + >>> db.coll.find_one_and_update( ... {'_exists': False}, {'$inc': {'count': 1}}) When the filter matches, by default :meth:`find_one_and_update` @@ -3605,12 +3605,12 @@ def find_one_and_update( If multiple documents match *filter*, a *sort* can be applied. - >>> for doc in db.test.find({'done': True}): + >>> for doc in db.coll.find({'done': True}): ... print(doc) ... {'_id': 665, 'done': True, 'result': {'count': 26}} {'_id': 701, 'done': True, 'result': {'count': 17}} - >>> db.test.find_one_and_update( + >>> db.coll.find_one_and_update( ... {'done': True}, ... {'$set': {'final': True}}, ... sort=[('_id', pymongo.DESCENDING)]) diff --git a/pymongo/synchronous/cursor.py b/pymongo/synchronous/cursor.py index 8085d58669..276b03072d 100644 --- a/pymongo/synchronous/cursor.py +++ b/pymongo/synchronous/cursor.py @@ -559,7 +559,7 @@ def __getitem__(self, index: Union[int, slice]) -> Union[_DocumentType, Cursor[_ To get a single document use an integral index, e.g.:: - >>> db.test.find()[50] + >>> db.coll.find()[50] An :class:`IndexError` will be raised if the index is negative or greater than the amount of documents in this cursor. Any @@ -567,7 +567,7 @@ def __getitem__(self, index: Union[int, slice]) -> Union[_DocumentType, Cursor[_ To get a slice of documents use a slice index, e.g.:: - >>> db.test.find()[20:25] + >>> db.coll.find()[20:25] This will return this cursor with a limit of ``5`` and skip of ``20`` applied. Using a slice index will override any prior @@ -705,7 +705,7 @@ def sort( Text search results can be sorted by relevance:: - cursor = db.test.find( + cursor = db.coll.find( {'$text': {'$search': 'some words'}}, {'score': {'$meta': 'textScore'}}) @@ -813,7 +813,7 @@ def where(self, code: Union[str, Code]) -> Cursor[_DocumentType]: to the object currently being scanned. For example:: # Find all documents where field "a" is less than "b" plus "c". - for doc in db.test.find().where('this.a < (this.b + this.c)'): + for doc in db.coll.find().where('this.a < (this.b + this.c)'): print(doc) Raises :class:`TypeError` if `code` is not an instance of diff --git a/pymongo/synchronous/database.py b/pymongo/synchronous/database.py index 1956795bcb..4eb2157391 100644 --- a/pymongo/synchronous/database.py +++ b/pymongo/synchronous/database.py @@ -266,7 +266,7 @@ def get_collection( >>> db.read_preference Primary() - >>> coll1 = db.test + >>> coll1 = db.coll >>> coll1.read_preference Primary() >>> from pymongo import ReadPreference diff --git a/pymongo/synchronous/mongo_client.py b/pymongo/synchronous/mongo_client.py index 2bd6f31b72..14cb09fdd8 100644 --- a/pymongo/synchronous/mongo_client.py +++ b/pymongo/synchronous/mongo_client.py @@ -2503,7 +2503,7 @@ def bulk_write( :class:`~pymongo.operations.DeleteOne`, or :class:`~pymongo.operations.DeleteMany`). - >>> for doc in db.test.find({}): + >>> for doc in db.coll.find({}): ... print(doc) ... {'x': 1, '_id': ObjectId('54f62e60fba5226811f634ef')} @@ -2516,10 +2516,10 @@ def bulk_write( ... >>> # DeleteMany, UpdateOne, and UpdateMany are also available. >>> from pymongo import InsertOne, DeleteOne, ReplaceOne - >>> models = [InsertOne(namespace="db.test", document={'y': 1}), - ... DeleteOne(namespace="db.test", filter={'x': 1}), + >>> models = [InsertOne(namespace="db.coll", document={'y': 1}), + ... DeleteOne(namespace="db.coll", filter={'x': 1}), ... InsertOne(namespace="db.coll", document={'y': 2}), - ... ReplaceOne(namespace="db.test", filter={'w': 1}, replacement={'z': 1}, upsert=True)] + ... ReplaceOne(namespace="db.coll", filter={'w': 1}, replacement={'z': 1}, upsert=True)] >>> result = client.bulk_write(models=models) >>> result.inserted_count 2 @@ -2529,7 +2529,7 @@ def bulk_write( 0 >>> result.upserted_count 1 - >>> for doc in db.test.find({}): + >>> for doc in db.coll.find({}): ... print(doc) ... {'x': 1, '_id': ObjectId('54f62e60fba5226811f634f0')} diff --git a/test/__init__.py b/test/__init__.py index 8540c442e0..8e2851b7e1 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -1163,7 +1163,7 @@ def setUp(self) -> None: if client_context.load_balancer and not getattr(self, "RUN_ON_LOAD_BALANCER", False): raise SkipTest("this test does not support load balancers") self.client = client_context.client - self.db = self.client.pymongo_test + self.db = self.client.db if client_context.auth_enabled: self.credentials = {"username": db_user, "password": db_pwd} else: diff --git a/test/asynchronous/__init__.py b/test/asynchronous/__init__.py index 4dde0acf1f..251f4fbf4a 100644 --- a/test/asynchronous/__init__.py +++ b/test/asynchronous/__init__.py @@ -1179,7 +1179,7 @@ async def asyncSetUp(self) -> None: if async_client_context.load_balancer and not getattr(self, "RUN_ON_LOAD_BALANCER", False): raise SkipTest("this test does not support load balancers") self.client = async_client_context.client - self.db = self.client.pymongo_test + self.db = self.client.db if async_client_context.auth_enabled: self.credentials = {"username": db_user, "password": db_pwd} else: diff --git a/test/asynchronous/test_async_cancellation.py b/test/asynchronous/test_async_cancellation.py index f450ea23cc..a41ca9b5b1 100644 --- a/test/asynchronous/test_async_cancellation.py +++ b/test/asynchronous/test_async_cancellation.py @@ -28,13 +28,13 @@ class TestAsyncCancellation(AsyncIntegrationTest): async def test_async_cancellation_closes_connection(self): pool = await async_get_pool(self.client) - await self.client.db.test.insert_one({"x": 1}) - self.addAsyncCleanup(self.client.db.test.delete_many, {}) + await self.client.db.coll.insert_one({"x": 1}) + self.addAsyncCleanup(self.client.db.coll.delete_many, {}) conn = one(pool.conns) async def task(): - await self.client.db.test.find_one({"$where": delay(0.2)}) + await self.client.db.coll.find_one({"$where": delay(0.2)}) task = asyncio.create_task(task()) @@ -48,13 +48,13 @@ async def task(): @async_client_context.require_transactions async def test_async_cancellation_aborts_transaction(self): - await self.client.db.test.insert_one({"x": 1}) - self.addAsyncCleanup(self.client.db.test.delete_many, {}) + await self.client.db.coll.insert_one({"x": 1}) + self.addAsyncCleanup(self.client.db.coll.delete_many, {}) session = self.client.start_session() async def callback(session): - await self.client.db.test.find_one({"$where": delay(0.2)}, session=session) + await self.client.db.coll.find_one({"$where": delay(0.2)}, session=session) async def task(): await session.with_transaction(callback) @@ -71,10 +71,10 @@ async def task(): @async_client_context.require_failCommand_blockConnection async def test_async_cancellation_closes_cursor(self): - await self.client.db.test.insert_many([{"x": 1}, {"x": 2}]) - self.addAsyncCleanup(self.client.db.test.delete_many, {}) + await self.client.db.coll.insert_many([{"x": 1}, {"x": 2}]) + self.addAsyncCleanup(self.client.db.coll.delete_many, {}) - cursor = self.client.db.test.find({}, batch_size=1) + cursor = self.client.db.coll.find({}, batch_size=1) await cursor.next() # Make sure getMore commands block @@ -101,8 +101,8 @@ async def task(): @async_client_context.require_change_streams @async_client_context.require_failCommand_blockConnection async def test_async_cancellation_closes_change_stream(self): - self.addAsyncCleanup(self.client.db.test.delete_many, {}) - change_stream = await self.client.db.test.watch(batch_size=2) + self.addAsyncCleanup(self.client.db.coll.delete_many, {}) + change_stream = await self.client.db.coll.watch(batch_size=2) event = asyncio.Event() # Make sure getMore commands block @@ -114,7 +114,7 @@ async def test_async_cancellation_closes_change_stream(self): async def task(): async with self.fail_point(fail_command): - await self.client.db.test.insert_many([{"x": 1}, {"x": 2}]) + await self.client.db.coll.insert_many([{"x": 1}, {"x": 2}]) event.set() await change_stream.next() diff --git a/test/asynchronous/test_async_contextvars_reset.py b/test/asynchronous/test_async_contextvars_reset.py index c6e825bbdf..8193cd2774 100644 --- a/test/asynchronous/test_async_contextvars_reset.py +++ b/test/asynchronous/test_async_contextvars_reset.py @@ -30,7 +30,7 @@ async def test_context_vars_are_reset_in_executor(self): if sys.version_info < (3, 12): self.skipTest("Test requires asyncio.Task.get_context (added in Python 3.12)") - await self.client.db.test.insert_one({"x": 1}) + await self.client.db.coll.insert_one({"x": 1}) for server in self.client._topology._servers.values(): for context in [ c @@ -38,4 +38,4 @@ async def test_context_vars_are_reset_in_executor(self): if c.name in ["TIMEOUT", "RTT", "DEADLINE"] ]: self.assertIn(context.get(), [None, float("inf"), 0.0]) - await self.client.db.test.delete_many({}) + await self.client.db.coll.delete_many({}) diff --git a/test/asynchronous/test_auth.py b/test/asynchronous/test_auth.py index 904674db16..922fbd813a 100644 --- a/test/asynchronous/test_auth.py +++ b/test/asynchronous/test_auth.py @@ -231,7 +231,7 @@ async def test_gssapi_threaded(self): # collection.find_one with a 1-second delay, forcing it to check out # multiple connections from the pool concurrently, proving that # auto-authentication works with GSSAPI. - collection = db.test + collection = db.coll if not await collection.count_documents({}): try: await collection.drop() @@ -403,11 +403,11 @@ class TestSCRAMSHA1(AsyncIntegrationTest): async def asyncSetUp(self): await super().asyncSetUp() await async_client_context.create_user( - "pymongo_test", "user", "pass", roles=["userAdmin", "readWrite"] + "db", "user", "pass", roles=["userAdmin", "readWrite"] ) async def asyncTearDown(self): - await async_client_context.drop_user("pymongo_test", "user") + await async_client_context.drop_user("db", "user") await super().asyncTearDown() @async_client_context.require_no_fips @@ -415,19 +415,19 @@ async def test_scram_sha1(self): host, port = await async_client_context.host, await async_client_context.port client = await self.async_rs_or_single_client_noauth( - "mongodb://user:pass@%s:%d/pymongo_test?authMechanism=SCRAM-SHA-1" % (host, port) + "mongodb://user:pass@%s:%d/db?authMechanism=SCRAM-SHA-1" % (host, port) ) - await client.pymongo_test.command("dbstats") + await client.db.command("dbstats") if async_client_context.is_rs: - uri = ( - "mongodb://user:pass" - "@%s:%d/pymongo_test?authMechanism=SCRAM-SHA-1" - "&replicaSet=%s" % (host, port, async_client_context.replica_set_name) + uri = "mongodb://user:pass" "@%s:%d/db?authMechanism=SCRAM-SHA-1" "&replicaSet=%s" % ( + host, + port, + async_client_context.replica_set_name, ) client = await self.async_single_client_noauth(uri) - await client.pymongo_test.command("dbstats") - db = client.get_database("pymongo_test", read_preference=ReadPreference.SECONDARY) + await client.db.command("dbstats") + db = client.get_database("db", read_preference=ReadPreference.SECONDARY) await db.command("dbstats") @@ -654,13 +654,13 @@ async def test_cache(self): @async_client_context.require_sync async def test_scram_threaded(self): - coll = async_client_context.client.db.test + coll = async_client_context.client.db.coll await coll.drop() await coll.insert_one({"_id": 1}) # The first thread to call find() will authenticate client = await self.async_rs_or_single_client() - coll = client.db.test + coll = client.db.coll threads = [] for _ in range(4): threads.append(AutoAuthenticateThread(coll)) @@ -676,12 +676,10 @@ class TestAuthURIOptions(AsyncIntegrationTest): async def asyncSetUp(self): await super().asyncSetUp() await async_client_context.create_user("admin", "admin", "pass") - await async_client_context.create_user( - "pymongo_test", "user", "pass", ["userAdmin", "readWrite"] - ) + await async_client_context.create_user("db", "user", "pass", ["userAdmin", "readWrite"]) async def asyncTearDown(self): - await async_client_context.drop_user("pymongo_test", "user") + await async_client_context.drop_user("db", "user") await async_client_context.drop_user("admin", "admin") await super().asyncTearDown() @@ -705,14 +703,14 @@ async def test_uri_options(self): self.assertTrue(await db.command("dbstats")) # Test explicit database - uri = "mongodb://user:pass@%s:%d/pymongo_test" % (host, port) + uri = "mongodb://user:pass@%s:%d/db" % (host, port) client = await self.async_rs_or_single_client_noauth(uri) with self.assertRaises(OperationFailure): await client.admin.command("dbstats") - self.assertTrue(await client.pymongo_test.command("dbstats")) + self.assertTrue(await client.db.command("dbstats")) if async_client_context.is_rs: - uri = "mongodb://user:pass@%s:%d/pymongo_test?replicaSet=%s" % ( + uri = "mongodb://user:pass@%s:%d/db?replicaSet=%s" % ( host, port, async_client_context.replica_set_name, @@ -720,27 +718,28 @@ async def test_uri_options(self): client = await self.async_single_client_noauth(uri) with self.assertRaises(OperationFailure): await client.admin.command("dbstats") - self.assertTrue(await client.pymongo_test.command("dbstats")) - db = client.get_database("pymongo_test", read_preference=ReadPreference.SECONDARY) + self.assertTrue(await client.db.command("dbstats")) + db = client.get_database("db", read_preference=ReadPreference.SECONDARY) self.assertTrue(await db.command("dbstats")) # Test authSource - uri = "mongodb://user:pass@%s:%d/pymongo_test2?authSource=pymongo_test" % (host, port) + uri = "mongodb://user:pass@%s:%d/db2?authSource=db" % (host, port) client = await self.async_rs_or_single_client_noauth(uri) with self.assertRaises(OperationFailure): - await client.pymongo_test2.command("dbstats") - self.assertTrue(await client.pymongo_test.command("dbstats")) + await client.db2.command("dbstats") + self.assertTrue(await client.db.command("dbstats")) if async_client_context.is_rs: - uri = ( - "mongodb://user:pass@%s:%d/pymongo_test2?replicaSet=" - "%s;authSource=pymongo_test" % (host, port, async_client_context.replica_set_name) + uri = "mongodb://user:pass@%s:%d/db2?replicaSet=" "%s;authSource=db" % ( + host, + port, + async_client_context.replica_set_name, ) client = await self.async_single_client_noauth(uri) with self.assertRaises(OperationFailure): - await client.pymongo_test2.command("dbstats") - self.assertTrue(await client.pymongo_test.command("dbstats")) - db = client.get_database("pymongo_test", read_preference=ReadPreference.SECONDARY) + await client.db2.command("dbstats") + self.assertTrue(await client.db.command("dbstats")) + db = client.get_database("db", read_preference=ReadPreference.SECONDARY) self.assertTrue(await db.command("dbstats")) diff --git a/test/asynchronous/test_auth_oidc.py b/test/asynchronous/test_auth_oidc.py index 3567d7706b..0c9c274330 100644 --- a/test/asynchronous/test_auth_oidc.py +++ b/test/asynchronous/test_auth_oidc.py @@ -177,7 +177,7 @@ async def test_1_1_single_principal_implicit_username(self): # Create default OIDC client with authMechanism=MONGODB-OIDC. client = await self.create_client() # Perform a find operation that succeeds. - await client.test.test.find_one() + await client.db.coll.find_one() # Close the client. await client.close() @@ -185,7 +185,7 @@ async def test_1_2_single_principal_explicit_username(self): # Create a client with MONGODB_URI_SINGLE, a username of test_user1, authMechanism=MONGODB-OIDC, and the OIDC human callback. client = await self.create_client(username="test_user1") # Perform a find operation that succeeds. - await client.test.test.find_one() + await client.db.coll.find_one() # Close the client. await client.close() @@ -195,7 +195,7 @@ async def test_1_3_multiple_principal_user_1(self): # Create a client with MONGODB_URI_MULTI, a username of test_user1, authMechanism=MONGODB-OIDC, and the OIDC human callback. client = await self.create_client(self.uri_multiple, username="test_user1") # Perform a find operation that succeeds. - await client.test.test.find_one() + await client.db.coll.find_one() # Close the client. await client.close() @@ -206,7 +206,7 @@ async def test_1_4_multiple_principal_user_2(self): # Create a client with MONGODB_URI_MULTI, a username of test_user2, authMechanism=MONGODB-OIDC, and the OIDC human callback. client = await self.create_client(self.uri_multiple, username="test_user2") # Perform a find operation that succeeds. - await client.test.test.find_one() + await client.db.coll.find_one() # Close the client. await client.close() @@ -217,7 +217,7 @@ async def test_1_5_multiple_principal_no_user(self): client = await self.create_client(self.uri_multiple) # Assert that a find operation fails. with self.assertRaises(OperationFailure): - await client.test.test.find_one() + await client.db.coll.find_one() # Close the client. await client.close() @@ -228,7 +228,7 @@ async def test_1_6_allowed_hosts_blocked(self): client = await self.create_client(authmechanismproperties=props) # Assert that a find operation fails with a client-side error. with self.assertRaises(ConfigurationError): - await client.test.test.find_one() + await client.db.coll.find_one() # Close the client. await client.close() @@ -247,7 +247,7 @@ async def test_1_6_allowed_hosts_blocked(self): ) # Assert that a find operation fails with a client-side error. with self.assertRaises(ConfigurationError): - await client.test.test.find_one() + await client.db.coll.find_one() # Close the client. await client.close() @@ -269,7 +269,7 @@ async def test_1_8_machine_idp_human_callback(self): # Create a client with MONGODB_URI_SINGLE, a username of test_machine, authMechanism=MONGODB-OIDC, and the OIDC human callback. client = await self.create_client(username="test_machine") # Perform a find operation that succeeds. - await client.test.test.find_one() + await client.db.coll.find_one() # Close the client. await client.close() @@ -278,7 +278,7 @@ async def test_2_1_valid_callback_inputs(self): client = await self.create_client() # Perform a find operation that succeeds. Verify that the human callback was called with the appropriate inputs, including the timeout parameter if possible. # Ensure that there are no unexpected fields. - await client.test.test.find_one() + await client.db.coll.find_one() # Close the client. await client.close() @@ -291,7 +291,7 @@ def fetch(self, ctx): client = await self.create_client(request_cb=CustomCB()) # Perform a find operation that fails. with self.assertRaises(ValueError): - await client.test.test.find_one() + await client.db.coll.find_one() # Close the client. await client.close() @@ -300,7 +300,7 @@ async def test_2_3_refresh_token_is_passed_to_the_callback(self): client = await self.create_client() # Perform a find operation that succeeds. - await client.test.test.find_one() + await client.db.coll.find_one() # Set a fail point for ``find`` commands. async with self.fail_point( @@ -310,7 +310,7 @@ async def test_2_3_refresh_token_is_passed_to_the_callback(self): } ): # Perform a ``find`` operation that succeeds. - await client.test.test.find_one() + await client.db.coll.find_one() # Assert that the callback has been called twice. self.assertEqual(self.request_called, 2) @@ -331,7 +331,7 @@ async def test_3_1_uses_speculative_authentication_if_there_is_a_cached_token(se ): # Perform a ``find`` operation that fails. with self.assertRaises(AutoReconnect): - await client.test.test.find_one() + await client.db.coll.find_one() # Set a fail point for ``saslStart`` commands. async with self.fail_point( @@ -341,7 +341,7 @@ async def test_3_1_uses_speculative_authentication_if_there_is_a_cached_token(se } ): # Perform a ``find`` operation that succeeds - await client.test.test.find_one() + await client.db.coll.find_one() # Close the client. await client.close() @@ -359,7 +359,7 @@ async def test_3_2_does_not_use_speculative_authentication_if_there_is_no_cached ): # Perform a ``find`` operation that fails. with self.assertRaises(OperationFailure): - await client.test.test.find_one() + await client.db.coll.find_one() # Close the client. await client.close() @@ -372,7 +372,7 @@ async def test_4_1_reauthenticate_succeeds(self): client = await self.create_client(event_listeners=[listener]) # Perform a find operation that succeeds. - await client.test.test.find_one() + await client.db.coll.find_one() # Assert that the human callback has been called once. self.assertEqual(self.request_called, 1) @@ -388,7 +388,7 @@ async def test_4_1_reauthenticate_succeeds(self): } ): # Perform another find operation that succeeds. - await client.test.test.find_one() + await client.db.coll.find_one() # Assert that the human callback has been called twice. self.assertEqual(self.request_called, 2) @@ -434,7 +434,7 @@ def fetch(self, *args, **kwargs): client = await self.create_client(request_cb=CustomRequest()) # Perform a find operation that succeeds. - await client.test.test.find_one() + await client.db.coll.find_one() # Assert that the human callback has been called once. self.assertEqual(self.request_called, 1) @@ -447,7 +447,7 @@ def fetch(self, *args, **kwargs): } ): # Perform a find operation that succeeds. - await client.test.test.find_one() + await client.db.coll.find_one() # Assert that the human callback has been called twice. self.assertEqual(self.request_called, 2) @@ -467,7 +467,7 @@ def fetch(self, *args, **kwargs): client = await self.create_client(request_cb=CustomRequest()) # Perform a find operation that succeeds. - await client.test.test.find_one() + await client.db.coll.find_one() # Assert that the human callback has been called once. self.assertEqual(self.request_called, 1) @@ -480,7 +480,7 @@ def fetch(self, *args, **kwargs): } ): # Perform a find operation that succeeds. - await client.test.test.find_one() + await client.db.coll.find_one() # Assert that the human callback has been called 2 times. self.assertEqual(self.request_called, 2) @@ -507,7 +507,7 @@ def fetch(self, *args, **kwargs): client = await self.create_client(request_cb=CustomRequest()) # Perform a find operation that succeeds (to force a speculative auth). - await client.test.test.find_one() + await client.db.coll.find_one() # Assert that the human callback has been called once. self.assertEqual(self.request_called, 1) @@ -520,7 +520,7 @@ def fetch(self, *args, **kwargs): ): # Perform a find operation that fails. with self.assertRaises(OperationFailure): - await client.test.test.find_one() + await client.db.coll.find_one() # Assert that the human callback has been called three times. self.assertEqual(self.request_called, 3) @@ -535,7 +535,7 @@ def fetch(self, a): client = await self.create_client(request_cb=RequestTokenNull()) with self.assertRaises(ValueError): - await client.test.test.find_one() + await client.db.coll.find_one() await client.close() async def test_request_callback_invalid_result(self): @@ -545,7 +545,7 @@ def fetch(self, a): client = await self.create_client(request_cb=CallbackInvalidToken()) with self.assertRaises(ValueError): - await client.test.test.find_one() + await client.db.coll.find_one() await client.close() async def test_reauthentication_succeeds_multiple_connections(self): @@ -556,8 +556,8 @@ async def test_reauthentication_succeeds_multiple_connections(self): client2 = await self.create_client(request_cb=request_cb) # Perform an insert operation. - await client1.test.test.insert_many([{"a": 1}, {"a": 1}]) - await client2.test.test.find_one() + await client1.db.coll.insert_many([{"a": 1}, {"a": 1}]) + await client2.db.coll.find_one() self.assertEqual(self.request_called, 2) # Use the same authenticator for both clients @@ -568,8 +568,8 @@ async def test_reauthentication_succeeds_multiple_connections(self): client1.options.pool_options._credentials.cache.data ) - await client1.test.test.find_one() - await client2.test.test.find_one() + await client1.db.coll.find_one() + await client2.db.coll.find_one() async with self.fail_point( { @@ -577,7 +577,7 @@ async def test_reauthentication_succeeds_multiple_connections(self): "data": {"failCommands": ["find"], "errorCode": 391}, } ): - await client1.test.test.find_one() + await client1.db.coll.find_one() self.assertEqual(self.request_called, 3) @@ -587,7 +587,7 @@ async def test_reauthentication_succeeds_multiple_connections(self): "data": {"failCommands": ["find"], "errorCode": 391}, } ): - await client2.test.test.find_one() + await client2.db.coll.find_one() self.assertEqual(self.request_called, 3) await client1.close() @@ -600,7 +600,7 @@ async def test_reauthenticate_succeeds_bulk_write(self): client = await self.create_client() # Perform a find operation. - await client.test.test.find_one() + await client.db.coll.find_one() # Assert that the request callback has been called once. self.assertEqual(self.request_called, 1) @@ -612,7 +612,7 @@ async def test_reauthenticate_succeeds_bulk_write(self): } ): # Perform a bulk write operation. - await client.test.test.bulk_write([InsertOne({})]) # type:ignore[type-var] + await client.db.coll.bulk_write([InsertOne({})]) # type:ignore[type-var] # Assert that the request callback has been called twice. self.assertEqual(self.request_called, 2) @@ -623,10 +623,10 @@ async def test_reauthenticate_succeeds_bulk_read(self): client = await self.create_client() # Perform a find operation. - await client.test.test.find_one() + await client.db.coll.find_one() # Perform a bulk write operation. - await client.test.test.bulk_write([InsertOne({})]) # type:ignore[type-var] + await client.db.coll.bulk_write([InsertOne({})]) # type:ignore[type-var] # Assert that the request callback has been called once. self.assertEqual(self.request_called, 1) @@ -638,7 +638,7 @@ async def test_reauthenticate_succeeds_bulk_read(self): } ): # Perform a bulk read operation. - cursor = client.test.test.find_raw_batches({}) + cursor = client.db.coll.find_raw_batches({}) await cursor.to_list() # Assert that the request callback has been called twice. @@ -650,7 +650,7 @@ async def test_reauthenticate_succeeds_cursor(self): client = await self.create_client() # Perform an insert operation. - await client.test.test.insert_one({"a": 1}) + await client.db.coll.insert_one({"a": 1}) # Assert that the request callback has been called once. self.assertEqual(self.request_called, 1) @@ -662,7 +662,7 @@ async def test_reauthenticate_succeeds_cursor(self): } ): # Perform a find operation. - cursor = client.test.test.find({"a": 1}) + cursor = client.db.coll.find({"a": 1}) self.assertGreaterEqual(len(await cursor.to_list()), 1) # Assert that the request callback has been called twice. @@ -674,7 +674,7 @@ async def test_reauthenticate_succeeds_get_more(self): client = await self.create_client() # Perform an insert operation. - await client.test.test.insert_many([{"a": 1}, {"a": 1}]) + await client.db.coll.insert_many([{"a": 1}, {"a": 1}]) # Assert that the request callback has been called once. self.assertEqual(self.request_called, 1) @@ -686,7 +686,7 @@ async def test_reauthenticate_succeeds_get_more(self): } ): # Perform a find operation. - cursor = client.test.test.find({"a": 1}, batch_size=1) + cursor = client.db.coll.find({"a": 1}, batch_size=1) self.assertGreaterEqual(len(await cursor.to_list()), 1) # Assert that the request callback has been called twice. @@ -704,7 +704,7 @@ async def test_reauthenticate_succeeds_get_more_exhaust(self): client = await self.create_client() # Perform an insert operation. - await client.test.test.insert_many([{"a": 1}, {"a": 1}]) + await client.db.coll.insert_many([{"a": 1}, {"a": 1}]) # Assert that the request callback has been called once. self.assertEqual(self.request_called, 1) @@ -716,7 +716,7 @@ async def test_reauthenticate_succeeds_get_more_exhaust(self): } ): # Perform a find operation. - cursor = client.test.test.find({"a": 1}, batch_size=1, cursor_type=CursorType.EXHAUST) + cursor = client.db.coll.find({"a": 1}, batch_size=1, cursor_type=CursorType.EXHAUST) self.assertGreaterEqual(len(await cursor.to_list()), 1) # Assert that the request callback has been called twice. @@ -728,7 +728,7 @@ async def test_reauthenticate_succeeds_command(self): client = await self.create_client() # Perform an insert operation. - await client.test.test.insert_one({"a": 1}) + await client.db.coll.insert_one({"a": 1}) # Assert that the request callback has been called once. self.assertEqual(self.request_called, 1) @@ -787,7 +787,7 @@ async def test_1_1_callback_is_called_during_reauthentication(self): # implements the provider logic. client = await self.create_client() # Perform a ``find`` operation that succeeds. - await client.test.test.find_one() + await client.db.coll.find_one() # Assert that the callback was called 1 time. self.assertEqual(self.request_called, 1) @@ -800,7 +800,7 @@ async def test_1_2_callback_is_called_once_for_multiple_connections(self): # Start 10 tasks and run 100 find operations that all succeed in each task. async def target(): for _ in range(100): - await client.test.test.find_one() + await client.db.coll.find_one() tasks = [] for i in range(10): @@ -816,7 +816,7 @@ async def test_2_1_valid_callback_inputs(self): # Create a AsyncMongoClient configured with an OIDC callback that validates its inputs and returns a valid access token. client = await self.create_client() # Perform a find operation that succeeds. - await client.test.test.find_one() + await client.db.coll.find_one() # Assert that the OIDC callback was called with the appropriate inputs, including the timeout parameter if possible. Ensure that there are no unexpected fields. self.assertEqual(self.request_called, 1) @@ -829,7 +829,7 @@ def fetch(self, a): client = await self.create_client(request_cb=CallbackNullToken()) # Perform a find operation that fails. with self.assertRaises(ValueError): - await client.test.test.find_one() + await client.db.coll.find_one() async def test_2_3_oidc_callback_returns_missing_data(self): # Create a AsyncMongoClient configured with an OIDC callback that returns data not conforming to the OIDCCredential with missing fields. @@ -843,7 +843,7 @@ def fetch(self, a): client = await self.create_client(request_cb=CustomCallback()) # Perform a find operation that fails. with self.assertRaises(ValueError): - await client.test.test.find_one() + await client.db.coll.find_one() async def test_2_4_invalid_client_configuration_with_callback(self): # Create a AsyncMongoClient configured with an OIDC callback and auth mechanism property ENVIRONMENT:test. @@ -898,13 +898,13 @@ async def test_3_1_authentication_failure_with_cached_tokens_fetch_a_new_token_a # Perform a ``find`` operation that fails. This is to force the ``AsyncMongoClient`` # to cache an access token. with self.assertRaises(AutoReconnect): - await client.test.test.find_one() + await client.db.coll.find_one() # Poison the cache of the client. client.options.pool_options._credentials.cache.data.access_token = "bad" # Reset the request count. self.request_called = 0 # Verify that a find succeeds. - await client.test.test.find_one() + await client.db.coll.find_one() # Verify that the callback was called 1 time. self.assertEqual(self.request_called, 1) @@ -921,7 +921,7 @@ def fetch(self, a): client = await self.create_client(request_cb=callback) # Perform a ``find`` operation that fails. with self.assertRaises(OperationFailure): - await client.test.test.find_one() + await client.db.coll.find_one() # Verify that the callback was called 1 time. self.assertEqual(callback.count, 1) @@ -938,13 +938,13 @@ async def test_3_3_unexpected_error_code_does_not_clear_cache(self): ): # Perform a ``find`` operation that fails. with self.assertRaises(OperationFailure): - await client.test.test.find_one() + await client.db.coll.find_one() # Assert that the callback has been called once. self.assertEqual(self.request_called, 1) # Perform a ``find`` operation that succeeds. - await client.test.test.find_one() + await client.db.coll.find_one() # Assert that the callback has been called once. self.assertEqual(self.request_called, 1) @@ -963,7 +963,7 @@ async def test_4_1_reauthentication_succeeds(self): } ): # Perform a ``find`` operation that succeeds. - await client.test.test.find_one() + await client.db.coll.find_one() # Verify that the callback was called 2 times (once during the connection # handshake, and again during reauthentication). @@ -989,7 +989,7 @@ def fetch(self, _): client = await self.create_client(request_cb=callback) # Perform a read operation that succeeds. - await client.test.test.find_one() + await client.db.coll.find_one() # Set a fail point for the find command. async with self.fail_point( @@ -1000,7 +1000,7 @@ def fetch(self, _): ): # Perform a ``find`` operation that fails. with self.assertRaises(OperationFailure): - await client.test.test.find_one() + await client.db.coll.find_one() # Verify that the callback was called 2 times. self.assertEqual(callback.count, 2) @@ -1025,7 +1025,7 @@ def fetch(self, _): client = await self.create_client(request_cb=callback) # Perform an insert operation that succeeds. - await client.test.test.insert_one({}) + await client.db.coll.insert_one({}) # Set a fail point for the find command. async with self.fail_point( @@ -1036,7 +1036,7 @@ def fetch(self, _): ): # Perform a ``insert`` operation that fails. with self.assertRaises(OperationFailure): - await client.test.test.insert_one({}) + await client.db.coll.insert_one({}) # Verify that the callback was called 2 times. self.assertEqual(callback.count, 2) @@ -1049,7 +1049,7 @@ async def test_4_4_speculative_authentication_should_be_ignored_on_reauthenticat # Preload the *Client Cache* with a valid access token to enforce Speculative Authentication. client2 = await self.create_client() - await client2.test.test.find_one() + await client2.db.coll.find_one() client.options.pool_options._credentials.cache.data = ( client2.options.pool_options._credentials.cache.data ) @@ -1057,7 +1057,7 @@ async def test_4_4_speculative_authentication_should_be_ignored_on_reauthenticat self.request_called = 0 # Perform an `insert` operation that succeeds. - await client.test.test.insert_one({}) + await client.db.coll.insert_one({}) # Assert that the callback was not called. self.assertEqual(self.request_called, 0) @@ -1076,7 +1076,7 @@ async def test_4_4_speculative_authentication_should_be_ignored_on_reauthenticat } ): # Perform an `insert` operation that succeeds. - await client.test.test.insert_one({}) + await client.db.coll.insert_one({}) # Assert that the callback was called once. self.assertEqual(self.request_called, 1) @@ -1098,7 +1098,7 @@ async def test_4_5_reauthentication_succeeds_when_a_session_is_involved(self): # Start a new session. async with client.start_session() as session: # In the started session perform a `find` operation that succeeds. - await client.test.test.find_one({}, session=session) + await client.db.coll.find_one({}, session=session) # Assert that the callback was called 2 times (once during the connection handshake, and again during reauthentication). self.assertEqual(self.request_called, 2) @@ -1111,7 +1111,7 @@ async def test_5_1_azure_with_no_username(self): props = dict(TOKEN_RESOURCE=resource, ENVIRONMENT="azure") client = await self.create_client(authMechanismProperties=props) - await client.test.test.find_one() + await client.db.coll.find_one() async def test_5_2_azure_with_bad_username(self): if ENVIRON != "azure": @@ -1123,11 +1123,11 @@ async def test_5_2_azure_with_bad_username(self): props = dict(TOKEN_RESOURCE=token_aud, ENVIRONMENT="azure") client = await self.create_client(username="bad", authmechanismproperties=props) with self.assertRaises(ValueError): - await client.test.test.find_one() + await client.db.coll.find_one() async def test_speculative_auth_success(self): client1 = await self.create_client() - await client1.test.test.find_one() + await client1.db.coll.find_one() client2 = await self.create_client() await client2.aconnect() @@ -1144,15 +1144,15 @@ async def test_speculative_auth_success(self): } ): # Perform a find operation. - await client2.test.test.find_one() + await client2.db.coll.find_one() async def test_reauthentication_succeeds_multiple_connections(self): client1 = await self.create_client() client2 = await self.create_client() # Perform an insert operation. - await client1.test.test.insert_many([{"a": 1}, {"a": 1}]) - await client2.test.test.find_one() + await client1.db.coll.insert_many([{"a": 1}, {"a": 1}]) + await client2.db.coll.find_one() self.assertEqual(self.request_called, 2) # Use the same authenticator for both clients @@ -1163,8 +1163,8 @@ async def test_reauthentication_succeeds_multiple_connections(self): client1.options.pool_options._credentials.cache.data ) - await client1.test.test.find_one() - await client2.test.test.find_one() + await client1.db.coll.find_one() + await client2.db.coll.find_one() async with self.fail_point( { @@ -1172,7 +1172,7 @@ async def test_reauthentication_succeeds_multiple_connections(self): "data": {"failCommands": ["find"], "errorCode": 391}, } ): - await client1.test.test.find_one() + await client1.db.coll.find_one() self.assertEqual(self.request_called, 3) @@ -1182,7 +1182,7 @@ async def test_reauthentication_succeeds_multiple_connections(self): "data": {"failCommands": ["find"], "errorCode": 391}, } ): - await client2.test.test.find_one() + await client2.db.coll.find_one() self.assertEqual(self.request_called, 3) diff --git a/test/asynchronous/test_bulk.py b/test/asynchronous/test_bulk.py index ce505bcb37..f0df7a677e 100644 --- a/test/asynchronous/test_bulk.py +++ b/test/asynchronous/test_bulk.py @@ -44,7 +44,7 @@ class AsyncBulkTestBase(AsyncIntegrationTest): async def asyncSetUp(self): await super().asyncSetUp() - self.coll = self.db.test + self.coll = self.db.coll await self.coll.drop() self.coll_w0 = self.coll.with_options(write_concern=WriteConcern(w=0)) @@ -794,7 +794,7 @@ async def asyncSetUp(self): privileges=[ { "actions": ["insert", "update", "find"], - "resource": {"db": "pymongo_test", "collection": "test"}, + "resource": {"db": "db", "collection": "coll"}, } ], roles=[], @@ -899,9 +899,9 @@ async def test_readonly(self): # We test that an authorization failure aborts the batch and is raised # as OperationFailure. cli = await self.async_rs_or_single_client_noauth( - username="readonly", password="pw", authSource="pymongo_test" + username="readonly", password="pw", authSource="db" ) - coll = cli.pymongo_test.test + coll = cli.db.coll await coll.find_one() with self.assertRaises(OperationFailure): await coll.bulk_write([InsertOne({"x": 1})]) @@ -910,9 +910,9 @@ async def test_no_remove(self): # We test that an authorization failure aborts the batch and is raised # as OperationFailure. cli = await self.async_rs_or_single_client_noauth( - username="noremove", password="pw", authSource="pymongo_test" + username="noremove", password="pw", authSource="db" ) - coll = cli.pymongo_test.test + coll = cli.db.coll await coll.find_one() requests = [ InsertOne({"x": 1}), diff --git a/test/asynchronous/test_change_stream.py b/test/asynchronous/test_change_stream.py index e4128b2499..8d1417d59c 100644 --- a/test/asynchronous/test_change_stream.py +++ b/test/asynchronous/test_change_stream.py @@ -776,7 +776,7 @@ class TestClusterAsyncChangeStream(TestAsyncChangeStreamBase, APITestsMixin): @async_client_context.require_change_streams # type:ignore[untyped-decorator] async def asyncSetUp(self) -> None: await super().asyncSetUp() - self.dbs = [self.db, self.client.pymongo_test_2] + self.dbs = [self.db, self.client.db2] async def asyncTearDown(self): for db in self.dbs: @@ -907,7 +907,7 @@ async def test_simple(self): async def test_isolation(self): # Ensure inserts to other dbs don't show up in our AsyncChangeStream. - other_db = self.client.pymongo_test_temp + other_db = self.client.coll self.assertNotEqual(other_db, self.db, msg="Isolation must be tested on separate DBs") collname = self.id() async with await self.change_stream() as change_stream: diff --git a/test/asynchronous/test_client.py b/test/asynchronous/test_client.py index 5902e957a2..90d14dfe0f 100644 --- a/test/asynchronous/test_client.py +++ b/test/asynchronous/test_client.py @@ -874,13 +874,13 @@ async def test_init_disconnected(self): bad_host = "somedomainthatdoesntexist.org" c = self.simple_client(bad_host, port, connectTimeoutMS=1, serverSelectionTimeoutMS=10) with self.assertRaises(ConnectionFailure): - await c.pymongo_test.test.find_one() + await c.db.coll.find_one() async def test_init_disconnected_with_auth(self): uri = "mongodb://user:pass@somedomainthatdoesntexist" c = self.simple_client(uri, connectTimeoutMS=1, serverSelectionTimeoutMS=10) with self.assertRaises(ConnectionFailure): - await c.pymongo_test.test.find_one() + await c.db.coll.find_one() @async_client_context.require_replica_set @async_client_context.require_no_load_balancer @@ -1047,7 +1047,7 @@ async def test_list_databases(self): async for doc in await client.list_databases(): self.assertIs(type(doc), dict) - await self.client.pymongo_test.test.insert_one({}) + await self.client.db.coll.insert_one({}) cursor = await self.client.list_databases(filter={"name": "admin"}) docs = await cursor.to_list() self.assertEqual(1, len(docs)) @@ -1058,14 +1058,14 @@ async def test_list_databases(self): self.assertEqual(["name"], list(doc)) async def test_list_database_names(self): - await self.client.pymongo_test.test.insert_one({"dummy": "object"}) - await self.client.pymongo_test_mike.test.insert_one({"dummy": "object"}) + await self.client.db.coll.insert_one({"dummy": "object"}) + await self.client.db_mike.test.insert_one({"dummy": "object"}) cmd_docs = (await self.client.admin.command("listDatabases"))["databases"] cmd_names = [doc["name"] for doc in cmd_docs] db_names = await self.client.list_database_names() - self.assertIn("pymongo_test", db_names) - self.assertIn("pymongo_test_mike", db_names) + self.assertIn("db", db_names) + self.assertIn("db_mike", db_names) self.assertCountEqual(db_names, cmd_names) async def test_drop_database(self): @@ -1074,26 +1074,26 @@ async def test_drop_database(self): with self.assertRaises(TypeError): await self.client.drop_database(None) # type: ignore[arg-type] - await self.client.pymongo_test.test.insert_one({"dummy": "object"}) - await self.client.pymongo_test2.test.insert_one({"dummy": "object"}) + await self.client.db.coll.insert_one({"dummy": "object"}) + await self.client.db2.coll.insert_one({"dummy": "object"}) dbs = await self.client.list_database_names() - self.assertIn("pymongo_test", dbs) - self.assertIn("pymongo_test2", dbs) - await self.client.drop_database("pymongo_test") + self.assertIn("db", dbs) + self.assertIn("db2", dbs) + await self.client.drop_database("db") if async_client_context.is_rs: wc_client = await self.async_rs_or_single_client(w=len(async_client_context.nodes) + 1) with self.assertRaises(WriteConcernError): - await wc_client.drop_database("pymongo_test2") + await wc_client.drop_database("db2") - await self.client.drop_database(self.client.pymongo_test2) + await self.client.drop_database(self.client.db2) dbs = await self.client.list_database_names() - self.assertNotIn("pymongo_test", dbs) - self.assertNotIn("pymongo_test2", dbs) + self.assertNotIn("db", dbs) + self.assertNotIn("db2", dbs) async def test_close(self): test_client = await self.async_rs_or_single_client() - coll = test_client.pymongo_test.bar + coll = test_client.db.coll await test_client.close() with self.assertRaises(InvalidOperation): await coll.count_documents({}) @@ -1105,7 +1105,7 @@ async def test_close_kills_cursors(self): await test_client._process_periodic_tasks() # Add some test data. - coll = test_client.pymongo_test.test_close_kills_cursors + coll = test_client.db.coll_close_kills_cursors docs_inserted = 1000 await coll.insert_many([{"i": i} for i in range(docs_inserted)]) @@ -1133,7 +1133,7 @@ async def test_close_kills_cursors(self): async def test_close_stops_kill_cursors_thread(self): client = await self.async_rs_client() - await client.test.test.find_one() + await client.db.coll.find_one() self.assertFalse(client._kill_cursors_executor._stopped) # Closing the client should stop the thread. @@ -1177,7 +1177,7 @@ async def test_close_does_not_open_servers(self): async def test_close_closes_sockets(self): client = await self.async_rs_client() - await client.test.test.find_one() + await client.db.coll.find_one() topology = client._topology await client.close() for server in topology._servers.values(): @@ -1197,10 +1197,10 @@ async def test_auth_from_uri(self): host, port = await async_client_context.host, await async_client_context.port await async_client_context.create_user("admin", "admin", "pass") self.addAsyncCleanup(async_client_context.drop_user, "admin", "admin") - self.addAsyncCleanup(remove_all_users, self.client.pymongo_test) + self.addAsyncCleanup(remove_all_users, self.client.db) await async_client_context.create_user( - "pymongo_test", "user", "pass", roles=["userAdmin", "readWrite"] + "db", "user", "pass", roles=["userAdmin", "readWrite"] ) with self.assertRaises(OperationFailure): @@ -1214,31 +1214,31 @@ async def test_auth_from_uri(self): ) # Wrong database. - uri = "mongodb://admin:pass@%s:%d/pymongo_test" % (host, port) + uri = "mongodb://admin:pass@%s:%d/db" % (host, port) with self.assertRaises(OperationFailure): await connected(await self.async_rs_or_single_client_noauth(uri)) # No error. await connected( await self.async_rs_or_single_client_noauth( - "mongodb://user:pass@%s:%d/pymongo_test" % (host, port) + "mongodb://user:pass@%s:%d/db" % (host, port) ) ) # Auth with lazy connection. await ( await self.async_rs_or_single_client_noauth( - "mongodb://user:pass@%s:%d/pymongo_test" % (host, port), connect=False + "mongodb://user:pass@%s:%d/db" % (host, port), connect=False ) - ).pymongo_test.test.find_one() + ).db.coll.find_one() # Wrong password. bad_client = await self.async_rs_or_single_client_noauth( - "mongodb://user:wrong@%s:%d/pymongo_test" % (host, port), connect=False + "mongodb://user:wrong@%s:%d/db" % (host, port), connect=False ) with self.assertRaises(OperationFailure): - await bad_client.pymongo_test.test.find_one() + await bad_client.db.coll.find_one() @async_client_context.require_auth async def test_username_and_password(self): @@ -1266,10 +1266,10 @@ async def test_username_and_password(self): async def test_lazy_auth_raises_operation_failure(self): host = await async_client_context.host lazy_client = await self.async_rs_or_single_client_noauth( - f"mongodb://user:wrong@{host}/pymongo_test", connect=False + f"mongodb://user:wrong@{host}/db", connect=False ) - await asyncAssertRaisesExactly(OperationFailure, lazy_client.test.collection.find_one) + await asyncAssertRaisesExactly(OperationFailure, lazy_client.db.coll.find_one) @async_client_context.require_no_tls async def test_unix_socket(self): @@ -1284,9 +1284,9 @@ async def test_unix_socket(self): uri = "mongodb://%s" % encoded_socket # Confirm we can do operations via the socket. client = await self.async_rs_or_single_client(uri) - await client.pymongo_test.test.insert_one({"dummy": "object"}) + await client.db.coll.insert_one({"dummy": "object"}) dbs = await client.list_database_names() - self.assertIn("pymongo_test", dbs) + self.assertIn("db", dbs) self.assertIn(mongodb_socket, repr(client)) @@ -1299,19 +1299,19 @@ async def test_unix_socket(self): async def test_document_class(self): c = self.client - db = c.pymongo_test - await db.test.insert_one({"x": 1}) + db = c.db + await db.coll.insert_one({"x": 1}) self.assertEqual(dict, c.codec_options.document_class) - self.assertIsInstance(await db.test.find_one(), dict) - self.assertNotIsInstance(await db.test.find_one(), SON) + self.assertIsInstance(await db.coll.find_one(), dict) + self.assertNotIsInstance(await db.coll.find_one(), SON) c = await self.async_rs_or_single_client(document_class=SON) - db = c.pymongo_test + db = c.db self.assertEqual(SON, c.codec_options.document_class) - self.assertIsInstance(await db.test.find_one(), SON) + self.assertIsInstance(await db.coll.find_one(), SON) async def test_timeouts(self): client = await self.async_rs_or_single_client( @@ -1353,19 +1353,19 @@ async def test_socket_timeout(self): timeout_sec = 1 timeout = await self.async_rs_or_single_client(socketTimeoutMS=1000 * timeout_sec) - await no_timeout.pymongo_test.drop_collection("test") - await no_timeout.pymongo_test.test.insert_one({"x": 1}) + await no_timeout.db.drop_collection("coll") + await no_timeout.db.coll.insert_one({"x": 1}) # A $where clause that takes a second longer than the timeout where_func = delay(timeout_sec + 1) async def get_x(db): - doc = await anext(db.test.find().where(where_func)) + doc = await anext(db.coll.find().where(where_func)) return doc["x"] - self.assertEqual(1, await get_x(no_timeout.pymongo_test)) + self.assertEqual(1, await get_x(no_timeout.db)) with self.assertRaises(NetworkTimeout): - await get_x(timeout.pymongo_test) + await get_x(timeout.db) async def test_server_selection_timeout(self): client = AsyncMongoClient(serverSelectionTimeoutMS=100, connect=False) @@ -1428,16 +1428,16 @@ async def test_tz_aware(self): aware = await self.async_rs_or_single_client(tz_aware=True) self.addAsyncCleanup(aware.close) naive = self.client - await aware.pymongo_test.drop_collection("test") + await aware.db.drop_collection("coll") now = datetime.datetime.now(tz=datetime.timezone.utc) - await aware.pymongo_test.test.insert_one({"x": now}) + await aware.db.coll.insert_one({"x": now}) - self.assertEqual(None, (await naive.pymongo_test.test.find_one())["x"].tzinfo) - self.assertEqual(utc, (await aware.pymongo_test.test.find_one())["x"].tzinfo) + self.assertEqual(None, (await naive.db.coll.find_one())["x"].tzinfo) + self.assertEqual(utc, (await aware.db.coll.find_one())["x"].tzinfo) self.assertEqual( - (await aware.pymongo_test.test.find_one())["x"].replace(tzinfo=None), - (await naive.pymongo_test.test.find_one())["x"], + (await aware.db.coll.find_one())["x"].replace(tzinfo=None), + (await naive.db.coll.find_one())["x"], ) @async_client_context.require_ipv6 @@ -1456,17 +1456,17 @@ async def test_ipv6(self): uri += "/?replicaSet=" + (async_client_context.replica_set_name or "") client = await self.async_rs_or_single_client_noauth(uri) - await client.pymongo_test.test.insert_one({"dummy": "object"}) - await client.pymongo_test_bernie.test.insert_one({"dummy": "object"}) + await client.db.coll.insert_one({"dummy": "object"}) + await client.db_bernie.coll.insert_one({"dummy": "object"}) dbs = await client.list_database_names() - self.assertIn("pymongo_test", dbs) - self.assertIn("pymongo_test_bernie", dbs) + self.assertIn("db", dbs) + self.assertIn("db_bernie", dbs) async def test_contextlib(self): client = await self.async_rs_or_single_client() - await client.pymongo_test.drop_collection("test") - await client.pymongo_test.test.insert_one({"foo": "bar"}) + await client.db.drop_collection("coll") + await client.db.coll.insert_one({"foo": "bar"}) # The socket used for the previous commands has been returned to the # pool @@ -1475,14 +1475,14 @@ async def test_contextlib(self): # contextlib async support was added in Python 3.10 if _IS_SYNC or sys.version_info >= (3, 10): async with contextlib.aclosing(client): - self.assertEqual("bar", (await client.pymongo_test.test.find_one())["foo"]) + self.assertEqual("bar", (await client.db.coll.find_one())["foo"]) with self.assertRaises(InvalidOperation): - await client.pymongo_test.test.find_one() + await client.db.coll.find_one() client = await self.async_rs_or_single_client() async with client as client: - self.assertEqual("bar", (await client.pymongo_test.test.find_one())["foo"]) + self.assertEqual("bar", (await client.db.coll.find_one())["foo"]) with self.assertRaises(InvalidOperation): - await client.pymongo_test.test.find_one() + await client.db.coll.find_one() @async_client_context.require_sync def test_interrupt_signal(self): @@ -1491,7 +1491,7 @@ def test_interrupt_signal(self): # Test fix for PYTHON-294 -- make sure AsyncMongoClient closes its # socket if it gets an interrupt while waiting to recv() from it. - db = self.client.pymongo_test + db = self.client.db # A $where clause which takes 1.5 sec to execute where = delay(1.5) @@ -1551,15 +1551,15 @@ async def test_operation_failure(self): # to avoid race conditions caused by replica set failover or idle # socket reaping. client = await self.async_single_client() - await client.pymongo_test.test.find_one() + await client.db.coll.find_one() pool = await async_get_pool(client) socket_count = len(pool.conns) self.assertGreaterEqual(socket_count, 1) old_conn = next(iter(pool.conns)) - await client.pymongo_test.test.drop() - await client.pymongo_test.test.insert_one({"_id": "foo"}) + await client.db.coll.drop() + await client.db.coll.insert_one({"_id": "foo"}) with self.assertRaises(OperationFailure): - await client.pymongo_test.test.insert_one({"_id": "foo"}) + await client.db.coll.insert_one({"_id": "foo"}) self.assertEqual(socket_count, len(pool.conns)) new_con = next(iter(pool.conns)) @@ -1575,26 +1575,26 @@ async def test_lazy_connect_w0(self): self.addAsyncCleanup(async_client_context.client.drop_database, "test_lazy_connect_w0") client = await self.async_rs_or_single_client(connect=False, w=0) - await client.test_lazy_connect_w0.test.insert_one({}) + await client.test_lazy_connect_w0.coll.insert_one({}) async def predicate(): - return await client.test_lazy_connect_w0.test.count_documents({}) == 1 + return await client.test_lazy_connect_w0.coll.count_documents({}) == 1 await async_wait_until(predicate, "find one document") client = await self.async_rs_or_single_client(connect=False, w=0) - await client.test_lazy_connect_w0.test.update_one({}, {"$set": {"x": 1}}) + await client.test_lazy_connect_w0.coll.update_one({}, {"$set": {"x": 1}}) async def predicate(): - return (await client.test_lazy_connect_w0.test.find_one()).get("x") == 1 + return (await client.test_lazy_connect_w0.coll.find_one()).get("x") == 1 await async_wait_until(predicate, "update one document") client = await self.async_rs_or_single_client(connect=False, w=0) - await client.test_lazy_connect_w0.test.delete_one({}) + await client.test_lazy_connect_w0.list_collection_names.delete_one({}) async def predicate(): - return await client.test_lazy_connect_w0.test.count_documents({}) == 0 + return await client.test_lazy_connect_w0.coll.count_documents({}) == 0 await async_wait_until(predicate, "delete one document") @@ -1603,7 +1603,7 @@ async def test_exhaust_network_error(self): # When doing an exhaust query, the socket stays checked out on success # but must be checked in on error to avoid semaphore leaks. client = await self.async_rs_or_single_client(maxPoolSize=1, retryReads=False) - collection = client.pymongo_test.test + collection = client.db.coll pool = await async_get_pool(client) pool._check_interval_seconds = None # Never check. @@ -1642,16 +1642,16 @@ async def test_auth_network_error(self): # AsyncConnection.authenticate logs, but gets a socket.error. Should be # reraised as AutoReconnect. with self.assertRaises(AutoReconnect): - await c.test.collection.find_one() + await c.db.coll.find_one() # No semaphore leak, the pool is allowed to make a new socket. - await c.test.collection.find_one() + await c.db.coll.find_one() @async_client_context.require_no_replica_set async def test_connect_to_standalone_using_replica_set_name(self): client = await self.async_single_client(replicaSet="anything", serverSelectionTimeoutMS=100) with self.assertRaises(AutoReconnect): - await client.test.test.find_one() + await client.db.coll.find_one() @async_client_context.require_replica_set async def test_stale_getmore(self): @@ -1662,8 +1662,8 @@ async def test_stale_getmore(self): client = await self.async_rs_client(connect=False, serverSelectionTimeoutMS=100) await client._run_operation( operation=message._GetMore( - "pymongo_test", - "collection", + "db", + "coll", 101, 1234, client.codec_options, @@ -1675,7 +1675,7 @@ async def test_stale_getmore(self): False, None, ), - unpack_res=AsyncCursor(client.pymongo_test.collection)._unpack_response, + unpack_res=AsyncCursor(client.db.coll)._unpack_response, address=("not-a-member", 27017), ) @@ -1809,7 +1809,7 @@ def compression_settings(client): for level in range(-1, 10): client = await self.async_single_client(zlibcompressionlevel=level) # No error - await client.pymongo_test.test.find_one() + await client.db.coll.find_one() @async_client_context.require_sync async def test_reset_during_update_pool(self): @@ -1948,7 +1948,7 @@ def server_description_count(): ) initial_count = server_description_count() with self.assertRaises(ServerSelectionTimeoutError): - await client.test.test.find_one() + await client.db.coll.find_one() gc.collect() final_count = server_description_count() await client.close() @@ -1967,12 +1967,12 @@ async def test_network_error_message(self): assert await client.address is not None expected = "{}:{}: ".format(*(await client.address)) with self.assertRaisesRegex(AutoReconnect, expected): - await client.pymongo_test.test.find_one({}) + await client.db.coll.find_one({}) @unittest.skipIf("PyPy" in sys.version, "PYTHON-2938 could fail on PyPy") async def test_process_periodic_tasks(self): client = await self.async_rs_or_single_client() - coll = client.db.collection + coll = client.db.coll await coll.insert_many([{} for _ in range(5)]) cursor = coll.find(batch_size=2) await cursor.next() @@ -2169,23 +2169,23 @@ async def test_handshake_09_container_with_provider(self): ) def test_dict_hints(self): - self.db.t.find(hint={"x": 1}) + self.db.coll.find(hint={"x": 1}) def test_dict_hints_sort(self): - result = self.db.t.find() + result = self.db.coll.find() result.sort({"x": 1}) - self.db.t.find(sort={"x": 1}) + self.db.coll.find(sort={"x": 1}) async def test_dict_hints_create_index(self): - await self.db.t.create_index({"x": pymongo.ASCENDING}) + await self.db.coll.create_index({"x": pymongo.ASCENDING}) async def test_legacy_java_uuid_roundtrip(self): data = BinaryData.java_data docs = bson.decode_all(data, CodecOptions(SON[str, Any], False, JAVA_LEGACY)) - await async_client_context.client.pymongo_test.drop_collection("java_uuid") - db = async_client_context.client.pymongo_test + await async_client_context.client.db.drop_collection("java_uuid") + db = async_client_context.client.db coll = db.get_collection("java_uuid", CodecOptions(uuid_representation=JAVA_LEGACY)) await coll.insert_many(docs) @@ -2196,14 +2196,14 @@ async def test_legacy_java_uuid_roundtrip(self): coll = db.get_collection("java_uuid", CodecOptions(uuid_representation=PYTHON_LEGACY)) async for d in coll.find(): self.assertNotEqual(d["newguid"], d["newguidstring"]) - await async_client_context.client.pymongo_test.drop_collection("java_uuid") + await async_client_context.client.db.drop_collection("java_uuid") async def test_legacy_csharp_uuid_roundtrip(self): data = BinaryData.csharp_data docs = bson.decode_all(data, CodecOptions(SON[str, Any], False, CSHARP_LEGACY)) - await async_client_context.client.pymongo_test.drop_collection("csharp_uuid") - db = async_client_context.client.pymongo_test + await async_client_context.client.db.drop_collection("csharp_uuid") + db = async_client_context.client.db coll = db.get_collection("csharp_uuid", CodecOptions(uuid_representation=CSHARP_LEGACY)) await coll.insert_many(docs) @@ -2214,16 +2214,16 @@ async def test_legacy_csharp_uuid_roundtrip(self): coll = db.get_collection("csharp_uuid", CodecOptions(uuid_representation=PYTHON_LEGACY)) async for d in coll.find(): self.assertNotEqual(d["newguid"], d["newguidstring"]) - await async_client_context.client.pymongo_test.drop_collection("csharp_uuid") + await async_client_context.client.db.drop_collection("csharp_uuid") async def test_uri_to_uuid(self): uri = "mongodb://foo/?uuidrepresentation=csharpLegacy" client = await self.async_single_client(uri, connect=False) - self.assertEqual(client.pymongo_test.test.codec_options.uuid_representation, CSHARP_LEGACY) + self.assertEqual(client.db.coll.codec_options.uuid_representation, CSHARP_LEGACY) async def test_uuid_queries(self): - db = async_client_context.client.pymongo_test - coll = db.test + db = async_client_context.client.db + coll = db.coll await coll.drop() uu = uuid.uuid4() @@ -2232,7 +2232,7 @@ async def test_uuid_queries(self): # Test regular UUID queries (using subtype 4). coll = db.get_collection( - "test", CodecOptions(uuid_representation=UuidRepresentation.STANDARD) + "coll", CodecOptions(uuid_representation=UuidRepresentation.STANDARD) ) self.assertEqual(0, await coll.count_documents({"uuid": uu})) await coll.insert_one({"uuid": uu}) @@ -2263,7 +2263,7 @@ async def test_exhaust_query_server_error(self): # but must be checked in on error to avoid semaphore leaks. client = await connected(await self.async_rs_or_single_client(maxPoolSize=1)) - collection = client.pymongo_test.test + collection = client.db.coll pool = await async_get_pool(client) conn = one(pool.conns) @@ -2285,11 +2285,11 @@ async def test_exhaust_getmore_server_error(self): # When doing a getmore on an exhaust cursor, the socket stays checked # out on success but it's checked in on error to avoid semaphore leaks. client = await self.async_rs_or_single_client(maxPoolSize=1) - collection = client.pymongo_test.test + collection = client.db.coll await collection.drop() await collection.insert_many([{} for _ in range(200)]) - self.addAsyncCleanup(async_client_context.client.pymongo_test.test.drop) + self.addAsyncCleanup(async_client_context.client.db.coll.drop) pool = await async_get_pool(client) pool._check_interval_seconds = None # Never check. @@ -2326,7 +2326,7 @@ async def test_exhaust_query_network_error(self): client = await connected( await self.async_rs_or_single_client(maxPoolSize=1, retryReads=False) ) - collection = client.pymongo_test.test + collection = client.db.coll pool = await async_get_pool(client) pool._check_interval_seconds = None # Never check. @@ -2347,7 +2347,7 @@ async def test_exhaust_getmore_network_error(self): # When doing a getmore on an exhaust cursor, the socket stays checked # out on success but it's checked in on error to avoid semaphore leaks. client = await self.async_rs_or_single_client(maxPoolSize=1) - collection = client.pymongo_test.test + collection = client.db.coll await collection.drop() await collection.insert_many([{} for _ in range(200)]) # More than one batch. pool = await async_get_pool(client) @@ -2383,7 +2383,7 @@ def test_gevent_task(self): def poller(): while True: - async_client_context.client.pymongo_test.test.insert_one({}) + async_client_context.client.db.coll.insert_one({}) task = spawn(poller) task.kill() @@ -2396,7 +2396,7 @@ def test_gevent_timeout(self): from gevent import Timeout, spawn client = self.async_rs_or_single_client(maxPoolSize=1) - coll = client.pymongo_test.test + coll = client.db.coll coll.insert_one({}) def contentious_task(): @@ -2429,7 +2429,7 @@ def test_gevent_timeout_when_creating_connection(self): client = self.async_rs_or_single_client() self.addCleanup(client.close) - coll = client.pymongo_test.test + coll = client.db.coll pool = async_get_pool(client) # type:ignore # Patch the pool to delay the connect method. @@ -2576,7 +2576,7 @@ async def test_reconnect(self): # ServerSelectionTimeoutError or AutoReconnect (from # AsyncMockPool.get_socket). with self.assertRaises(AutoReconnect): - await c.db.collection.find_one() + await c.db.coll.find_one() # But it can reconnect. c.revive_host("a:1") @@ -2633,31 +2633,31 @@ async def _test_network_error(self, operation_callback): async def test_network_error_on_query(self): async def callback(client): - return await client.db.collection.find_one() + return await client.db.coll.find_one() await self._test_network_error(callback) async def test_network_error_on_insert(self): async def callback(client): - return await client.db.collection.insert_one({}) + return await client.db.coll.insert_one({}) await self._test_network_error(callback) async def test_network_error_on_update(self): async def callback(client): - return await client.db.collection.update_one({}, {"$unset": "x"}) + return await client.db.coll.update_one({}, {"$unset": "x"}) await self._test_network_error(callback) async def test_network_error_on_replace(self): async def callback(client): - return await client.db.collection.replace_one({}, {}) + return await client.db.coll.replace_one({}, {}) await self._test_network_error(callback) async def test_network_error_on_delete(self): async def callback(client): - return await client.db.collection.delete_many({}) + return await client.db.coll.delete_many({}) await self._test_network_error(callback) diff --git a/test/asynchronous/test_client_backpressure.py b/test/asynchronous/test_client_backpressure.py index 3e75ed9b0d..41def9c7f5 100644 --- a/test/asynchronous/test_client_backpressure.py +++ b/test/asynchronous/test_client_backpressure.py @@ -60,36 +60,36 @@ class TestBackpressure(AsyncIntegrationTest): @async_client_context.require_failCommand_appName async def test_retry_overload_error_command(self): - await self.db.t.insert_one({"x": 1}) + await self.db.coll.insert_one({"x": 1}) # Ensure command is retried on overload error. fail_many = get_mock_overload_error(MAX_ADAPTIVE_RETRIES) async with self.fail_point(fail_many): - await self.db.command("find", "t") + await self.db.command("find", "coll") # Ensure command stops retrying after MAX_ADAPTIVE_RETRIES. fail_too_many = get_mock_overload_error(MAX_ADAPTIVE_RETRIES + 1) async with self.fail_point(fail_too_many): with self.assertRaises(PyMongoError) as error: - await self.db.command("find", "t") + await self.db.command("find", "coll") self.assertIn("RetryableError", str(error.exception)) self.assertIn("SystemOverloadedError", str(error.exception)) @async_client_context.require_failCommand_appName async def test_retry_overload_error_find(self): - await self.db.t.insert_one({"x": 1}) + await self.db.coll.insert_one({"x": 1}) # Ensure command is retried on overload error. fail_many = get_mock_overload_error(MAX_ADAPTIVE_RETRIES) async with self.fail_point(fail_many): - await self.db.t.find_one() + await self.db.coll.find_one() # Ensure command stops retrying after MAX_ADAPTIVE_RETRIES. fail_too_many = get_mock_overload_error(MAX_ADAPTIVE_RETRIES + 1) async with self.fail_point(fail_too_many): with self.assertRaises(PyMongoError) as error: - await self.db.t.find_one() + await self.db.coll.find_one() self.assertIn("RetryableError", str(error.exception)) self.assertIn("SystemOverloadedError", str(error.exception)) @@ -99,13 +99,13 @@ async def test_retry_overload_error_insert_one(self): # Ensure command is retried on overload error. fail_many = get_mock_overload_error(MAX_ADAPTIVE_RETRIES) async with self.fail_point(fail_many): - await self.db.t.insert_one({"x": 1}) + await self.db.coll.insert_one({"x": 1}) # Ensure command stops retrying after MAX_ADAPTIVE_RETRIES. fail_too_many = get_mock_overload_error(MAX_ADAPTIVE_RETRIES + 1) async with self.fail_point(fail_too_many): with self.assertRaises(PyMongoError) as error: - await self.db.t.insert_one({"x": 1}) + await self.db.coll.insert_one({"x": 1}) self.assertIn("RetryableError", str(error.exception)) self.assertIn("SystemOverloadedError", str(error.exception)) @@ -114,25 +114,25 @@ async def test_retry_overload_error_insert_one(self): async def test_retry_overload_error_update_many(self): # Even though update_many is not a retryable write operation, it will # still be retried via the "RetryableError" error label. - await self.db.t.insert_one({"x": 1}) + await self.db.coll.insert_one({"x": 1}) # Ensure command is retried on overload error. fail_many = get_mock_overload_error(MAX_ADAPTIVE_RETRIES) async with self.fail_point(fail_many): - await self.db.t.update_many({}, {"$set": {"x": 2}}) + await self.db.coll.update_many({}, {"$set": {"x": 2}}) # Ensure command stops retrying after MAX_ADAPTIVE_RETRIES. fail_too_many = get_mock_overload_error(MAX_ADAPTIVE_RETRIES + 1) async with self.fail_point(fail_too_many): with self.assertRaises(PyMongoError) as error: - await self.db.t.update_many({}, {"$set": {"x": 2}}) + await self.db.coll.update_many({}, {"$set": {"x": 2}}) self.assertIn("RetryableError", str(error.exception)) self.assertIn("SystemOverloadedError", str(error.exception)) @async_client_context.require_failCommand_appName async def test_retry_overload_error_getMore(self): - coll = self.db.t + coll = self.db.coll await coll.insert_many([{"x": 1} for _ in range(10)]) # Ensure command is retried on overload error. @@ -189,7 +189,7 @@ async def test_01_operation_retry_uses_exponential_backoff(self, random_func): client = self.client # 2. let `collection` be a collection - collection = client.test.test + collection = client.db.coll # 3. Now, run transactions without backoff: @@ -234,7 +234,7 @@ async def test_03_overload_retries_limited(self): # 1. Let `client` be a `MongoClient`. client = self.client # 2. Let `coll` be a collection. - coll = client.pymongo_test.coll + coll = client.db.coll # 3. Configure the following failpoint: failpoint = { @@ -269,7 +269,7 @@ async def test_04_overload_retries_limited_configured(self): maxAdaptiveRetries=max_retries, event_listeners=[self.listener] ) # 2. Let `coll` be a collection. - coll = client.pymongo_test.coll + coll = client.db.coll # 3. Configure the following failpoint: failpoint = { diff --git a/test/asynchronous/test_collation.py b/test/asynchronous/test_collation.py index 78b28ab3df..d4bed48ff6 100644 --- a/test/asynchronous/test_collation.py +++ b/test/asynchronous/test_collation.py @@ -102,7 +102,7 @@ async def asyncSetUp(self) -> None: await super().asyncSetUp() self.listener = OvertCommandListener() self.client = await self.async_rs_or_single_client(event_listeners=[self.listener]) - self.db = self.client.pymongo_test + self.db = self.client.db self.collation = Collation("en_US") self.warn_context = warnings.catch_warnings() self.warn_context.__enter__() @@ -120,14 +120,14 @@ def assertCollationInLastCommand(self): self.assertEqual(self.collation.document, self.last_command_started()["collation"]) async def test_create_collection(self): - await self.db.test.drop() - await self.db.create_collection("test", collation=self.collation) + await self.db.coll.drop() + await self.db.create_collection("coll", collation=self.collation) self.assertCollationInLastCommand() # Test passing collation as a dict as well. - await self.db.test.drop() + await self.db.coll.drop() self.listener.reset() - await self.db.create_collection("test", collation=self.collation.document) + await self.db.create_collection("coll", collation=self.collation.document) self.assertCollationInLastCommand() def test_index_model(self): @@ -135,81 +135,81 @@ def test_index_model(self): self.assertEqual(self.collation.document, model.document["collation"]) async def test_create_index(self): - await self.db.test.create_index("foo", collation=self.collation) + await self.db.coll.create_index("foo", collation=self.collation) ci_cmd = self.listener.started_events[0].command self.assertEqual(self.collation.document, ci_cmd["indexes"][0]["collation"]) async def test_aggregate(self): - await self.db.test.aggregate([{"$group": {"_id": 42}}], collation=self.collation) + await self.db.coll.aggregate([{"$group": {"_id": 42}}], collation=self.collation) self.assertCollationInLastCommand() async def test_count_documents(self): - await self.db.test.count_documents({}, collation=self.collation) + await self.db.coll.count_documents({}, collation=self.collation) self.assertCollationInLastCommand() async def test_distinct(self): - await self.db.test.distinct("foo", collation=self.collation) + await self.db.coll.distinct("foo", collation=self.collation) self.assertCollationInLastCommand() self.listener.reset() - await self.db.test.find(collation=self.collation).distinct("foo") + await self.db.coll.find(collation=self.collation).distinct("foo") self.assertCollationInLastCommand() async def test_find_command(self): - await self.db.test.insert_one({"is this thing on?": True}) + await self.db.coll.insert_one({"is this thing on?": True}) self.listener.reset() - await anext(self.db.test.find(collation=self.collation)) + await anext(self.db.coll.find(collation=self.collation)) self.assertCollationInLastCommand() async def test_explain_command(self): self.listener.reset() - await self.db.test.find(collation=self.collation).explain() + await self.db.coll.find(collation=self.collation).explain() # The collation should be part of the explained command. self.assertEqual( self.collation.document, self.last_command_started()["explain"]["collation"] ) async def test_delete(self): - await self.db.test.delete_one({"foo": 42}, collation=self.collation) + await self.db.coll.delete_one({"foo": 42}, collation=self.collation) command = self.listener.started_events[0].command self.assertEqual(self.collation.document, command["deletes"][0]["collation"]) self.listener.reset() - await self.db.test.delete_many({"foo": 42}, collation=self.collation) + await self.db.coll.delete_many({"foo": 42}, collation=self.collation) command = self.listener.started_events[0].command self.assertEqual(self.collation.document, command["deletes"][0]["collation"]) async def test_update(self): - await self.db.test.replace_one({"foo": 42}, {"foo": 43}, collation=self.collation) + await self.db.coll.replace_one({"foo": 42}, {"foo": 43}, collation=self.collation) command = self.listener.started_events[0].command self.assertEqual(self.collation.document, command["updates"][0]["collation"]) self.listener.reset() - await self.db.test.update_one({"foo": 42}, {"$set": {"foo": 43}}, collation=self.collation) + await self.db.coll.update_one({"foo": 42}, {"$set": {"foo": 43}}, collation=self.collation) command = self.listener.started_events[0].command self.assertEqual(self.collation.document, command["updates"][0]["collation"]) self.listener.reset() - await self.db.test.update_many({"foo": 42}, {"$set": {"foo": 43}}, collation=self.collation) + await self.db.coll.update_many({"foo": 42}, {"$set": {"foo": 43}}, collation=self.collation) command = self.listener.started_events[0].command self.assertEqual(self.collation.document, command["updates"][0]["collation"]) async def test_find_and(self): - await self.db.test.find_one_and_delete({"foo": 42}, collation=self.collation) + await self.db.coll.find_one_and_delete({"foo": 42}, collation=self.collation) self.assertCollationInLastCommand() self.listener.reset() - await self.db.test.find_one_and_update( + await self.db.coll.find_one_and_update( {"foo": 42}, {"$set": {"foo": 43}}, collation=self.collation ) self.assertCollationInLastCommand() self.listener.reset() - await self.db.test.find_one_and_replace({"foo": 42}, {"foo": 43}, collation=self.collation) + await self.db.coll.find_one_and_replace({"foo": 42}, {"foo": 43}, collation=self.collation) self.assertCollationInLastCommand() async def test_bulk_write(self): - await self.db.test.collection.bulk_write( + await self.db.coll.collection.bulk_write( [ DeleteOne({"noCollation": 42}), DeleteMany({"noCollation": 42}), @@ -240,32 +240,32 @@ def check_ops(ops): check_ops(update_cmd["updates"]) async def test_indexes_same_keys_different_collations(self): - await self.db.test.drop() + await self.db.coll.drop() usa_collation = Collation("en_US") ja_collation = Collation("ja") - await self.db.test.create_indexes( + await self.db.coll.create_indexes( [ IndexModel("fieldname", collation=usa_collation), IndexModel("fieldname", name="japanese_version", collation=ja_collation), IndexModel("fieldname", name="simple"), ] ) - indexes = await self.db.test.index_information() + indexes = await self.db.coll.index_information() self.assertEqual( usa_collation.document["locale"], indexes["fieldname_1"]["collation"]["locale"] ) self.assertEqual( ja_collation.document["locale"], indexes["japanese_version"]["collation"]["locale"] ) - await self.db.test.drop_index("fieldname_1") - indexes = await self.db.test.index_information() + await self.db.coll.drop_index("fieldname_1") + indexes = await self.db.coll.index_information() self.assertIn("japanese_version", indexes) self.assertIn("simple", indexes) self.assertNotIn("fieldname", indexes) async def test_unacknowledged_write(self): unacknowledged = WriteConcern(w=0) - collection = self.db.get_collection("test", write_concern=unacknowledged) + collection = self.db.get_collection("coll", write_concern=unacknowledged) with self.assertRaises(ConfigurationError): await collection.update_one( {"hello": "world"}, {"$set": {"hello": "moon"}}, collation=self.collation @@ -277,6 +277,6 @@ async def test_unacknowledged_write(self): await collection.bulk_write([update_one]) async def test_cursor_collation(self): - await self.db.test.insert_one({"hello": "world"}) - await anext(self.db.test.find().collation(self.collation)) + await self.db.coll.insert_one({"hello": "world"}) + await anext(self.db.coll.find().collation(self.collation)) self.assertCollationInLastCommand() diff --git a/test/asynchronous/test_collection.py b/test/asynchronous/test_collection.py index 704d407491..5f8351ab82 100644 --- a/test/asynchronous/test_collection.py +++ b/test/asynchronous/test_collection.py @@ -90,7 +90,7 @@ class TestCollectionNoConnect(AsyncUnitTest): async def asyncSetUp(self) -> None: await super().asyncSetUp() self.client = self.simple_client(connect=False) - self.db = self.client.pymongo_test + self.db = self.client.db def test_collection(self): self.assertRaises(TypeError, AsyncCollection, self.db, 5) @@ -103,15 +103,15 @@ def make_col(base, name): self.assertRaises(InvalidName, make_col, self.db, ".test") self.assertRaises(InvalidName, make_col, self.db, "test.") self.assertRaises(InvalidName, make_col, self.db, "tes..t") - self.assertRaises(InvalidName, make_col, self.db.test, "") - self.assertRaises(InvalidName, make_col, self.db.test, "te$t") - self.assertRaises(InvalidName, make_col, self.db.test, ".test") - self.assertRaises(InvalidName, make_col, self.db.test, "test.") - self.assertRaises(InvalidName, make_col, self.db.test, "tes..t") - self.assertRaises(InvalidName, make_col, self.db.test, "tes\x00t") + self.assertRaises(InvalidName, make_col, self.db.coll, "") + self.assertRaises(InvalidName, make_col, self.db.coll, "te$t") + self.assertRaises(InvalidName, make_col, self.db.coll, ".test") + self.assertRaises(InvalidName, make_col, self.db.coll, "test.") + self.assertRaises(InvalidName, make_col, self.db.coll, "tes..t") + self.assertRaises(InvalidName, make_col, self.db.coll, "tes\x00t") def test_getattr(self): - coll = self.db.test + coll = self.db.coll self.assertIsInstance(coll["_does_not_exist"], AsyncCollection) with self.assertRaises(AttributeError) as context: @@ -159,7 +159,7 @@ async def asyncSetUp(self): self.w = async_client_context.w # type: ignore async def asyncTearDown(self): - await self.db.test.drop() + await self.db.coll.drop() await self.db.drop_collection("test_large_limit") await super().asyncTearDown() @@ -170,25 +170,25 @@ def write_concern_collection(self): # Unsatisfiable write concern. yield AsyncCollection( self.db, - "test", + "coll", write_concern=WriteConcern(w=len(async_client_context.nodes) + 1), ) else: - yield self.db.test + yield self.db.coll async def test_equality(self): - self.assertIsInstance(self.db.test, AsyncCollection) - self.assertEqual(self.db.test, self.db["test"]) - self.assertEqual(self.db.test, AsyncCollection(self.db, "test")) - self.assertEqual(self.db.test.mike, self.db["test.mike"]) - self.assertEqual(self.db.test["mike"], self.db["test.mike"]) + self.assertIsInstance(self.db.coll, AsyncCollection) + self.assertEqual(self.db.coll, self.db["coll"]) + self.assertEqual(self.db.coll, AsyncCollection(self.db, "coll")) + self.assertEqual(self.db.coll.mike, self.db["coll.mike"]) + self.assertEqual(self.db.coll["mike"], self.db["coll.mike"]) async def test_hashable(self): - self.assertIn(self.db.test.mike, {self.db["test.mike"]}) + self.assertIn(self.db.coll.mike, {self.db["coll.mike"]}) async def test_create(self): # No Exception. - db = async_client_context.client.pymongo_test + db = async_client_context.client.db await db.create_test_no_wc.drop() async def lambda_test(): @@ -212,59 +212,59 @@ async def lambda_test_2(): await db.create_collection("create-test-wc", write_concern=IMPOSSIBLE_WRITE_CONCERN) async def test_drop_nonexistent_collection(self): - await self.db.drop_collection("test") - self.assertNotIn("test", await self.db.list_collection_names()) + await self.db.drop_collection("coll") + self.assertNotIn("coll", await self.db.list_collection_names()) # No exception - await self.db.drop_collection("test") + await self.db.drop_collection("coll") async def test_create_indexes(self): db = self.db with self.assertRaises(TypeError): - await db.test.create_indexes("foo") # type: ignore[arg-type] + await db.coll.create_indexes("foo") # type: ignore[arg-type] with self.assertRaises(TypeError): - await db.test.create_indexes(["foo"]) # type: ignore[list-item] + await db.coll.create_indexes(["foo"]) # type: ignore[list-item] self.assertRaises(TypeError, IndexModel, 5) self.assertRaises(ValueError, IndexModel, []) - await db.test.drop_indexes() - await db.create_collection("test") - self.assertEqual(len(await db.test.index_information()), 1) + await db.coll.drop_indexes() + await db.create_collection("coll") + self.assertEqual(len(await db.coll.index_information()), 1) - await db.test.create_indexes([IndexModel("hello")]) - await db.test.create_indexes([IndexModel([("hello", DESCENDING), ("world", ASCENDING)])]) + await db.coll.create_indexes([IndexModel("hello")]) + await db.coll.create_indexes([IndexModel([("hello", DESCENDING), ("world", ASCENDING)])]) # Tuple instead of list. - await db.test.create_indexes([IndexModel((("world", ASCENDING),))]) + await db.coll.create_indexes([IndexModel((("world", ASCENDING),))]) - self.assertEqual(len(await db.test.index_information()), 4) + self.assertEqual(len(await db.coll.index_information()), 4) - await db.test.drop_indexes() - names = await db.test.create_indexes( + await db.coll.drop_indexes() + names = await db.coll.create_indexes( [IndexModel([("hello", DESCENDING), ("world", ASCENDING)], name="hello_world")] ) self.assertEqual(names, ["hello_world"]) - await db.test.drop_indexes() - self.assertEqual(len(await db.test.index_information()), 1) - await db.test.create_indexes([IndexModel("hello")]) - self.assertIn("hello_1", await db.test.index_information()) + await db.coll.drop_indexes() + self.assertEqual(len(await db.coll.index_information()), 1) + await db.coll.create_indexes([IndexModel("hello")]) + self.assertIn("hello_1", await db.coll.index_information()) - await db.test.drop_indexes() - self.assertEqual(len(await db.test.index_information()), 1) - names = await db.test.create_indexes( + await db.coll.drop_indexes() + self.assertEqual(len(await db.coll.index_information()), 1) + names = await db.coll.create_indexes( [IndexModel([("hello", DESCENDING), ("world", ASCENDING)]), IndexModel("hello")] ) - info = await db.test.index_information() + info = await db.coll.index_information() for name in names: self.assertIn(name, info) - await db.test.drop() - await db.test.insert_one({"a": 1}) - await db.test.insert_one({"a": 1}) + await db.coll.drop() + await db.coll.insert_one({"a": 1}) + await db.coll.insert_one({"a": 1}) with self.assertRaises(DuplicateKeyError): - await db.test.create_indexes([IndexModel("a", unique=True)]) + await db.coll.create_indexes([IndexModel("a", unique=True)]) with self.write_concern_collection() as coll: await coll.create_indexes([IndexModel("hello")]) @@ -287,83 +287,83 @@ async def test_create_index(self): db = self.db with self.assertRaises(TypeError): - await db.test.create_index(5) # type: ignore[arg-type] + await db.coll.create_index(5) # type: ignore[arg-type] with self.assertRaises(ValueError): - await db.test.create_index([]) + await db.coll.create_index([]) - await db.test.drop_indexes() - await db.create_collection("test") - self.assertEqual(len(await db.test.index_information()), 1) + await db.coll.drop_indexes() + await db.create_collection("coll") + self.assertEqual(len(await db.coll.index_information()), 1) - await db.test.create_index("hello") - await db.test.create_index([("hello", DESCENDING), ("world", ASCENDING)]) + await db.coll.create_index("hello") + await db.coll.create_index([("hello", DESCENDING), ("world", ASCENDING)]) # Tuple instead of list. - await db.test.create_index((("world", ASCENDING),)) + await db.coll.create_index((("world", ASCENDING),)) - self.assertEqual(len(await db.test.index_information()), 4) + self.assertEqual(len(await db.coll.index_information()), 4) - await db.test.drop_indexes() - ix = await db.test.create_index( + await db.coll.drop_indexes() + ix = await db.coll.create_index( [("hello", DESCENDING), ("world", ASCENDING)], name="hello_world" ) self.assertEqual(ix, "hello_world") - await db.test.drop_indexes() - self.assertEqual(len(await db.test.index_information()), 1) - await db.test.create_index("hello") - self.assertIn("hello_1", await db.test.index_information()) + await db.coll.drop_indexes() + self.assertEqual(len(await db.coll.index_information()), 1) + await db.coll.create_index("hello") + self.assertIn("hello_1", await db.coll.index_information()) - await db.test.drop_indexes() - self.assertEqual(len(await db.test.index_information()), 1) - await db.test.create_index([("hello", DESCENDING), ("world", ASCENDING)]) - self.assertIn("hello_-1_world_1", await db.test.index_information()) + await db.coll.drop_indexes() + self.assertEqual(len(await db.coll.index_information()), 1) + await db.coll.create_index([("hello", DESCENDING), ("world", ASCENDING)]) + self.assertIn("hello_-1_world_1", await db.coll.index_information()) - await db.test.drop_indexes() - await db.test.create_index([("hello", DESCENDING), ("world", ASCENDING)], name=None) - self.assertIn("hello_-1_world_1", await db.test.index_information()) + await db.coll.drop_indexes() + await db.coll.create_index([("hello", DESCENDING), ("world", ASCENDING)], name=None) + self.assertIn("hello_-1_world_1", await db.coll.index_information()) - await db.test.drop() - await db.test.insert_one({"a": 1}) - await db.test.insert_one({"a": 1}) + await db.coll.drop() + await db.coll.insert_one({"a": 1}) + await db.coll.insert_one({"a": 1}) with self.assertRaises(DuplicateKeyError): - await db.test.create_index("a", unique=True) + await db.coll.create_index("a", unique=True) with self.write_concern_collection() as coll: await coll.create_index([("hello", DESCENDING)]) - await db.test.create_index(["hello", "world"]) - await db.test.create_index(["hello", ("world", DESCENDING)]) - await db.test.create_index({"hello": 1}.items()) # type:ignore[arg-type] + await db.coll.create_index(["hello", "world"]) + await db.coll.create_index(["hello", ("world", DESCENDING)]) + await db.coll.create_index({"hello": 1}.items()) # type:ignore[arg-type] async def test_drop_index(self): db = self.db - await db.test.drop_indexes() - await db.test.create_index("hello") - name = await db.test.create_index("goodbye") + await db.coll.drop_indexes() + await db.coll.create_index("hello") + name = await db.coll.create_index("goodbye") - self.assertEqual(len(await db.test.index_information()), 3) + self.assertEqual(len(await db.coll.index_information()), 3) self.assertEqual(name, "goodbye_1") - await db.test.drop_index(name) + await db.coll.drop_index(name) # Drop it again. if async_client_context.version < Version(8, 3, -1): with self.assertRaises(OperationFailure): - await db.test.drop_index(name) + await db.coll.drop_index(name) else: - await db.test.drop_index(name) - self.assertEqual(len(await db.test.index_information()), 2) - self.assertIn("hello_1", await db.test.index_information()) + await db.coll.drop_index(name) + self.assertEqual(len(await db.coll.index_information()), 2) + self.assertIn("hello_1", await db.coll.index_information()) - await db.test.drop_indexes() - await db.test.create_index("hello") - name = await db.test.create_index("goodbye") + await db.coll.drop_indexes() + await db.coll.create_index("hello") + name = await db.coll.create_index("goodbye") - self.assertEqual(len(await db.test.index_information()), 3) + self.assertEqual(len(await db.coll.index_information()), 3) self.assertEqual(name, "goodbye_1") - await db.test.drop_index([("goodbye", ASCENDING)]) - self.assertEqual(len(await db.test.index_information()), 2) - self.assertIn("hello_1", await db.test.index_information()) + await db.coll.drop_index([("goodbye", ASCENDING)]) + self.assertEqual(len(await db.coll.index_information()), 2) + self.assertIn("hello_1", await db.coll.index_information()) with self.write_concern_collection() as coll: await coll.drop_index("hello_1") @@ -371,7 +371,7 @@ async def test_drop_index(self): @async_client_context.require_no_mongos @async_client_context.require_test_commands async def test_index_management_max_time_ms(self): - coll = self.db.test + coll = self.db.coll await self.client.admin.command( "configureFailPoint", "maxTimeAlwaysTimeOut", mode="alwaysOn" ) @@ -391,23 +391,23 @@ async def test_index_management_max_time_ms(self): async def test_list_indexes(self): db = self.db - await db.test.drop() - await db.create_collection("test") + await db.coll.drop() + await db.create_collection("coll") def map_indexes(indexes): return {index["name"]: index for index in indexes} - indexes = await (await db.test.list_indexes()).to_list() + indexes = await (await db.coll.list_indexes()).to_list() self.assertEqual(len(indexes), 1) self.assertIn("_id_", map_indexes(indexes)) - await db.test.create_index("hello") - indexes = await (await db.test.list_indexes()).to_list() + await db.coll.create_index("hello") + indexes = await (await db.coll.list_indexes()).to_list() self.assertEqual(len(indexes), 2) self.assertEqual(map_indexes(indexes)["hello_1"]["key"], SON([("hello", ASCENDING)])) - await db.test.create_index([("hello", DESCENDING), ("world", ASCENDING)], unique=True) - indexes = await (await db.test.list_indexes()).to_list() + await db.coll.create_index([("hello", DESCENDING), ("world", ASCENDING)], unique=True) + indexes = await (await db.coll.list_indexes()).to_list() self.assertEqual(len(indexes), 3) index_map = map_indexes(indexes) self.assertEqual( @@ -425,33 +425,33 @@ def map_indexes(indexes): async def test_index_info(self): db = self.db - await db.test.drop() - await db.create_collection("test") - self.assertEqual(len(await db.test.index_information()), 1) - self.assertIn("_id_", await db.test.index_information()) + await db.coll.drop() + await db.create_collection("coll") + self.assertEqual(len(await db.coll.index_information()), 1) + self.assertIn("_id_", await db.coll.index_information()) - await db.test.create_index("hello") - self.assertEqual(len(await db.test.index_information()), 2) + await db.coll.create_index("hello") + self.assertEqual(len(await db.coll.index_information()), 2) self.assertEqual( - (await db.test.index_information())["hello_1"]["key"], [("hello", ASCENDING)] + (await db.coll.index_information())["hello_1"]["key"], [("hello", ASCENDING)] ) - await db.test.create_index([("hello", DESCENDING), ("world", ASCENDING)], unique=True) + await db.coll.create_index([("hello", DESCENDING), ("world", ASCENDING)], unique=True) self.assertEqual( - (await db.test.index_information())["hello_1"]["key"], [("hello", ASCENDING)] + (await db.coll.index_information())["hello_1"]["key"], [("hello", ASCENDING)] ) - self.assertEqual(len(await db.test.index_information()), 3) + self.assertEqual(len(await db.coll.index_information()), 3) self.assertEqual( [("hello", DESCENDING), ("world", ASCENDING)], - (await db.test.index_information())["hello_-1_world_1"]["key"], + (await db.coll.index_information())["hello_-1_world_1"]["key"], ) - self.assertEqual(True, (await db.test.index_information())["hello_-1_world_1"]["unique"]) + self.assertEqual(True, (await db.coll.index_information())["hello_-1_world_1"]["unique"]) async def test_index_geo2d(self): db = self.db - await db.test.drop_indexes() - self.assertEqual("loc_2d", await db.test.create_index([("loc", GEO2D)])) - index_info = (await db.test.index_information())["loc_2d"] + await db.coll.drop_indexes() + self.assertEqual("loc_2d", await db.coll.create_index([("loc", GEO2D)])) + index_info = (await db.coll.index_information())["loc_2d"] self.assertEqual([("loc", "2d")], index_info["key"]) # geoSearch was deprecated in 4.4 and removed in 5.0 @@ -459,13 +459,13 @@ async def test_index_geo2d(self): @async_client_context.require_no_mongos async def test_index_haystack(self): db = self.db - await db.test.drop() + await db.coll.drop() _id = ( - await db.test.insert_one({"pos": {"long": 34.2, "lat": 33.3}, "type": "restaurant"}) + await db.coll.insert_one({"pos": {"long": 34.2, "lat": 33.3}, "type": "restaurant"}) ).inserted_id - await db.test.insert_one({"pos": {"long": 34.2, "lat": 37.3}, "type": "restaurant"}) - await db.test.insert_one({"pos": {"long": 59.1, "lat": 87.2}, "type": "office"}) - await db.test.create_index([("pos", "geoHaystack"), ("type", ASCENDING)], bucketSize=1) + await db.coll.insert_one({"pos": {"long": 34.2, "lat": 37.3}, "type": "restaurant"}) + await db.coll.insert_one({"pos": {"long": 59.1, "lat": 87.2}, "type": "office"}) + await db.coll.create_index([("pos", "geoHaystack"), ("type", ASCENDING)], bucketSize=1) results = ( await db.command( @@ -489,31 +489,31 @@ async def test_index_haystack(self): @async_client_context.require_no_mongos async def test_index_text(self): db = self.db - await db.test.drop_indexes() - self.assertEqual("t_text", await db.test.create_index([("t", TEXT)])) - index_info = (await db.test.index_information())["t_text"] + await db.coll.drop_indexes() + self.assertEqual("t_text", await db.coll.create_index([("t", TEXT)])) + index_info = (await db.coll.index_information())["t_text"] self.assertIn("weights", index_info) - await db.test.insert_many( + await db.coll.insert_many( [{"t": "spam eggs and spam"}, {"t": "spam"}, {"t": "egg sausage and bacon"}] ) # MongoDB 2.6 text search. Create 'score' field in projection. - cursor = db.test.find({"$text": {"$search": "spam"}}, {"score": {"$meta": "textScore"}}) + cursor = db.coll.find({"$text": {"$search": "spam"}}, {"score": {"$meta": "textScore"}}) # Sort by 'score' field. cursor.sort([("score", {"$meta": "textScore"})]) results = await cursor.to_list() self.assertGreaterEqual(results[0]["score"], results[1]["score"]) - await db.test.drop_indexes() + await db.coll.drop_indexes() async def test_index_2dsphere(self): db = self.db - await db.test.drop_indexes() - self.assertEqual("geo_2dsphere", await db.test.create_index([("geo", GEOSPHERE)])) + await db.coll.drop_indexes() + self.assertEqual("geo_2dsphere", await db.coll.create_index([("geo", GEOSPHERE)])) - for dummy, info in (await db.test.index_information()).items(): + for dummy, info in (await db.coll.index_information()).items(): field, idx_type = info["key"][0] if field == "geo" and idx_type == "2dsphere": break @@ -524,45 +524,45 @@ async def test_index_2dsphere(self): query = {"geo": {"$within": {"$geometry": poly}}} # This query will error without a 2dsphere index. - db.test.find(query) - await db.test.drop_indexes() + db.coll.find(query) + await db.coll.drop_indexes() async def test_index_hashed(self): db = self.db - await db.test.drop_indexes() - self.assertEqual("a_hashed", await db.test.create_index([("a", HASHED)])) + await db.coll.drop_indexes() + self.assertEqual("a_hashed", await db.coll.create_index([("a", HASHED)])) - for dummy, info in (await db.test.index_information()).items(): + for dummy, info in (await db.coll.index_information()).items(): field, idx_type = info["key"][0] if field == "a" and idx_type == "hashed": break else: self.fail("hashed index not found.") - await db.test.drop_indexes() + await db.coll.drop_indexes() async def test_index_sparse(self): db = self.db - await db.test.drop_indexes() - await db.test.create_index([("key", ASCENDING)], sparse=True) - self.assertTrue((await db.test.index_information())["key_1"]["sparse"]) + await db.coll.drop_indexes() + await db.coll.create_index([("key", ASCENDING)], sparse=True) + self.assertTrue((await db.coll.index_information())["key_1"]["sparse"]) async def test_index_background(self): db = self.db - await db.test.drop_indexes() - await db.test.create_index([("keya", ASCENDING)]) - await db.test.create_index([("keyb", ASCENDING)], background=False) - await db.test.create_index([("keyc", ASCENDING)], background=True) - self.assertNotIn("background", (await db.test.index_information())["keya_1"]) - self.assertFalse((await db.test.index_information())["keyb_1"]["background"]) - self.assertTrue((await db.test.index_information())["keyc_1"]["background"]) + await db.coll.drop_indexes() + await db.coll.create_index([("keya", ASCENDING)]) + await db.coll.create_index([("keyb", ASCENDING)], background=False) + await db.coll.create_index([("keyc", ASCENDING)], background=True) + self.assertNotIn("background", (await db.coll.index_information())["keya_1"]) + self.assertFalse((await db.coll.index_information())["keyb_1"]["background"]) + self.assertTrue((await db.coll.index_information())["keyc_1"]["background"]) async def _drop_dups_setup(self, db): - await db.drop_collection("test") - await db.test.insert_one({"i": 1}) - await db.test.insert_one({"i": 2}) - await db.test.insert_one({"i": 2}) # duplicate - await db.test.insert_one({"i": 3}) + await db.drop_collection("coll") + await db.coll.insert_one({"i": 1}) + await db.coll.insert_one({"i": 2}) + await db.coll.insert_one({"i": 2}) # duplicate + await db.coll.insert_one({"i": 3}) async def test_index_dont_drop_dups(self): # Try *not* dropping duplicates @@ -571,16 +571,16 @@ async def test_index_dont_drop_dups(self): # There's a duplicate async def _test_create(): - await db.test.create_index([("i", ASCENDING)], unique=True, dropDups=False) + await db.coll.create_index([("i", ASCENDING)], unique=True, dropDups=False) with self.assertRaises(DuplicateKeyError): await _test_create() # Duplicate wasn't dropped - self.assertEqual(4, await db.test.count_documents({})) + self.assertEqual(4, await db.coll.count_documents({})) # Index wasn't created, only the default index on _id - self.assertEqual(1, len(await db.test.index_information())) + self.assertEqual(1, len(await db.coll.index_information())) # Get the plan dynamically because the explain format will change. def get_plan_stage(self, root, stage): @@ -605,141 +605,141 @@ def get_plan_stage(self, root, stage): async def test_index_filter(self): db = self.db - await db.drop_collection("test") + await db.drop_collection("coll") # Test bad filter spec on create. with self.assertRaises(OperationFailure): - await db.test.create_index("x", partialFilterExpression=5) + await db.coll.create_index("x", partialFilterExpression=5) with self.assertRaises(OperationFailure): - await db.test.create_index("x", partialFilterExpression={"x": {"$asdasd": 3}}) + await db.coll.create_index("x", partialFilterExpression={"x": {"$asdasd": 3}}) with self.assertRaises(OperationFailure): - await db.test.create_index("x", partialFilterExpression={"$and": 5}) + await db.coll.create_index("x", partialFilterExpression={"$and": 5}) self.assertEqual( "x_1", - await db.test.create_index( + await db.coll.create_index( [("x", ASCENDING)], partialFilterExpression={"a": {"$lte": 1.5}} ), ) - await db.test.insert_one({"x": 5, "a": 2}) - await db.test.insert_one({"x": 6, "a": 1}) + await db.coll.insert_one({"x": 5, "a": 2}) + await db.coll.insert_one({"x": 6, "a": 1}) # Operations that use the partial index. - explain = await db.test.find({"x": 6, "a": 1}).explain() + explain = await db.coll.find({"x": 6, "a": 1}).explain() stage = self.get_plan_stage(explain["queryPlanner"]["winningPlan"], "IXSCAN") self.assertEqual("x_1", stage.get("indexName")) self.assertTrue(stage.get("isPartial")) - explain = await db.test.find({"x": {"$gt": 1}, "a": 1}).explain() + explain = await db.coll.find({"x": {"$gt": 1}, "a": 1}).explain() stage = self.get_plan_stage(explain["queryPlanner"]["winningPlan"], "IXSCAN") self.assertEqual("x_1", stage.get("indexName")) self.assertTrue(stage.get("isPartial")) - explain = await db.test.find({"x": 6, "a": {"$lte": 1}}).explain() + explain = await db.coll.find({"x": 6, "a": {"$lte": 1}}).explain() stage = self.get_plan_stage(explain["queryPlanner"]["winningPlan"], "IXSCAN") self.assertEqual("x_1", stage.get("indexName")) self.assertTrue(stage.get("isPartial")) # Operations that do not use the partial index. - explain = await db.test.find({"x": 6, "a": {"$lte": 1.6}}).explain() + explain = await db.coll.find({"x": 6, "a": {"$lte": 1.6}}).explain() stage = self.get_plan_stage(explain["queryPlanner"]["winningPlan"], "COLLSCAN") self.assertNotEqual({}, stage) - explain = await db.test.find({"x": 6}).explain() + explain = await db.coll.find({"x": 6}).explain() stage = self.get_plan_stage(explain["queryPlanner"]["winningPlan"], "COLLSCAN") self.assertNotEqual({}, stage) # Test drop_indexes. - await db.test.drop_index("x_1") - explain = await db.test.find({"x": 6, "a": 1}).explain() + await db.coll.drop_index("x_1") + explain = await db.coll.find({"x": 6, "a": 1}).explain() stage = self.get_plan_stage(explain["queryPlanner"]["winningPlan"], "COLLSCAN") self.assertNotEqual({}, stage) async def test_field_selection(self): db = self.db - await db.drop_collection("test") + await db.drop_collection("coll") doc = {"a": 1, "b": 5, "c": {"d": 5, "e": 10}} - await db.test.insert_one(doc) + await db.coll.insert_one(doc) # Test field inclusion - doc = await anext(db.test.find({}, ["_id"])) + doc = await anext(db.coll.find({}, ["_id"])) self.assertEqual(list(doc), ["_id"]) - doc = await anext(db.test.find({}, ["a"])) + doc = await anext(db.coll.find({}, ["a"])) l = list(doc) l.sort() self.assertEqual(l, ["_id", "a"]) - doc = await anext(db.test.find({}, ["b"])) + doc = await anext(db.coll.find({}, ["b"])) l = list(doc) l.sort() self.assertEqual(l, ["_id", "b"]) - doc = await anext(db.test.find({}, ["c"])) + doc = await anext(db.coll.find({}, ["c"])) l = list(doc) l.sort() self.assertEqual(l, ["_id", "c"]) - doc = await anext(db.test.find({}, ["a"])) + doc = await anext(db.coll.find({}, ["a"])) self.assertEqual(doc["a"], 1) - doc = await anext(db.test.find({}, ["b"])) + doc = await anext(db.coll.find({}, ["b"])) self.assertEqual(doc["b"], 5) - doc = await anext(db.test.find({}, ["c"])) + doc = await anext(db.coll.find({}, ["c"])) self.assertEqual(doc["c"], {"d": 5, "e": 10}) # Test inclusion of fields with dots - doc = await anext(db.test.find({}, ["c.d"])) + doc = await anext(db.coll.find({}, ["c.d"])) self.assertEqual(doc["c"], {"d": 5}) - doc = await anext(db.test.find({}, ["c.e"])) + doc = await anext(db.coll.find({}, ["c.e"])) self.assertEqual(doc["c"], {"e": 10}) - doc = await anext(db.test.find({}, ["b", "c.e"])) + doc = await anext(db.coll.find({}, ["b", "c.e"])) self.assertEqual(doc["c"], {"e": 10}) - doc = await anext(db.test.find({}, ["b", "c.e"])) + doc = await anext(db.coll.find({}, ["b", "c.e"])) l = list(doc) l.sort() self.assertEqual(l, ["_id", "b", "c"]) - doc = await anext(db.test.find({}, ["b", "c.e"])) + doc = await anext(db.coll.find({}, ["b", "c.e"])) self.assertEqual(doc["b"], 5) # Test field exclusion - doc = await anext(db.test.find({}, {"a": False, "b": 0})) + doc = await anext(db.coll.find({}, {"a": False, "b": 0})) l = list(doc) l.sort() self.assertEqual(l, ["_id", "c"]) - doc = await anext(db.test.find({}, {"_id": False})) + doc = await anext(db.coll.find({}, {"_id": False})) l = list(doc) self.assertNotIn("_id", l) async def test_options(self): db = self.db - await db.drop_collection("test") - await db.create_collection("test", capped=True, size=4096) - result = await db.test.options() + await db.drop_collection("coll") + await db.create_collection("coll", capped=True, size=4096) + result = await db.coll.options() self.assertEqual(result, {"capped": True, "size": 4096}) - await db.drop_collection("test") + await db.drop_collection("coll") async def test_insert_one(self): db = self.db - await db.test.drop() + await db.coll.drop() document: dict[str, Any] = {"_id": 1000} - result = await db.test.insert_one(document) + result = await db.coll.insert_one(document) self.assertIsInstance(result, InsertOneResult) self.assertIsInstance(result.inserted_id, int) self.assertEqual(document["_id"], result.inserted_id) self.assertTrue(result.acknowledged) - self.assertIsNotNone(await db.test.find_one({"_id": document["_id"]})) - self.assertEqual(1, await db.test.count_documents({})) + self.assertIsNotNone(await db.coll.find_one({"_id": document["_id"]})) + self.assertEqual(1, await db.coll.count_documents({})) document = {"foo": "bar"} - result = await db.test.insert_one(document) + result = await db.coll.insert_one(document) self.assertIsInstance(result, InsertOneResult) self.assertIsInstance(result.inserted_id, ObjectId) self.assertEqual(document["_id"], result.inserted_id) self.assertTrue(result.acknowledged) - self.assertIsNotNone(await db.test.find_one({"_id": document["_id"]})) - self.assertEqual(2, await db.test.count_documents({})) + self.assertIsNotNone(await db.coll.find_one({"_id": document["_id"]})) + self.assertEqual(2, await db.coll.count_documents({})) db = db.client.get_database(db.name, write_concern=WriteConcern(w=0)) - result = await db.test.insert_one(document) + result = await db.coll.insert_one(document) self.assertIsInstance(result, InsertOneResult) self.assertIsInstance(result.inserted_id, ObjectId) self.assertEqual(document["_id"], result.inserted_id) @@ -747,21 +747,21 @@ async def test_insert_one(self): # The insert failed duplicate key... async def async_lambda(): - return await db.test.count_documents({}) == 2 + return await db.coll.count_documents({}) == 2 await async_wait_until(async_lambda, "forcing duplicate key error") document = RawBSONDocument(encode({"_id": ObjectId(), "foo": "bar"})) - result = await db.test.insert_one(document) + result = await db.coll.insert_one(document) self.assertIsInstance(result, InsertOneResult) self.assertEqual(result.inserted_id, None) async def test_insert_many(self): db = self.db - await db.test.drop() + await db.coll.drop() docs: list = [{} for _ in range(5)] - result = await db.test.insert_many(docs) + result = await db.coll.insert_many(docs) self.assertIsInstance(result, InsertManyResult) self.assertIsInstance(result.inserted_ids, list) self.assertEqual(5, len(result.inserted_ids)) @@ -769,11 +769,11 @@ async def test_insert_many(self): _id = doc["_id"] self.assertIsInstance(_id, ObjectId) self.assertIn(_id, result.inserted_ids) - self.assertEqual(1, await db.test.count_documents({"_id": _id})) + self.assertEqual(1, await db.coll.count_documents({"_id": _id})) self.assertTrue(result.acknowledged) docs = [{"_id": i} for i in range(5)] - result = await db.test.insert_many(docs) + result = await db.coll.insert_many(docs) self.assertIsInstance(result, InsertManyResult) self.assertIsInstance(result.inserted_ids, list) self.assertEqual(5, len(result.inserted_ids)) @@ -781,24 +781,24 @@ async def test_insert_many(self): _id = doc["_id"] self.assertIsInstance(_id, int) self.assertIn(_id, result.inserted_ids) - self.assertEqual(1, await db.test.count_documents({"_id": _id})) + self.assertEqual(1, await db.coll.count_documents({"_id": _id})) self.assertTrue(result.acknowledged) docs = [RawBSONDocument(encode({"_id": i + 5})) for i in range(5)] - result = await db.test.insert_many(docs) + result = await db.coll.insert_many(docs) self.assertIsInstance(result, InsertManyResult) self.assertIsInstance(result.inserted_ids, list) self.assertEqual([], result.inserted_ids) db = db.client.get_database(db.name, write_concern=WriteConcern(w=0)) docs: list = [{} for _ in range(5)] - result = await db.test.insert_many(docs) + result = await db.coll.insert_many(docs) self.assertIsInstance(result, InsertManyResult) self.assertFalse(result.acknowledged) - self.assertEqual(20, await db.test.count_documents({})) + self.assertEqual(20, await db.coll.count_documents({})) async def test_insert_many_generator(self): - coll = self.db.test + coll = self.db.coll await coll.delete_many({}) def gen(): @@ -815,75 +815,75 @@ async def test_insert_many_invalid(self): db = self.db with self.assertRaisesRegex(TypeError, "documents must be a non-empty list"): - await db.test.insert_many({}) + await db.coll.insert_many({}) with self.assertRaisesRegex(TypeError, "documents must be a non-empty list"): - await db.test.insert_many([]) + await db.coll.insert_many([]) with self.assertRaisesRegex(TypeError, "documents must be a non-empty list"): - await db.test.insert_many(1) # type: ignore[arg-type] + await db.coll.insert_many(1) # type: ignore[arg-type] with self.assertRaisesRegex(TypeError, "documents must be a non-empty list"): - await db.test.insert_many(RawBSONDocument(encode({"_id": 2}))) + await db.coll.insert_many(RawBSONDocument(encode({"_id": 2}))) async def test_delete_one(self): - await self.db.test.drop() + await self.db.coll.drop() - await self.db.test.insert_one({"x": 1}) - await self.db.test.insert_one({"y": 1}) - await self.db.test.insert_one({"z": 1}) + await self.db.coll.insert_one({"x": 1}) + await self.db.coll.insert_one({"y": 1}) + await self.db.coll.insert_one({"z": 1}) - result = await self.db.test.delete_one({"x": 1}) + result = await self.db.coll.delete_one({"x": 1}) self.assertIsInstance(result, DeleteResult) self.assertEqual(1, result.deleted_count) self.assertTrue(result.acknowledged) - self.assertEqual(2, await self.db.test.count_documents({})) + self.assertEqual(2, await self.db.coll.count_documents({})) - result = await self.db.test.delete_one({"y": 1}) + result = await self.db.coll.delete_one({"y": 1}) self.assertIsInstance(result, DeleteResult) self.assertEqual(1, result.deleted_count) self.assertTrue(result.acknowledged) - self.assertEqual(1, await self.db.test.count_documents({})) + self.assertEqual(1, await self.db.coll.count_documents({})) db = self.db.client.get_database(self.db.name, write_concern=WriteConcern(w=0)) - result = await db.test.delete_one({"z": 1}) + result = await db.coll.delete_one({"z": 1}) self.assertIsInstance(result, DeleteResult) self.assertRaises(InvalidOperation, lambda: result.deleted_count) self.assertFalse(result.acknowledged) async def lambda_async(): - return await db.test.count_documents({}) == 0 + return await db.coll.count_documents({}) == 0 await async_wait_until(lambda_async, "delete 1 documents") async def test_delete_many(self): - await self.db.test.drop() + await self.db.coll.drop() - await self.db.test.insert_one({"x": 1}) - await self.db.test.insert_one({"x": 1}) - await self.db.test.insert_one({"y": 1}) - await self.db.test.insert_one({"y": 1}) + await self.db.coll.insert_one({"x": 1}) + await self.db.coll.insert_one({"x": 1}) + await self.db.coll.insert_one({"y": 1}) + await self.db.coll.insert_one({"y": 1}) - result = await self.db.test.delete_many({"x": 1}) + result = await self.db.coll.delete_many({"x": 1}) self.assertIsInstance(result, DeleteResult) self.assertEqual(2, result.deleted_count) self.assertTrue(result.acknowledged) - self.assertEqual(0, await self.db.test.count_documents({"x": 1})) + self.assertEqual(0, await self.db.coll.count_documents({"x": 1})) db = self.db.client.get_database(self.db.name, write_concern=WriteConcern(w=0)) - result = await db.test.delete_many({"y": 1}) + result = await db.coll.delete_many({"y": 1}) self.assertIsInstance(result, DeleteResult) self.assertRaises(InvalidOperation, lambda: result.deleted_count) self.assertFalse(result.acknowledged) async def lambda_async(): - return await db.test.count_documents({}) == 0 + return await db.coll.count_documents({}) == 0 await async_wait_until(lambda_async, "delete 2 documents") async def test_command_document_too_large(self): large = "*" * (await async_client_context.max_bson_size + _COMMAND_OVERHEAD) - coll = self.db.test + coll = self.db.coll with self.assertRaises(DocumentTooLarge): await coll.insert_one({"data": large}) # update_one and update_many are the same @@ -900,33 +900,33 @@ async def test_write_large_document(self): self.assertEqual(max_size, 16777216) with self.assertRaises(OperationFailure): - await self.db.test.insert_one({"foo": max_str}) + await self.db.coll.insert_one({"foo": max_str}) with self.assertRaises(OperationFailure): - await self.db.test.replace_one({}, {"foo": max_str}, upsert=True) + await self.db.coll.replace_one({}, {"foo": max_str}, upsert=True) with self.assertRaises(OperationFailure): - await self.db.test.insert_many([{"x": 1}, {"foo": max_str}]) - await self.db.test.insert_many([{"foo": half_str}, {"foo": half_str}]) + await self.db.coll.insert_many([{"x": 1}, {"foo": max_str}]) + await self.db.coll.insert_many([{"foo": half_str}, {"foo": half_str}]) - await self.db.test.insert_one({"bar": "x"}) + await self.db.coll.insert_one({"bar": "x"}) # Use w=0 here to test legacy doc size checking in all server versions - unack_coll = self.db.test.with_options(write_concern=WriteConcern(w=0)) + unack_coll = self.db.coll.with_options(write_concern=WriteConcern(w=0)) with self.assertRaises(DocumentTooLarge): await unack_coll.replace_one({"bar": "x"}, {"bar": "x" * (max_size - 14)}) - await self.db.test.replace_one({"bar": "x"}, {"bar": "x" * (max_size - 32)}) + await self.db.coll.replace_one({"bar": "x"}, {"bar": "x" * (max_size - 32)}) async def test_insert_bypass_document_validation(self): db = self.db - await db.test.drop() - await db.create_collection("test", validator={"a": {"$exists": True}}) + await db.coll.drop() + await db.create_collection("coll", validator={"a": {"$exists": True}}) db_w0 = self.db.client.get_database(self.db.name, write_concern=WriteConcern(w=0)) # Test insert_one with self.assertRaises(OperationFailure): - await db.test.insert_one({"_id": 1, "x": 100}) - result = await db.test.insert_one({"_id": 1, "x": 100}, bypass_document_validation=True) + await db.coll.insert_one({"_id": 1, "x": 100}) + result = await db.coll.insert_one({"_id": 1, "x": 100}, bypass_document_validation=True) self.assertIsInstance(result, InsertOneResult) self.assertEqual(1, result.inserted_id) - result = await db.test.insert_one({"_id": 2, "a": 0}) + result = await db.coll.insert_one({"_id": 2, "a": 0}) self.assertIsInstance(result, InsertOneResult) self.assertEqual(2, result.inserted_id) @@ -940,25 +940,25 @@ async def async_lambda(): # Test insert_many docs = [{"_id": i, "x": 100 - i} for i in range(3, 100)] with self.assertRaises(OperationFailure): - await db.test.insert_many(docs) - result = await db.test.insert_many(docs, bypass_document_validation=True) + await db.coll.insert_many(docs) + result = await db.coll.insert_many(docs, bypass_document_validation=True) self.assertIsInstance(result, InsertManyResult) self.assertTrue(97, len(result.inserted_ids)) for doc in docs: _id = doc["_id"] self.assertIsInstance(_id, int) self.assertIn(_id, result.inserted_ids) - self.assertEqual(1, await db.test.count_documents({"x": doc["x"]})) + self.assertEqual(1, await db.coll.count_documents({"x": doc["x"]})) self.assertTrue(result.acknowledged) docs = [{"_id": i, "a": 200 - i} for i in range(100, 200)] - result = await db.test.insert_many(docs) + result = await db.coll.insert_many(docs) self.assertIsInstance(result, InsertManyResult) self.assertTrue(97, len(result.inserted_ids)) for doc in docs: _id = doc["_id"] self.assertIsInstance(_id, int) self.assertIn(_id, result.inserted_ids) - self.assertEqual(1, await db.test.count_documents({"a": doc["a"]})) + self.assertEqual(1, await db.coll.count_documents({"a": doc["a"]})) self.assertTrue(result.acknowledged) with self.assertRaises(OperationFailure): @@ -969,37 +969,37 @@ async def async_lambda(): async def test_replace_bypass_document_validation(self): db = self.db - await db.test.drop() - await db.create_collection("test", validator={"a": {"$exists": True}}) + await db.coll.drop() + await db.create_collection("coll", validator={"a": {"$exists": True}}) db_w0 = self.db.client.get_database(self.db.name, write_concern=WriteConcern(w=0)) # Test replace_one - await db.test.insert_one({"a": 101}) + await db.coll.insert_one({"a": 101}) with self.assertRaises(OperationFailure): - await db.test.replace_one({"a": 101}, {"y": 1}) - self.assertEqual(0, await db.test.count_documents({"y": 1})) - self.assertEqual(1, await db.test.count_documents({"a": 101})) - await db.test.replace_one({"a": 101}, {"y": 1}, bypass_document_validation=True) - self.assertEqual(0, await db.test.count_documents({"a": 101})) - self.assertEqual(1, await db.test.count_documents({"y": 1})) - await db.test.replace_one({"y": 1}, {"a": 102}) - self.assertEqual(0, await db.test.count_documents({"y": 1})) - self.assertEqual(0, await db.test.count_documents({"a": 101})) - self.assertEqual(1, await db.test.count_documents({"a": 102})) - - await db.test.insert_one({"y": 1}, bypass_document_validation=True) + await db.coll.replace_one({"a": 101}, {"y": 1}) + self.assertEqual(0, await db.coll.count_documents({"y": 1})) + self.assertEqual(1, await db.coll.count_documents({"a": 101})) + await db.coll.replace_one({"a": 101}, {"y": 1}, bypass_document_validation=True) + self.assertEqual(0, await db.coll.count_documents({"a": 101})) + self.assertEqual(1, await db.coll.count_documents({"y": 1})) + await db.coll.replace_one({"y": 1}, {"a": 102}) + self.assertEqual(0, await db.coll.count_documents({"y": 1})) + self.assertEqual(0, await db.coll.count_documents({"a": 101})) + self.assertEqual(1, await db.coll.count_documents({"a": 102})) + + await db.coll.insert_one({"y": 1}, bypass_document_validation=True) with self.assertRaises(OperationFailure): - await db.test.replace_one({"y": 1}, {"x": 101}) - self.assertEqual(0, await db.test.count_documents({"x": 101})) - self.assertEqual(1, await db.test.count_documents({"y": 1})) - await db.test.replace_one({"y": 1}, {"x": 101}, bypass_document_validation=True) - self.assertEqual(0, await db.test.count_documents({"y": 1})) - self.assertEqual(1, await db.test.count_documents({"x": 101})) - await db.test.replace_one({"x": 101}, {"a": 103}, bypass_document_validation=False) - self.assertEqual(0, await db.test.count_documents({"x": 101})) - self.assertEqual(1, await db.test.count_documents({"a": 103})) - - await db.test.insert_one({"y": 1}, bypass_document_validation=True) + await db.coll.replace_one({"y": 1}, {"x": 101}) + self.assertEqual(0, await db.coll.count_documents({"x": 101})) + self.assertEqual(1, await db.coll.count_documents({"y": 1})) + await db.coll.replace_one({"y": 1}, {"x": 101}, bypass_document_validation=True) + self.assertEqual(0, await db.coll.count_documents({"y": 1})) + self.assertEqual(1, await db.coll.count_documents({"x": 101})) + await db.coll.replace_one({"x": 101}, {"a": 103}, bypass_document_validation=False) + self.assertEqual(0, await db.coll.count_documents({"x": 101})) + self.assertEqual(1, await db.coll.count_documents({"a": 103})) + + await db.coll.insert_one({"y": 1}, bypass_document_validation=True) await db_w0.test.replace_one({"y": 1}, {"x": 1}, bypass_document_validation=True) async def predicate(): @@ -1009,36 +1009,36 @@ async def predicate(): async def test_update_bypass_document_validation(self): db = self.db - await db.test.drop() - await db.test.insert_one({"z": 5}) + await db.coll.drop() + await db.coll.insert_one({"z": 5}) await db.command(SON([("collMod", "test"), ("validator", {"z": {"$gte": 0}})])) db_w0 = self.db.client.get_database(self.db.name, write_concern=WriteConcern(w=0)) # Test update_one with self.assertRaises(OperationFailure): - await db.test.update_one({"z": 5}, {"$inc": {"z": -10}}) - self.assertEqual(0, await db.test.count_documents({"z": -5})) - self.assertEqual(1, await db.test.count_documents({"z": 5})) - await db.test.update_one({"z": 5}, {"$inc": {"z": -10}}, bypass_document_validation=True) - self.assertEqual(0, await db.test.count_documents({"z": 5})) - self.assertEqual(1, await db.test.count_documents({"z": -5})) - await db.test.update_one({"z": -5}, {"$inc": {"z": 6}}, bypass_document_validation=False) - self.assertEqual(1, await db.test.count_documents({"z": 1})) - self.assertEqual(0, await db.test.count_documents({"z": -5})) - - await db.test.insert_one({"z": -10}, bypass_document_validation=True) + await db.coll.update_one({"z": 5}, {"$inc": {"z": -10}}) + self.assertEqual(0, await db.coll.count_documents({"z": -5})) + self.assertEqual(1, await db.coll.count_documents({"z": 5})) + await db.coll.update_one({"z": 5}, {"$inc": {"z": -10}}, bypass_document_validation=True) + self.assertEqual(0, await db.coll.count_documents({"z": 5})) + self.assertEqual(1, await db.coll.count_documents({"z": -5})) + await db.coll.update_one({"z": -5}, {"$inc": {"z": 6}}, bypass_document_validation=False) + self.assertEqual(1, await db.coll.count_documents({"z": 1})) + self.assertEqual(0, await db.coll.count_documents({"z": -5})) + + await db.coll.insert_one({"z": -10}, bypass_document_validation=True) with self.assertRaises(OperationFailure): - await db.test.update_one({"z": -10}, {"$inc": {"z": 1}}) - self.assertEqual(0, await db.test.count_documents({"z": -9})) - self.assertEqual(1, await db.test.count_documents({"z": -10})) - await db.test.update_one({"z": -10}, {"$inc": {"z": 1}}, bypass_document_validation=True) - self.assertEqual(1, await db.test.count_documents({"z": -9})) - self.assertEqual(0, await db.test.count_documents({"z": -10})) - await db.test.update_one({"z": -9}, {"$inc": {"z": 9}}, bypass_document_validation=False) - self.assertEqual(0, await db.test.count_documents({"z": -9})) - self.assertEqual(1, await db.test.count_documents({"z": 0})) - - await db.test.insert_one({"y": 1, "x": 0}, bypass_document_validation=True) + await db.coll.update_one({"z": -10}, {"$inc": {"z": 1}}) + self.assertEqual(0, await db.coll.count_documents({"z": -9})) + self.assertEqual(1, await db.coll.count_documents({"z": -10})) + await db.coll.update_one({"z": -10}, {"$inc": {"z": 1}}, bypass_document_validation=True) + self.assertEqual(1, await db.coll.count_documents({"z": -9})) + self.assertEqual(0, await db.coll.count_documents({"z": -10})) + await db.coll.update_one({"z": -9}, {"$inc": {"z": 9}}, bypass_document_validation=False) + self.assertEqual(0, await db.coll.count_documents({"z": -9})) + self.assertEqual(1, await db.coll.count_documents({"z": 0})) + + await db.coll.insert_one({"y": 1, "x": 0}, bypass_document_validation=True) await db_w0.test.update_one({"y": 1}, {"$inc": {"x": 1}}, bypass_document_validation=True) async def async_lambda(): @@ -1047,42 +1047,42 @@ async def async_lambda(): await async_wait_until(async_lambda, "find w:0 updated document") # Test update_many - await db.test.insert_many([{"z": i} for i in range(3, 101)]) - await db.test.insert_one({"y": 0}, bypass_document_validation=True) + await db.coll.insert_many([{"z": i} for i in range(3, 101)]) + await db.coll.insert_one({"y": 0}, bypass_document_validation=True) with self.assertRaises(OperationFailure): - await db.test.update_many({}, {"$inc": {"z": -100}}) - self.assertEqual(100, await db.test.count_documents({"z": {"$gte": 0}})) - self.assertEqual(0, await db.test.count_documents({"z": {"$lt": 0}})) - self.assertEqual(0, await db.test.count_documents({"y": 0, "z": -100})) - await db.test.update_many( + await db.coll.update_many({}, {"$inc": {"z": -100}}) + self.assertEqual(100, await db.coll.count_documents({"z": {"$gte": 0}})) + self.assertEqual(0, await db.coll.count_documents({"z": {"$lt": 0}})) + self.assertEqual(0, await db.coll.count_documents({"y": 0, "z": -100})) + await db.coll.update_many( {"z": {"$gte": 0}}, {"$inc": {"z": -100}}, bypass_document_validation=True ) - self.assertEqual(0, await db.test.count_documents({"z": {"$gt": 0}})) - self.assertEqual(100, await db.test.count_documents({"z": {"$lte": 0}})) - await db.test.update_many( + self.assertEqual(0, await db.coll.count_documents({"z": {"$gt": 0}})) + self.assertEqual(100, await db.coll.count_documents({"z": {"$lte": 0}})) + await db.coll.update_many( {"z": {"$gt": -50}}, {"$inc": {"z": 100}}, bypass_document_validation=False ) - self.assertEqual(50, await db.test.count_documents({"z": {"$gt": 0}})) - self.assertEqual(50, await db.test.count_documents({"z": {"$lt": 0}})) + self.assertEqual(50, await db.coll.count_documents({"z": {"$gt": 0}})) + self.assertEqual(50, await db.coll.count_documents({"z": {"$lt": 0}})) - await db.test.insert_many([{"z": -i} for i in range(50)], bypass_document_validation=True) + await db.coll.insert_many([{"z": -i} for i in range(50)], bypass_document_validation=True) with self.assertRaises(OperationFailure): - await db.test.update_many({}, {"$inc": {"z": 1}}) - self.assertEqual(100, await db.test.count_documents({"z": {"$lte": 0}})) - self.assertEqual(50, await db.test.count_documents({"z": {"$gt": 1}})) - await db.test.update_many( + await db.coll.update_many({}, {"$inc": {"z": 1}}) + self.assertEqual(100, await db.coll.count_documents({"z": {"$lte": 0}})) + self.assertEqual(50, await db.coll.count_documents({"z": {"$gt": 1}})) + await db.coll.update_many( {"z": {"$gte": 0}}, {"$inc": {"z": -100}}, bypass_document_validation=True ) - self.assertEqual(0, await db.test.count_documents({"z": {"$gt": 0}})) - self.assertEqual(150, await db.test.count_documents({"z": {"$lte": 0}})) - await db.test.update_many( + self.assertEqual(0, await db.coll.count_documents({"z": {"$gt": 0}})) + self.assertEqual(150, await db.coll.count_documents({"z": {"$lte": 0}})) + await db.coll.update_many( {"z": {"$lte": 0}}, {"$inc": {"z": 100}}, bypass_document_validation=False ) - self.assertEqual(150, await db.test.count_documents({"z": {"$gte": 0}})) - self.assertEqual(0, await db.test.count_documents({"z": {"$lt": 0}})) + self.assertEqual(150, await db.coll.count_documents({"z": {"$gte": 0}})) + self.assertEqual(0, await db.coll.count_documents({"z": {"$lt": 0}})) - await db.test.insert_one({"m": 1, "x": 0}, bypass_document_validation=True) - await db.test.insert_one({"m": 1, "x": 0}, bypass_document_validation=True) + await db.coll.insert_one({"m": 1, "x": 0}, bypass_document_validation=True) + await db.coll.insert_one({"m": 1, "x": 0}, bypass_document_validation=True) await db_w0.test.update_many({"m": 1}, {"$inc": {"x": 1}}, bypass_document_validation=True) async def async_lambda(): @@ -1092,8 +1092,8 @@ async def async_lambda(): async def test_bypass_document_validation_bulk_write(self): db = self.db - await db.test.drop() - await db.create_collection("test", validator={"a": {"$gte": 0}}) + await db.coll.drop() + await db.create_collection("coll", validator={"a": {"$gte": 0}}) db_w0 = self.db.client.get_database(self.db.name, write_concern=WriteConcern(w=0)) ops: list = [ @@ -1104,142 +1104,142 @@ async def test_bypass_document_validation_bulk_write(self): UpdateMany({"a": {"$lte": -10}}, {"$inc": {"a": 1}}), ReplaceOne({"a": {"$lte": -10}}, {"a": -1}), ] - await db.test.bulk_write(ops, bypass_document_validation=True) + await db.coll.bulk_write(ops, bypass_document_validation=True) - self.assertEqual(3, await db.test.count_documents({})) - self.assertEqual(1, await db.test.count_documents({"a": -11})) - self.assertEqual(1, await db.test.count_documents({"a": -1})) - self.assertEqual(1, await db.test.count_documents({"a": -9})) + self.assertEqual(3, await db.coll.count_documents({})) + self.assertEqual(1, await db.coll.count_documents({"a": -11})) + self.assertEqual(1, await db.coll.count_documents({"a": -1})) + self.assertEqual(1, await db.coll.count_documents({"a": -9})) # Assert that the operations would fail without bypass_doc_val for op in ops: with self.assertRaises(BulkWriteError): - await db.test.bulk_write([op]) + await db.coll.bulk_write([op]) with self.assertRaises(OperationFailure): await db_w0.test.bulk_write(ops, bypass_document_validation=True) async def test_find_by_default_dct(self): db = self.db - await db.test.insert_one({"foo": "bar"}) + await db.coll.insert_one({"foo": "bar"}) dct = defaultdict(dict, [("foo", "bar")]) # type: ignore[arg-type] - self.assertIsNotNone(await db.test.find_one(dct)) + self.assertIsNotNone(await db.coll.find_one(dct)) self.assertEqual(dct, defaultdict(dict, [("foo", "bar")])) async def test_find_w_fields(self): db = self.db - await db.test.delete_many({}) + await db.coll.delete_many({}) - await db.test.insert_one( + await db.coll.insert_one( {"x": 1, "mike": "awesome", "extra thing": "abcdefghijklmnopqrstuvwxyz"} ) - self.assertEqual(1, await db.test.count_documents({})) - doc = await anext(db.test.find({})) + self.assertEqual(1, await db.coll.count_documents({})) + doc = await anext(db.coll.find({})) self.assertIn("x", doc) - doc = await anext(db.test.find({})) + doc = await anext(db.coll.find({})) self.assertIn("mike", doc) - doc = await anext(db.test.find({})) + doc = await anext(db.coll.find({})) self.assertIn("extra thing", doc) - doc = await anext(db.test.find({}, ["x", "mike"])) + doc = await anext(db.coll.find({}, ["x", "mike"])) self.assertIn("x", doc) - doc = await anext(db.test.find({}, ["x", "mike"])) + doc = await anext(db.coll.find({}, ["x", "mike"])) self.assertIn("mike", doc) - doc = await anext(db.test.find({}, ["x", "mike"])) + doc = await anext(db.coll.find({}, ["x", "mike"])) self.assertNotIn("extra thing", doc) - doc = await anext(db.test.find({}, ["mike"])) + doc = await anext(db.coll.find({}, ["mike"])) self.assertNotIn("x", doc) - doc = await anext(db.test.find({}, ["mike"])) + doc = await anext(db.coll.find({}, ["mike"])) self.assertIn("mike", doc) - doc = await anext(db.test.find({}, ["mike"])) + doc = await anext(db.coll.find({}, ["mike"])) self.assertNotIn("extra thing", doc) @no_type_check async def test_fields_specifier_as_dict(self): db = self.db - await db.test.delete_many({}) + await db.coll.delete_many({}) - await db.test.insert_one({"x": [1, 2, 3], "mike": "awesome"}) + await db.coll.insert_one({"x": [1, 2, 3], "mike": "awesome"}) - self.assertEqual([1, 2, 3], (await db.test.find_one())["x"]) - self.assertEqual([2, 3], (await db.test.find_one(projection={"x": {"$slice": -2}}))["x"]) - self.assertNotIn("x", await db.test.find_one(projection={"x": 0})) - self.assertIn("mike", await db.test.find_one(projection={"x": 0})) + self.assertEqual([1, 2, 3], (await db.coll.find_one())["x"]) + self.assertEqual([2, 3], (await db.coll.find_one(projection={"x": {"$slice": -2}}))["x"]) + self.assertNotIn("x", await db.coll.find_one(projection={"x": 0})) + self.assertIn("mike", await db.coll.find_one(projection={"x": 0})) async def test_find_w_regex(self): db = self.db - await db.test.delete_many({}) + await db.coll.delete_many({}) - await db.test.insert_one({"x": "hello_world"}) - await db.test.insert_one({"x": "hello_mike"}) - await db.test.insert_one({"x": "hello_mikey"}) - await db.test.insert_one({"x": "hello_test"}) + await db.coll.insert_one({"x": "hello_world"}) + await db.coll.insert_one({"x": "hello_mike"}) + await db.coll.insert_one({"x": "hello_mikey"}) + await db.coll.insert_one({"x": "hello_test"}) - self.assertEqual(len(await db.test.find().to_list()), 4) - self.assertEqual(len(await db.test.find({"x": re.compile("^hello.*")}).to_list()), 4) - self.assertEqual(len(await db.test.find({"x": re.compile("ello")}).to_list()), 4) - self.assertEqual(len(await db.test.find({"x": re.compile("^hello$")}).to_list()), 0) - self.assertEqual(len(await db.test.find({"x": re.compile("^hello_mi.*$")}).to_list()), 2) + self.assertEqual(len(await db.coll.find().to_list()), 4) + self.assertEqual(len(await db.coll.find({"x": re.compile("^hello.*")}).to_list()), 4) + self.assertEqual(len(await db.coll.find({"x": re.compile("ello")}).to_list()), 4) + self.assertEqual(len(await db.coll.find({"x": re.compile("^hello$")}).to_list()), 0) + self.assertEqual(len(await db.coll.find({"x": re.compile("^hello_mi.*$")}).to_list()), 2) async def test_id_can_be_anything(self): db = self.db - await db.test.delete_many({}) + await db.coll.delete_many({}) auto_id = {"hello": "world"} - await db.test.insert_one(auto_id) + await db.coll.insert_one(auto_id) self.assertIsInstance(auto_id["_id"], ObjectId) numeric = {"_id": 240, "hello": "world"} - await db.test.insert_one(numeric) + await db.coll.insert_one(numeric) self.assertEqual(numeric["_id"], 240) obj = {"_id": numeric, "hello": "world"} - await db.test.insert_one(obj) + await db.coll.insert_one(obj) self.assertEqual(obj["_id"], numeric) - async for x in db.test.find(): + async for x in db.coll.find(): self.assertEqual(x["hello"], "world") self.assertIn("_id", x) async def test_unique_index(self): db = self.db - await db.drop_collection("test") - await db.test.create_index("hello") + await db.drop_collection("coll") + await db.coll.create_index("hello") # No error. - await db.test.insert_one({"hello": "world"}) - await db.test.insert_one({"hello": "world"}) + await db.coll.insert_one({"hello": "world"}) + await db.coll.insert_one({"hello": "world"}) - await db.drop_collection("test") - await db.test.create_index("hello", unique=True) + await db.drop_collection("coll") + await db.coll.create_index("hello", unique=True) with self.assertRaises(DuplicateKeyError): - await db.test.insert_one({"hello": "world"}) - await db.test.insert_one({"hello": "world"}) + await db.coll.insert_one({"hello": "world"}) + await db.coll.insert_one({"hello": "world"}) async def test_duplicate_key_error(self): db = self.db - await db.drop_collection("test") + await db.drop_collection("coll") - await db.test.create_index("x", unique=True) + await db.coll.create_index("x", unique=True) - await db.test.insert_one({"_id": 1, "x": 1}) + await db.coll.insert_one({"_id": 1, "x": 1}) with self.assertRaises(DuplicateKeyError) as context: - await db.test.insert_one({"x": 1}) + await db.coll.insert_one({"x": 1}) self.assertIsNotNone(context.exception.details) with self.assertRaises(DuplicateKeyError) as context: - await db.test.insert_one({"x": 1}) + await db.coll.insert_one({"x": 1}) self.assertIsNotNone(context.exception.details) - self.assertEqual(1, await db.test.count_documents({})) + self.assertEqual(1, await db.coll.count_documents({})) async def test_write_error_text_handling(self): db = self.db - await db.drop_collection("test") + await db.drop_collection("coll") - await db.test.create_index("text", unique=True) + await db.coll.create_index("text", unique=True) # Test workaround for SERVER-24007 data = ( @@ -1274,21 +1274,21 @@ async def test_write_error_text_handling(self): ) text = utf_8_decode(data, None, True) - await db.test.insert_one({"text": text}) + await db.coll.insert_one({"text": text}) # Should raise DuplicateKeyError, not InvalidBSON with self.assertRaises(DuplicateKeyError): - await db.test.insert_one({"text": text}) + await db.coll.insert_one({"text": text}) with self.assertRaises(DuplicateKeyError): - await db.test.replace_one({"_id": ObjectId()}, {"text": text}, upsert=True) + await db.coll.replace_one({"_id": ObjectId()}, {"text": text}, upsert=True) # Should raise BulkWriteError, not InvalidBSON with self.assertRaises(BulkWriteError): - await db.test.insert_many([{"text": text}]) + await db.coll.insert_many([{"text": text}]) async def test_write_error_unicode(self): - coll = self.db.test + coll = self.db.coll self.addAsyncCleanup(coll.drop) await coll.create_index("a", unique=True) @@ -1302,7 +1302,7 @@ async def test_write_error_unicode(self): async def test_wtimeout(self): # Ensure setting wtimeout doesn't disable write concern altogether. # See SERVER-12596. - collection = self.db.test + collection = self.db.coll await collection.drop() await collection.insert_one({"_id": 1}) @@ -1316,7 +1316,7 @@ async def test_wtimeout(self): async def test_error_code(self): try: - await self.db.test.update_many({}, {"$thismodifierdoesntexist": 1}) + await self.db.coll.update_many({}, {"$thismodifierdoesntexist": 1}) except OperationFailure as exc: self.assertIn(exc.code, (9, 10147, 16840, 17009)) # Just check that we set the error document. Fields @@ -1327,59 +1327,59 @@ async def test_error_code(self): async def test_index_on_subfield(self): db = self.db - await db.drop_collection("test") + await db.drop_collection("coll") - await db.test.insert_one({"hello": {"a": 4, "b": 5}}) - await db.test.insert_one({"hello": {"a": 7, "b": 2}}) - await db.test.insert_one({"hello": {"a": 4, "b": 10}}) + await db.coll.insert_one({"hello": {"a": 4, "b": 5}}) + await db.coll.insert_one({"hello": {"a": 7, "b": 2}}) + await db.coll.insert_one({"hello": {"a": 4, "b": 10}}) - await db.drop_collection("test") - await db.test.create_index("hello.a", unique=True) + await db.drop_collection("coll") + await db.coll.create_index("hello.a", unique=True) - await db.test.insert_one({"hello": {"a": 4, "b": 5}}) - await db.test.insert_one({"hello": {"a": 7, "b": 2}}) + await db.coll.insert_one({"hello": {"a": 4, "b": 5}}) + await db.coll.insert_one({"hello": {"a": 7, "b": 2}}) with self.assertRaises(DuplicateKeyError): - await db.test.insert_one({"hello": {"a": 4, "b": 10}}) + await db.coll.insert_one({"hello": {"a": 4, "b": 10}}) async def test_replace_one(self): db = self.db - await db.drop_collection("test") + await db.drop_collection("coll") with self.assertRaises(ValueError): - await db.test.replace_one({}, {"$set": {"x": 1}}) + await db.coll.replace_one({}, {"$set": {"x": 1}}) - id1 = (await db.test.insert_one({"x": 1})).inserted_id - result = await db.test.replace_one({"x": 1}, {"y": 1}) + id1 = (await db.coll.insert_one({"x": 1})).inserted_id + result = await db.coll.replace_one({"x": 1}, {"y": 1}) self.assertIsInstance(result, UpdateResult) self.assertEqual(1, result.matched_count) self.assertIn(result.modified_count, (None, 1)) self.assertIsNone(result.upserted_id) self.assertTrue(result.acknowledged) - self.assertEqual(1, await db.test.count_documents({"y": 1})) - self.assertEqual(0, await db.test.count_documents({"x": 1})) - self.assertEqual((await db.test.find_one(id1))["y"], 1) # type: ignore + self.assertEqual(1, await db.coll.count_documents({"y": 1})) + self.assertEqual(0, await db.coll.count_documents({"x": 1})) + self.assertEqual((await db.coll.find_one(id1))["y"], 1) # type: ignore replacement = RawBSONDocument(encode({"_id": id1, "z": 1})) - result = await db.test.replace_one({"y": 1}, replacement, True) + result = await db.coll.replace_one({"y": 1}, replacement, True) self.assertIsInstance(result, UpdateResult) self.assertEqual(1, result.matched_count) self.assertIn(result.modified_count, (None, 1)) self.assertIsNone(result.upserted_id) self.assertTrue(result.acknowledged) - self.assertEqual(1, await db.test.count_documents({"z": 1})) - self.assertEqual(0, await db.test.count_documents({"y": 1})) - self.assertEqual((await db.test.find_one(id1))["z"], 1) # type: ignore + self.assertEqual(1, await db.coll.count_documents({"z": 1})) + self.assertEqual(0, await db.coll.count_documents({"y": 1})) + self.assertEqual((await db.coll.find_one(id1))["z"], 1) # type: ignore - result = await db.test.replace_one({"x": 2}, {"y": 2}, True) + result = await db.coll.replace_one({"x": 2}, {"y": 2}, True) self.assertIsInstance(result, UpdateResult) self.assertEqual(0, result.matched_count) self.assertIn(result.modified_count, (None, 0)) self.assertIsInstance(result.upserted_id, ObjectId) self.assertTrue(result.acknowledged) - self.assertEqual(1, await db.test.count_documents({"y": 2})) + self.assertEqual(1, await db.coll.count_documents({"y": 2})) db = db.client.get_database(db.name, write_concern=WriteConcern(w=0)) - result = await db.test.replace_one({"x": 0}, {"y": 0}) + result = await db.coll.replace_one({"x": 0}, {"y": 0}) self.assertIsInstance(result, UpdateResult) self.assertRaises(InvalidOperation, lambda: result.matched_count) self.assertRaises(InvalidOperation, lambda: result.modified_count) @@ -1388,31 +1388,31 @@ async def test_replace_one(self): async def test_update_one(self): db = self.db - await db.drop_collection("test") + await db.drop_collection("coll") with self.assertRaises(ValueError): - await db.test.update_one({}, {"x": 1}) + await db.coll.update_one({}, {"x": 1}) - id1 = (await db.test.insert_one({"x": 5})).inserted_id - result = await db.test.update_one({}, {"$inc": {"x": 1}}) + id1 = (await db.coll.insert_one({"x": 5})).inserted_id + result = await db.coll.update_one({}, {"$inc": {"x": 1}}) self.assertIsInstance(result, UpdateResult) self.assertEqual(1, result.matched_count) self.assertIn(result.modified_count, (None, 1)) self.assertIsNone(result.upserted_id) self.assertTrue(result.acknowledged) - self.assertEqual((await db.test.find_one(id1))["x"], 6) # type: ignore + self.assertEqual((await db.coll.find_one(id1))["x"], 6) # type: ignore - id2 = (await db.test.insert_one({"x": 1})).inserted_id - result = await db.test.update_one({"x": 6}, {"$inc": {"x": 1}}) + id2 = (await db.coll.insert_one({"x": 1})).inserted_id + result = await db.coll.update_one({"x": 6}, {"$inc": {"x": 1}}) self.assertIsInstance(result, UpdateResult) self.assertEqual(1, result.matched_count) self.assertIn(result.modified_count, (None, 1)) self.assertIsNone(result.upserted_id) self.assertTrue(result.acknowledged) - self.assertEqual((await db.test.find_one(id1))["x"], 7) # type: ignore - self.assertEqual((await db.test.find_one(id2))["x"], 1) # type: ignore + self.assertEqual((await db.coll.find_one(id1))["x"], 7) # type: ignore + self.assertEqual((await db.coll.find_one(id2))["x"], 1) # type: ignore - result = await db.test.update_one({"x": 2}, {"$set": {"y": 1}}, True) + result = await db.coll.update_one({"x": 2}, {"$set": {"y": 1}}, True) self.assertIsInstance(result, UpdateResult) self.assertEqual(0, result.matched_count) self.assertIn(result.modified_count, (None, 0)) @@ -1420,7 +1420,7 @@ async def test_update_one(self): self.assertTrue(result.acknowledged) db = db.client.get_database(db.name, write_concern=WriteConcern(w=0)) - result = await db.test.update_one({"x": 0}, {"$inc": {"x": 1}}) + result = await db.coll.update_one({"x": 0}, {"$inc": {"x": 1}}) self.assertIsInstance(result, UpdateResult) self.assertRaises(InvalidOperation, lambda: result.matched_count) self.assertRaises(InvalidOperation, lambda: result.modified_count) @@ -1429,45 +1429,45 @@ async def test_update_one(self): async def test_update_result(self): db = self.db - await db.drop_collection("test") + await db.drop_collection("coll") - result = await db.test.update_one({"x": 0}, {"$inc": {"x": 1}}, upsert=True) + result = await db.coll.update_one({"x": 0}, {"$inc": {"x": 1}}, upsert=True) self.assertEqual(result.did_upsert, True) - result = await db.test.update_one({"_id": None, "x": 0}, {"$inc": {"x": 1}}, upsert=True) + result = await db.coll.update_one({"_id": None, "x": 0}, {"$inc": {"x": 1}}, upsert=True) self.assertEqual(result.did_upsert, True) - result = await db.test.update_one({"_id": None}, {"$inc": {"x": 1}}) + result = await db.coll.update_one({"_id": None}, {"$inc": {"x": 1}}) self.assertEqual(result.did_upsert, False) async def test_update_many(self): db = self.db - await db.drop_collection("test") + await db.drop_collection("coll") with self.assertRaises(ValueError): - await db.test.update_many({}, {"x": 1}) + await db.coll.update_many({}, {"x": 1}) - await db.test.insert_one({"x": 4, "y": 3}) - await db.test.insert_one({"x": 5, "y": 5}) - await db.test.insert_one({"x": 4, "y": 4}) + await db.coll.insert_one({"x": 4, "y": 3}) + await db.coll.insert_one({"x": 5, "y": 5}) + await db.coll.insert_one({"x": 4, "y": 4}) - result = await db.test.update_many({"x": 4}, {"$set": {"y": 5}}) + result = await db.coll.update_many({"x": 4}, {"$set": {"y": 5}}) self.assertIsInstance(result, UpdateResult) self.assertEqual(2, result.matched_count) self.assertIn(result.modified_count, (None, 2)) self.assertIsNone(result.upserted_id) self.assertTrue(result.acknowledged) - self.assertEqual(3, await db.test.count_documents({"y": 5})) + self.assertEqual(3, await db.coll.count_documents({"y": 5})) - result = await db.test.update_many({"x": 5}, {"$set": {"y": 6}}) + result = await db.coll.update_many({"x": 5}, {"$set": {"y": 6}}) self.assertIsInstance(result, UpdateResult) self.assertEqual(1, result.matched_count) self.assertIn(result.modified_count, (None, 1)) self.assertIsNone(result.upserted_id) self.assertTrue(result.acknowledged) - self.assertEqual(1, await db.test.count_documents({"y": 6})) + self.assertEqual(1, await db.coll.count_documents({"y": 6})) - result = await db.test.update_many({"x": 2}, {"$set": {"y": 1}}, True) + result = await db.coll.update_many({"x": 2}, {"$set": {"y": 1}}, True) self.assertIsInstance(result, UpdateResult) self.assertEqual(0, result.matched_count) self.assertIn(result.modified_count, (None, 0)) @@ -1475,7 +1475,7 @@ async def test_update_many(self): self.assertTrue(result.acknowledged) db = db.client.get_database(db.name, write_concern=WriteConcern(w=0)) - result = await db.test.update_many({"x": 0}, {"$inc": {"x": 1}}) + result = await db.coll.update_many({"x": 0}, {"$inc": {"x": 1}}) self.assertIsInstance(result, UpdateResult) self.assertRaises(InvalidOperation, lambda: result.matched_count) self.assertRaises(InvalidOperation, lambda: result.modified_count) @@ -1483,12 +1483,12 @@ async def test_update_many(self): self.assertFalse(result.acknowledged) async def test_update_check_keys(self): - await self.db.drop_collection("test") - self.assertTrue(await self.db.test.insert_one({"hello": "world"})) + await self.db.drop_collection("coll") + self.assertTrue(await self.db.coll.insert_one({"hello": "world"})) # Modify shouldn't check keys... self.assertTrue( - await self.db.test.update_one( + await self.db.coll.update_one( {"hello": "world"}, {"$set": {"foo.bar": "baz"}}, upsert=True ) ) @@ -1497,7 +1497,7 @@ async def test_update_check_keys(self): # by CI if the server's behavior changes here. doc = SON([("$set", {"foo.bar": "bim"}), ("hello", "world")]) with self.assertRaises(OperationFailure): - await self.db.test.update_one({"hello": "world"}, doc, upsert=True) + await self.db.coll.update_one({"hello": "world"}, doc, upsert=True) # This is going to cause keys to be checked and raise InvalidDocument. # That's OK assuming the server's behavior in the previous assert @@ -1505,61 +1505,61 @@ async def test_update_check_keys(self): # '$' in update won't be good enough anymore. doc = SON([("hello", "world"), ("$set", {"foo.bar": "bim"})]) with self.assertRaises(OperationFailure): - await self.db.test.replace_one({"hello": "world"}, doc, upsert=True) + await self.db.coll.replace_one({"hello": "world"}, doc, upsert=True) # Replace with empty document self.assertNotEqual( - 0, (await self.db.test.replace_one({"hello": "world"}, {})).matched_count + 0, (await self.db.coll.replace_one({"hello": "world"}, {})).matched_count ) async def test_acknowledged_delete(self): db = self.db - await db.drop_collection("test") - await db.test.insert_many([{"x": 1}, {"x": 1}]) - self.assertEqual(2, (await db.test.delete_many({})).deleted_count) - self.assertEqual(0, (await db.test.delete_many({})).deleted_count) + await db.drop_collection("coll") + await db.coll.insert_many([{"x": 1}, {"x": 1}]) + self.assertEqual(2, (await db.coll.delete_many({})).deleted_count) + self.assertEqual(0, (await db.coll.delete_many({})).deleted_count) @async_client_context.require_version_max(4, 9) async def test_manual_last_error(self): - coll = self.db.get_collection("test", write_concern=WriteConcern(w=0)) + coll = self.db.get_collection("coll", write_concern=WriteConcern(w=0)) await coll.insert_one({"x": 1}) await self.db.command("getlasterror", w=1, wtimeout=1) async def test_count_documents(self): db = self.db - await db.drop_collection("test") - self.addAsyncCleanup(db.drop_collection, "test") + await db.drop_collection("coll") + self.addAsyncCleanup(db.drop_collection, "coll") - self.assertEqual(await db.test.count_documents({}), 0) + self.assertEqual(await db.coll.count_documents({}), 0) await db.wrong.insert_many([{}, {}]) - self.assertEqual(await db.test.count_documents({}), 0) - await db.test.insert_many([{}, {}]) - self.assertEqual(await db.test.count_documents({}), 2) - await db.test.insert_many([{"foo": "bar"}, {"foo": "baz"}]) - self.assertEqual(await db.test.count_documents({"foo": "bar"}), 1) - self.assertEqual(await db.test.count_documents({"foo": re.compile(r"ba.*")}), 2) + self.assertEqual(await db.coll.count_documents({}), 0) + await db.coll.insert_many([{}, {}]) + self.assertEqual(await db.coll.count_documents({}), 2) + await db.coll.insert_many([{"foo": "bar"}, {"foo": "baz"}]) + self.assertEqual(await db.coll.count_documents({"foo": "bar"}), 1) + self.assertEqual(await db.coll.count_documents({"foo": re.compile(r"ba.*")}), 2) async def test_estimated_document_count(self): db = self.db - await db.drop_collection("test") - self.addAsyncCleanup(db.drop_collection, "test") + await db.drop_collection("coll") + self.addAsyncCleanup(db.drop_collection, "coll") - self.assertEqual(await db.test.estimated_document_count(), 0) + self.assertEqual(await db.coll.estimated_document_count(), 0) await db.wrong.insert_many([{}, {}]) - self.assertEqual(await db.test.estimated_document_count(), 0) - await db.test.insert_many([{}, {}]) - self.assertEqual(await db.test.estimated_document_count(), 2) + self.assertEqual(await db.coll.estimated_document_count(), 0) + await db.coll.insert_many([{}, {}]) + self.assertEqual(await db.coll.estimated_document_count(), 2) async def test_aggregate(self): db = self.db - await db.drop_collection("test") - await db.test.insert_one({"foo": [1, 2]}) + await db.drop_collection("coll") + await db.coll.insert_one({"foo": [1, 2]}) with self.assertRaises(TypeError): - await db.test.aggregate("wow") # type: ignore[arg-type] + await db.coll.aggregate("wow") # type: ignore[arg-type] pipeline = {"$project": {"_id": False, "foo": True}} - result = await db.test.aggregate([pipeline]) + result = await db.coll.aggregate([pipeline]) self.assertIsInstance(result, AsyncCommandCursor) self.assertEqual([{"foo": [1, 2]}], await result.to_list()) @@ -1569,14 +1569,14 @@ async def test_aggregate(self): async def test_aggregate_raw_bson(self): db = self.db - await db.drop_collection("test") - await db.test.insert_one({"foo": [1, 2]}) + await db.drop_collection("coll") + await db.coll.insert_one({"foo": [1, 2]}) with self.assertRaises(TypeError): - await db.test.aggregate("wow") # type: ignore[arg-type] + await db.coll.aggregate("wow") # type: ignore[arg-type] pipeline = {"$project": {"_id": False, "foo": True}} - coll = db.get_collection("test", codec_options=CodecOptions(document_class=RawBSONDocument)) + coll = db.get_collection("coll", codec_options=CodecOptions(document_class=RawBSONDocument)) result = await coll.aggregate([pipeline]) self.assertIsInstance(result, AsyncCommandCursor) first_result = await anext(result) @@ -1586,7 +1586,7 @@ async def test_aggregate_raw_bson(self): async def test_aggregation_cursor_validation(self): db = self.db projection = {"$project": {"_id": "$_id"}} - cursor = await db.test.aggregate([projection], cursor={}) + cursor = await db.coll.aggregate([projection], cursor={}) self.assertIsInstance(cursor, AsyncCommandCursor) async def test_aggregation_cursor(self): @@ -1600,16 +1600,16 @@ async def test_aggregation_cursor(self): ) for collection_size in (10, 1000): - await db.drop_collection("test") - await db.test.insert_many([{"_id": i} for i in range(collection_size)]) + await db.drop_collection("coll") + await db.coll.insert_many([{"_id": i} for i in range(collection_size)]) expected_sum = sum(range(collection_size)) # Use batchSize to ensure multiple getMore messages - cursor = await db.test.aggregate([{"$project": {"_id": "$_id"}}], batchSize=5) + cursor = await db.coll.aggregate([{"$project": {"_id": "$_id"}}], batchSize=5) self.assertEqual(expected_sum, sum(doc["_id"] for doc in await cursor.to_list())) # Test that batchSize is handled properly. - cursor = await db.test.aggregate([], batchSize=5) + cursor = await db.coll.aggregate([], batchSize=5) self.assertEqual(5, len(cursor._data)) # Force a getMore cursor._data.clear() @@ -1621,10 +1621,10 @@ async def test_aggregation_cursor(self): pass async def test_aggregation_cursor_alive(self): - await self.db.test.delete_many({}) - await self.db.test.insert_many([{} for _ in range(3)]) - self.addAsyncCleanup(self.db.test.delete_many, {}) - cursor = await self.db.test.aggregate(pipeline=[], cursor={"batchSize": 2}) + await self.db.coll.delete_many({}) + await self.db.coll.insert_many([{} for _ in range(3)]) + self.addAsyncCleanup(self.db.coll.delete_many, {}) + cursor = await self.db.coll.aggregate(pipeline=[], cursor={"batchSize": 2}) n = 0 while True: await cursor.next() @@ -1637,7 +1637,7 @@ async def test_aggregation_cursor_alive(self): async def test_invalid_session_parameter(self): async def try_invalid_session(): - with await self.db.test.aggregate([], {}): # type:ignore + with await self.db.coll.aggregate([], {}): # type:ignore pass with self.assertRaisesRegex(ValueError, "must be an AsyncClientSession"): @@ -1646,14 +1646,14 @@ async def try_invalid_session(): async def test_large_limit(self): db = self.db await db.drop_collection("test_large_limit") - await db.test_large_limit.create_index([("x", 1)]) + await db.coll_large_limit.create_index([("x", 1)]) my_str = "mongomongo" * 1000 - await db.test_large_limit.insert_many({"x": i, "y": my_str} for i in range(2000)) + await db.coll_large_limit.insert_many({"x": i, "y": my_str} for i in range(2000)) i = 0 y = 0 - async for doc in db.test_large_limit.find(limit=1900).sort([("x", 1)]): + async for doc in db.coll_large_limit.find(limit=1900).sort([("x", 1)]): i += 1 y += doc["x"] @@ -1662,45 +1662,45 @@ async def test_large_limit(self): async def test_find_kwargs(self): db = self.db - await db.drop_collection("test") - await db.test.insert_many({"x": i} for i in range(10)) + await db.drop_collection("coll") + await db.coll.insert_many({"x": i} for i in range(10)) - self.assertEqual(10, await db.test.count_documents({})) + self.assertEqual(10, await db.coll.count_documents({})) total = 0 - async for x in db.test.find({}, skip=4, limit=2): + async for x in db.coll.find({}, skip=4, limit=2): total += x["x"] self.assertEqual(9, total) async def test_rename(self): db = self.db - await db.drop_collection("test") + await db.drop_collection("coll") await db.drop_collection("foo") with self.assertRaises(TypeError): - await db.test.rename(5) # type: ignore[arg-type] + await db.coll.rename(5) # type: ignore[arg-type] with self.assertRaises(InvalidName): - await db.test.rename("") + await db.coll.rename("") with self.assertRaises(InvalidName): - await db.test.rename("te$t") + await db.coll.rename("te$t") with self.assertRaises(InvalidName): - await db.test.rename(".test") + await db.coll.rename(".test") with self.assertRaises(InvalidName): - await db.test.rename("test.") + await db.coll.rename("test.") with self.assertRaises(InvalidName): - await db.test.rename("tes..t") + await db.coll.rename("tes..t") - self.assertEqual(0, await db.test.count_documents({})) + self.assertEqual(0, await db.coll.count_documents({})) self.assertEqual(0, await db.foo.count_documents({})) - await db.test.insert_many({"x": i} for i in range(10)) + await db.coll.insert_many({"x": i} for i in range(10)) - self.assertEqual(10, await db.test.count_documents({})) + self.assertEqual(10, await db.coll.count_documents({})) - await db.test.rename("foo") + await db.coll.rename("foo") - self.assertEqual(0, await db.test.count_documents({})) + self.assertEqual(0, await db.coll.count_documents({})) self.assertEqual(10, await db.foo.count_documents({})) x = 0 @@ -1708,10 +1708,10 @@ async def test_rename(self): self.assertEqual(x, doc["x"]) x += 1 - await db.test.insert_one({}) + await db.coll.insert_one({}) with self.assertRaises(OperationFailure): - await db.foo.rename("test") - await db.foo.rename("test", dropTarget=True) + await db.foo.rename("coll") + await db.foo.rename("coll", dropTarget=True) with self.write_concern_collection() as coll: await coll.rename("foo") @@ -1719,112 +1719,112 @@ async def test_rename(self): @no_type_check async def test_find_one(self): db = self.db - await db.drop_collection("test") + await db.drop_collection("coll") - _id = (await db.test.insert_one({"hello": "world", "foo": "bar"})).inserted_id + _id = (await db.coll.insert_one({"hello": "world", "foo": "bar"})).inserted_id - self.assertEqual("world", (await db.test.find_one())["hello"]) - self.assertEqual(await db.test.find_one(_id), await db.test.find_one()) - self.assertEqual(await db.test.find_one(None), await db.test.find_one()) - self.assertEqual(await db.test.find_one({}), await db.test.find_one()) - self.assertEqual(await db.test.find_one({"hello": "world"}), await db.test.find_one()) + self.assertEqual("world", (await db.coll.find_one())["hello"]) + self.assertEqual(await db.coll.find_one(_id), await db.coll.find_one()) + self.assertEqual(await db.coll.find_one(None), await db.coll.find_one()) + self.assertEqual(await db.coll.find_one({}), await db.coll.find_one()) + self.assertEqual(await db.coll.find_one({"hello": "world"}), await db.coll.find_one()) - self.assertIn("hello", await db.test.find_one(projection=["hello"])) - self.assertNotIn("hello", await db.test.find_one(projection=["foo"])) + self.assertIn("hello", await db.coll.find_one(projection=["hello"])) + self.assertNotIn("hello", await db.coll.find_one(projection=["foo"])) - self.assertIn("hello", await db.test.find_one(projection=("hello",))) - self.assertNotIn("hello", await db.test.find_one(projection=("foo",))) + self.assertIn("hello", await db.coll.find_one(projection=("hello",))) + self.assertNotIn("hello", await db.coll.find_one(projection=("foo",))) - self.assertIn("hello", await db.test.find_one(projection={"hello"})) - self.assertNotIn("hello", await db.test.find_one(projection={"foo"})) + self.assertIn("hello", await db.coll.find_one(projection={"hello"})) + self.assertNotIn("hello", await db.coll.find_one(projection={"foo"})) - self.assertIn("hello", await db.test.find_one(projection=frozenset(["hello"]))) - self.assertNotIn("hello", await db.test.find_one(projection=frozenset(["foo"]))) + self.assertIn("hello", await db.coll.find_one(projection=frozenset(["hello"]))) + self.assertNotIn("hello", await db.coll.find_one(projection=frozenset(["foo"]))) - self.assertEqual(["_id"], list(await db.test.find_one(projection={"_id": True}))) - self.assertIn("hello", list(await db.test.find_one(projection={}))) - self.assertIn("hello", list(await db.test.find_one(projection=[]))) + self.assertEqual(["_id"], list(await db.coll.find_one(projection={"_id": True}))) + self.assertIn("hello", list(await db.coll.find_one(projection={}))) + self.assertIn("hello", list(await db.coll.find_one(projection=[]))) - self.assertEqual(None, await db.test.find_one({"hello": "foo"})) - self.assertEqual(None, await db.test.find_one(ObjectId())) + self.assertEqual(None, await db.coll.find_one({"hello": "foo"})) + self.assertEqual(None, await db.coll.find_one(ObjectId())) async def test_find_one_non_objectid(self): db = self.db - await db.drop_collection("test") + await db.drop_collection("coll") - await db.test.insert_one({"_id": 5}) + await db.coll.insert_one({"_id": 5}) - self.assertTrue(await db.test.find_one(5)) - self.assertFalse(await db.test.find_one(6)) + self.assertTrue(await db.coll.find_one(5)) + self.assertFalse(await db.coll.find_one(6)) async def test_find_one_with_find_args(self): db = self.db - await db.drop_collection("test") + await db.drop_collection("coll") - await db.test.insert_many([{"x": i} for i in range(1, 4)]) + await db.coll.insert_many([{"x": i} for i in range(1, 4)]) - self.assertEqual(1, (await db.test.find_one())["x"]) - self.assertEqual(2, (await db.test.find_one(skip=1, limit=2))["x"]) + self.assertEqual(1, (await db.coll.find_one())["x"]) + self.assertEqual(2, (await db.coll.find_one(skip=1, limit=2))["x"]) async def test_find_with_sort(self): db = self.db - await db.drop_collection("test") + await db.drop_collection("coll") - await db.test.insert_many([{"x": 2}, {"x": 1}, {"x": 3}]) + await db.coll.insert_many([{"x": 2}, {"x": 1}, {"x": 3}]) - self.assertEqual(2, (await db.test.find_one())["x"]) - self.assertEqual(1, (await db.test.find_one(sort=[("x", 1)]))["x"]) - self.assertEqual(3, (await db.test.find_one(sort=[("x", -1)]))["x"]) + self.assertEqual(2, (await db.coll.find_one())["x"]) + self.assertEqual(1, (await db.coll.find_one(sort=[("x", 1)]))["x"]) + self.assertEqual(3, (await db.coll.find_one(sort=[("x", -1)]))["x"]) async def to_list(things): return [thing["x"] async for thing in things] - self.assertEqual([2, 1, 3], await to_list(db.test.find())) - self.assertEqual([1, 2, 3], await to_list(db.test.find(sort=[("x", 1)]))) - self.assertEqual([3, 2, 1], await to_list(db.test.find(sort=[("x", -1)]))) + self.assertEqual([2, 1, 3], await to_list(db.coll.find())) + self.assertEqual([1, 2, 3], await to_list(db.coll.find(sort=[("x", 1)]))) + self.assertEqual([3, 2, 1], await to_list(db.coll.find(sort=[("x", -1)]))) with self.assertRaises(TypeError): - await db.test.find(sort=5) + await db.coll.find(sort=5) with self.assertRaises(TypeError): - await db.test.find(sort="hello") + await db.coll.find(sort="hello") with self.assertRaises(TypeError): - await db.test.find(sort=["hello", 1]) + await db.coll.find(sort=["hello", 1]) # TODO doesn't actually test functionality, just that it doesn't blow up async def test_cursor_timeout(self): - await self.db.test.find(no_cursor_timeout=True).to_list() - await self.db.test.find(no_cursor_timeout=False).to_list() + await self.db.coll.find(no_cursor_timeout=True).to_list() + await self.db.coll.find(no_cursor_timeout=False).to_list() async def test_exhaust(self): if await async_is_mongos(self.db.client): with self.assertRaises(InvalidOperation): - await anext(self.db.test.find(cursor_type=CursorType.EXHAUST)) + await anext(self.db.coll.find(cursor_type=CursorType.EXHAUST)) return # Limit is incompatible with exhaust. with self.assertRaises(InvalidOperation): - await anext(self.db.test.find(cursor_type=CursorType.EXHAUST, limit=5)) - cur = self.db.test.find(cursor_type=CursorType.EXHAUST) + await anext(self.db.coll.find(cursor_type=CursorType.EXHAUST, limit=5)) + cur = self.db.coll.find(cursor_type=CursorType.EXHAUST) with self.assertRaises(InvalidOperation): cur.limit(5) await cur.next() - cur = self.db.test.find(limit=5) + cur = self.db.coll.find(limit=5) with self.assertRaises(InvalidOperation): await cur.add_option(64) - cur = self.db.test.find() + cur = self.db.coll.find() await cur.add_option(64) with self.assertRaises(InvalidOperation): cur.limit(5) - await self.db.drop_collection("test") + await self.db.drop_collection("coll") # Insert enough documents to require more than one batch - await self.db.test.insert_many([{"i": i} for i in range(150)]) + await self.db.coll.insert_many([{"i": i} for i in range(150)]) client = await self.async_rs_or_single_client(maxPoolSize=1) pool = await async_get_pool(client) # Make sure the socket is returned after exhaustion. - cur = client[self.db.name].test.find(cursor_type=CursorType.EXHAUST) + cur = client[self.db.name].coll.find(cursor_type=CursorType.EXHAUST) await anext(cur) self.assertEqual(0, len(pool.conns)) async for _ in cur: @@ -1832,14 +1832,14 @@ async def test_exhaust(self): self.assertEqual(1, len(pool.conns)) # Same as previous but don't call next() - async for _ in client[self.db.name].test.find(cursor_type=CursorType.EXHAUST): + async for _ in client[self.db.name].coll.find(cursor_type=CursorType.EXHAUST): pass self.assertEqual(1, len(pool.conns)) # If the Cursor instance is discarded before being completely iterated # and the socket has pending data (more_to_come=True) we have to close # and discard the socket. - cur = client[self.db.name].test.find(cursor_type=CursorType.EXHAUST, batch_size=2) + cur = client[self.db.name].coll.find(cursor_type=CursorType.EXHAUST, batch_size=2) if async_client_context.version.at_least(4, 2): # On 4.2+ we use OP_MSG which only sets more_to_come=True after the # first getMore. @@ -1858,9 +1858,9 @@ async def test_exhaust(self): self.assertEqual(0, len(pool.conns)) async def test_distinct(self): - await self.db.drop_collection("test") + await self.db.drop_collection("coll") - test = self.db.test + test = self.db.coll await test.insert_many([{"a": 1}, {"a": 2}, {"a": 2}, {"a": 2}, {"a": 3}]) distinct = await test.distinct("a") @@ -1876,7 +1876,7 @@ async def test_distinct(self): distinct.sort() self.assertEqual([2, 3], distinct) - await self.db.drop_collection("test") + await self.db.drop_collection("coll") await test.insert_one({"a": {"b": "a"}, "c": 12}) await test.insert_one({"a": {"b": "b"}, "c": 12}) @@ -1889,19 +1889,19 @@ async def test_distinct(self): self.assertEqual(["a", "b", "c"], distinct) async def test_query_on_query_field(self): - await self.db.drop_collection("test") - await self.db.test.insert_one({"query": "foo"}) - await self.db.test.insert_one({"bar": "foo"}) + await self.db.drop_collection("coll") + await self.db.coll.insert_one({"query": "foo"}) + await self.db.coll.insert_one({"bar": "foo"}) - self.assertEqual(1, await self.db.test.count_documents({"query": {"$ne": None}})) - self.assertEqual(1, len(await self.db.test.find({"query": {"$ne": None}}).to_list())) + self.assertEqual(1, await self.db.coll.count_documents({"query": {"$ne": None}})) + self.assertEqual(1, len(await self.db.coll.find({"query": {"$ne": None}}).to_list())) async def test_min_query(self): - await self.db.drop_collection("test") - await self.db.test.insert_many([{"x": 1}, {"x": 2}]) - await self.db.test.create_index("x") + await self.db.drop_collection("coll") + await self.db.coll.insert_many([{"x": 1}, {"x": 2}]) + await self.db.coll.create_index("x") - cursor = self.db.test.find({"$min": {"x": 2}, "$query": {}}, hint="x_1") + cursor = self.db.coll.find({"$min": {"x": 2}, "$query": {}}, hint="x_1") docs = await cursor.to_list() self.assertEqual(1, len(docs)) @@ -1909,11 +1909,11 @@ async def test_min_query(self): async def test_numerous_inserts(self): # Ensure we don't exceed server's maxWriteBatchSize size limit. - await self.db.test.drop() + await self.db.coll.drop() n_docs = await async_client_context.max_write_batch_size + 100 - await self.db.test.insert_many([{} for _ in range(n_docs)]) - self.assertEqual(n_docs, await self.db.test.count_documents({})) - await self.db.test.drop() + await self.db.coll.insert_many([{} for _ in range(n_docs)]) + self.assertEqual(n_docs, await self.db.coll.count_documents({})) + await self.db.coll.drop() async def test_insert_many_large_batch(self): # Tests legacy insert. @@ -2002,13 +2002,13 @@ async def test_messages_with_unicode_collection_names(self): await db["Employés"].find().to_list() async def test_drop_indexes_non_existent(self): - await self.db.drop_collection("test") - await self.db.test.drop_indexes() + await self.db.drop_collection("coll") + await self.db.coll.drop_indexes() # This is really a bson test but easier to just reproduce it here... # (Shame on me) async def test_bad_encode(self): - c = self.db.test + c = self.db.coll await c.drop() with self.assertRaises(InvalidDocument): await c.insert_one({"x": c}) @@ -2023,7 +2023,7 @@ def __getattr__(self, name): async def test_array_filters_validation(self): # array_filters must be a list. - c = self.db.test + c = self.db.coll with self.assertRaises(TypeError): await c.update_one({}, {"$set": {"a": 1}}, array_filters={}) # type: ignore[arg-type] with self.assertRaises(TypeError): @@ -2033,7 +2033,7 @@ async def test_array_filters_validation(self): await c.find_one_and_update({}, update, array_filters={}) # type: ignore[arg-type] async def test_array_filters_unacknowledged(self): - c_w0 = self.db.test.with_options(write_concern=WriteConcern(w=0)) + c_w0 = self.db.coll.with_options(write_concern=WriteConcern(w=0)) with self.assertRaises(ConfigurationError): await c_w0.update_one({}, {"$set": {"y.$[i].b": 5}}, array_filters=[{"i.b": 1}]) with self.assertRaises(ConfigurationError): @@ -2044,7 +2044,7 @@ async def test_array_filters_unacknowledged(self): ) async def test_find_one_and(self): - c = self.db.test + c = self.db.coll await c.drop() await c.insert_one({"_id": 1, "i": 1}) @@ -2102,9 +2102,9 @@ async def test_find_one_and_write_concern(self): listener = OvertCommandListener() db = (await self.async_single_client(event_listeners=[listener]))[self.db.name] # non-default WriteConcern. - c_w0 = db.get_collection("test", write_concern=WriteConcern(w=0)) + c_w0 = db.get_collection("coll", write_concern=WriteConcern(w=0)) # default WriteConcern. - c_default = db.get_collection("test", write_concern=WriteConcern()) + c_default = db.get_collection("coll", write_concern=WriteConcern()) # Authenticate the client and throw out auth commands from the listener. await db.command("ping") listener.reset() @@ -2123,7 +2123,7 @@ async def test_find_one_and_write_concern(self): # Test write concern errors. if async_client_context.is_rs: c_wc_error = db.get_collection( - "test", write_concern=WriteConcern(w=len(async_client_context.nodes) + 1) + "coll", write_concern=WriteConcern(w=len(async_client_context.nodes) + 1) ) with self.assertRaises(WriteConcernError): await c_wc_error.find_one_and_update({"_id": 1}, {"$set": {"foo": "bar"}}) @@ -2150,7 +2150,7 @@ async def test_find_one_and_write_concern(self): listener.reset() async def test_find_with_nested(self): - c = self.db.test + c = self.db.coll await c.drop() await c.insert_many([{"i": i} for i in range(5)]) # [0, 1, 2, 3, 4] self.assertEqual( @@ -2208,7 +2208,7 @@ async def test_find_with_nested(self): ) async def test_find_regex(self): - c = self.db.test + c = self.db.coll await c.drop() await c.insert_one({"r": re.compile(".*")}) @@ -2233,11 +2233,11 @@ def test_find_command_generation(self): def test_bool(self): with self.assertRaises(NotImplementedError): - bool(AsyncCollection(self.db, "test")) + bool(AsyncCollection(self.db, "coll")) @async_client_context.require_version_min(5, 0, 0) async def test_helpers_with_let(self): - c = self.db.test + c = self.db.coll async def afind(*args, **kwargs): return c.find(*args, **kwargs) diff --git a/test/asynchronous/test_comment.py b/test/asynchronous/test_comment.py index 2d6d0f5f1e..c160de2b10 100644 --- a/test/asynchronous/test_comment.py +++ b/test/asynchronous/test_comment.py @@ -92,7 +92,7 @@ async def test_database_helpers(self): (db.list_collections, []), (db.list_collection_names, []), (db.drop_collection, ["hello"]), - (db.validate_collection, ["test"]), + (db.validate_collection, ["coll"]), (db.dereference, [DBRef("collection", 1)]), ] already_supported = [db.command, db.list_collections, db.list_collection_names] @@ -107,7 +107,7 @@ async def test_client_helpers(self): (cli.watch, []), (cli.list_databases, []), (cli.list_database_names, []), - (cli.drop_database, ["test"]), + (cli.drop_database, ["db"]), ] already_supported = [ cli.list_databases, @@ -118,7 +118,7 @@ async def test_client_helpers(self): async def test_collection_helpers(self): listener = OvertCommandListener() db = (await self.async_rs_or_single_client(event_listeners=[listener]))[self.db.name] - coll = db.get_collection("test") + coll = db.get_collection("coll") helpers = [ (coll.list_indexes, []), diff --git a/test/asynchronous/test_common.py b/test/asynchronous/test_common.py index 00495e7c30..a3122be6ab 100644 --- a/test/asynchronous/test_common.py +++ b/test/asynchronous/test_common.py @@ -119,23 +119,23 @@ async def test_write_concern(self): self.assertEqual(wc, c.write_concern) # Can we override back to the server default? - db = c.get_database("pymongo_test", write_concern=WriteConcern()) + db = c.get_database("db", write_concern=WriteConcern()) self.assertEqual(db.write_concern, WriteConcern()) - db = c.pymongo_test + db = c.db self.assertEqual(wc, db.write_concern) - coll = db.test + coll = db.coll self.assertEqual(wc, coll.write_concern) cwc = WriteConcern(j=True) - coll = db.get_collection("test", write_concern=cwc) + coll = db.get_collection("coll", write_concern=cwc) self.assertEqual(cwc, coll.write_concern) self.assertEqual(wc, db.write_concern) async def test_mongo_client(self): pair = await async_client_context.pair m = await self.async_rs_or_single_client(w=0) - coll = m.pymongo_test.write_concern_test + coll = m.db.write_concern_test await coll.drop() doc = {"_id": ObjectId()} await coll.insert_one(doc) @@ -145,7 +145,7 @@ async def test_mongo_client(self): await coll.insert_one(doc) m = await self.async_rs_or_single_client() - coll = m.pymongo_test.write_concern_test + coll = m.db.write_concern_test new_coll = coll.with_options(write_concern=WriteConcern(w=0)) self.assertTrue(await new_coll.insert_one(doc)) with self.assertRaises(OperationFailure): @@ -155,14 +155,14 @@ async def test_mongo_client(self): f"mongodb://{pair}/", replicaSet=async_client_context.replica_set_name ) - coll = m.pymongo_test.write_concern_test + coll = m.db.write_concern_test with self.assertRaises(OperationFailure): await coll.insert_one(doc) m = await self.async_rs_or_single_client( f"mongodb://{pair}/?w=0", replicaSet=async_client_context.replica_set_name ) - coll = m.pymongo_test.write_concern_test + coll = m.db.write_concern_test await coll.insert_one(doc) # Equality tests @@ -174,11 +174,11 @@ async def test_mongo_client(self): self.assertFalse(direct != direct2) async def test_validate_boolean(self): - await self.db.test.update_one({}, {"$set": {"total": 1}}, upsert=True) + await self.db.coll.update_one({}, {"$set": {"total": 1}}, upsert=True) with self.assertRaisesRegex( TypeError, "upsert must be True or False, was: upsert={'upsert': True}" ): - await self.db.test.update_one({}, {"$set": {"total": 1}}, {"upsert": True}) # type: ignore + await self.db.coll.update_one({}, {"$set": {"total": 1}}, {"upsert": True}) # type: ignore if __name__ == "__main__": diff --git a/test/asynchronous/test_concurrency.py b/test/asynchronous/test_concurrency.py index c8093bb4bd..8b0559f20f 100644 --- a/test/asynchronous/test_concurrency.py +++ b/test/asynchronous/test_concurrency.py @@ -28,7 +28,7 @@ class TestAsyncConcurrency(AsyncIntegrationTest): async def _task(self, client): - await client.db.test.find_one({"$where": delay(0.20)}) + await client.db.coll.find_one({"$where": delay(0.20)}) @unittest.skipIf( sys.platform == "darwin" and "CI" in os.environ, @@ -39,8 +39,8 @@ async def test_concurrency(self): iterations = 5 client = await self.async_single_client() - await client.db.test.drop() - await client.db.test.insert_one({"x": 1}) + await client.db.coll.drop() + await client.db.coll.insert_one({"x": 1}) start = time.time() diff --git a/test/asynchronous/test_csot.py b/test/asynchronous/test_csot.py index 547ee20a54..07155d5c19 100644 --- a/test/asynchronous/test_csot.py +++ b/test/asynchronous/test_csot.py @@ -78,7 +78,7 @@ async def test_timeout_nested(self): @async_client_context.require_change_streams @flaky(reason="PYTHON-3522") async def test_change_stream_can_resume_after_timeouts(self): - coll = self.db.test + coll = self.db.coll await coll.insert_one({}) async with await coll.watch() as stream: with pymongo.timeout(0.1): diff --git a/test/asynchronous/test_cursor.py b/test/asynchronous/test_cursor.py index 3a959a52ae..cd20310f2b 100644 --- a/test/asynchronous/test_cursor.py +++ b/test/asynchronous/test_cursor.py @@ -60,7 +60,7 @@ class TestCursor(AsyncIntegrationTest): async def test_deepcopy_cursor_littered_with_regexes(self): - cursor = self.db.test.find( + cursor = self.db.coll.find( { "x": re.compile("^hmmm.*"), "y": [re.compile("^hmm.*")], @@ -73,18 +73,18 @@ async def test_deepcopy_cursor_littered_with_regexes(self): self.assertEqual(cursor._spec, cursor2._spec) async def test_add_remove_option(self): - cursor = self.db.test.find() + cursor = self.db.coll.find() self.assertEqual(0, cursor._query_flags) await cursor.add_option(2) - cursor2 = self.db.test.find(cursor_type=CursorType.TAILABLE) + cursor2 = self.db.coll.find(cursor_type=CursorType.TAILABLE) self.assertEqual(2, cursor2._query_flags) self.assertEqual(cursor._query_flags, cursor2._query_flags) await cursor.add_option(32) - cursor2 = self.db.test.find(cursor_type=CursorType.TAILABLE_AWAIT) + cursor2 = self.db.coll.find(cursor_type=CursorType.TAILABLE_AWAIT) self.assertEqual(34, cursor2._query_flags) self.assertEqual(cursor._query_flags, cursor2._query_flags) await cursor.add_option(128) - cursor2 = await self.db.test.find(cursor_type=CursorType.TAILABLE_AWAIT).add_option(128) + cursor2 = await self.db.coll.find(cursor_type=CursorType.TAILABLE_AWAIT).add_option(128) self.assertEqual(162, cursor2._query_flags) self.assertEqual(cursor._query_flags, cursor2._query_flags) @@ -93,11 +93,11 @@ async def test_add_remove_option(self): self.assertEqual(162, cursor._query_flags) cursor.remove_option(128) - cursor2 = self.db.test.find(cursor_type=CursorType.TAILABLE_AWAIT) + cursor2 = self.db.coll.find(cursor_type=CursorType.TAILABLE_AWAIT) self.assertEqual(34, cursor2._query_flags) self.assertEqual(cursor._query_flags, cursor2._query_flags) cursor.remove_option(32) - cursor2 = self.db.test.find(cursor_type=CursorType.TAILABLE) + cursor2 = self.db.coll.find(cursor_type=CursorType.TAILABLE) self.assertEqual(2, cursor2._query_flags) self.assertEqual(cursor._query_flags, cursor2._query_flags) @@ -106,25 +106,25 @@ async def test_add_remove_option(self): self.assertEqual(2, cursor._query_flags) # Timeout - cursor = self.db.test.find(no_cursor_timeout=True) + cursor = self.db.coll.find(no_cursor_timeout=True) self.assertEqual(16, cursor._query_flags) - cursor2 = await self.db.test.find().add_option(16) + cursor2 = await self.db.coll.find().add_option(16) self.assertEqual(cursor._query_flags, cursor2._query_flags) cursor.remove_option(16) self.assertEqual(0, cursor._query_flags) # Tailable / Await data - cursor = self.db.test.find(cursor_type=CursorType.TAILABLE_AWAIT) + cursor = self.db.coll.find(cursor_type=CursorType.TAILABLE_AWAIT) self.assertEqual(34, cursor._query_flags) - cursor2 = await self.db.test.find().add_option(34) + cursor2 = await self.db.coll.find().add_option(34) self.assertEqual(cursor._query_flags, cursor2._query_flags) cursor.remove_option(32) self.assertEqual(2, cursor._query_flags) # Partial - cursor = self.db.test.find(allow_partial_results=True) + cursor = self.db.coll.find(allow_partial_results=True) self.assertEqual(128, cursor._query_flags) - cursor2 = await self.db.test.find().add_option(128) + cursor2 = await self.db.coll.find().add_option(128) self.assertEqual(cursor._query_flags, cursor2._query_flags) cursor.remove_option(128) self.assertEqual(0, cursor._query_flags) @@ -133,11 +133,11 @@ async def test_add_remove_option_exhaust(self): # Exhaust - which mongos doesn't support if async_client_context.is_mongos: with self.assertRaises(InvalidOperation): - await anext(self.db.test.find(cursor_type=CursorType.EXHAUST)) + await anext(self.db.coll.find(cursor_type=CursorType.EXHAUST)) else: - cursor = self.db.test.find(cursor_type=CursorType.EXHAUST) + cursor = self.db.coll.find(cursor_type=CursorType.EXHAUST) self.assertEqual(64, cursor._query_flags) - cursor2 = await self.db.test.find().add_option(64) + cursor2 = await self.db.coll.find().add_option(64) self.assertEqual(cursor._query_flags, cursor2._query_flags) self.assertTrue(cursor._exhaust) cursor.remove_option(64) @@ -146,8 +146,8 @@ async def test_add_remove_option_exhaust(self): async def test_allow_disk_use(self): db = self.db - await db.pymongo_test.drop() - coll = db.pymongo_test + await db.coll.drop() + coll = db.coll with self.assertRaises(TypeError): coll.find().allow_disk_use("baz") # type: ignore[arg-type] @@ -159,8 +159,8 @@ async def test_allow_disk_use(self): async def test_max_time_ms(self): db = self.db - await db.pymongo_test.drop() - coll = db.pymongo_test + await db.coll.drop() + coll = db.coll with self.assertRaises(TypeError): coll.find().max_time_ms("foo") # type: ignore[arg-type] await coll.insert_one({"amalia": 1}) @@ -203,9 +203,9 @@ async def test_max_time_ms(self): async def test_maxtime_ms_message(self): db = self.db - await db.t.insert_one({"x": 1}) + await db.coll.insert_one({"x": 1}) with self.assertRaises(OperationFailure) as error: - await db.t.find_one({"$where": delay(2)}, max_time_ms=1) + await db.coll.find_one({"$where": delay(2)}, max_time_ms=1) # Newer MongoDB executes $where in WASM and returns Interrupted (11601) instead # of MaxTimeMSExpired (50) when max_time_ms kills execution; only MaxTimeMSExpired @@ -214,17 +214,17 @@ async def test_maxtime_ms_message(self): self.assertIn("(configured timeouts: connectTimeoutMS: 20000.0ms", str(error.exception)) client = await self.async_rs_client(document_class=RawBSONDocument) - await client.db.t.insert_one({"x": 1}) + await client.db.coll.insert_one({"x": 1}) with self.assertRaises(OperationFailure) as error: - await client.db.t.find_one({"$where": delay(2)}, max_time_ms=1) + await client.db.coll.find_one({"$where": delay(2)}, max_time_ms=1) if isinstance(error.exception, ExecutionTimeout): self.assertIn("(configured timeouts: connectTimeoutMS: 20000.0ms", str(error.exception)) async def test_max_await_time_ms(self): db = self.db - await db.pymongo_test.drop() - coll = await db.create_collection("pymongo_test", capped=True, size=4096) + await db.coll.drop() + coll = await db.create_collection("db", capped=True, size=4096) with self.assertRaises(TypeError): coll.find().max_await_time_ms("foo") # type: ignore[arg-type] @@ -256,9 +256,7 @@ async def test_max_await_time_ms(self): self.assertEqual(90, cursor._max_await_time_ms) listener = AllowListEventListener("find", "getMore") - coll = (await self.async_rs_or_single_client(event_listeners=[listener]))[ - self.db.name - ].pymongo_test + coll = (await self.async_rs_or_single_client(event_listeners=[listener]))[self.db.name].coll # Tailable_await defaults. await coll.find(cursor_type=CursorType.TAILABLE_AWAIT).to_list() @@ -344,7 +342,7 @@ async def test_max_await_time_ms(self): @async_client_context.require_no_mongos async def test_max_time_ms_getmore(self): # Test that Cursor handles server timeout error in response to getmore. - coll = self.db.pymongo_test + coll = self.db.coll await coll.insert_many([{} for _ in range(200)]) cursor = coll.find().max_time_ms(100) @@ -367,7 +365,7 @@ async def test_max_time_ms_getmore(self): ) async def test_explain(self): - a = self.db.test.find() + a = self.db.coll.find() await a.explain() async for _ in a: break @@ -378,7 +376,7 @@ async def test_explain_with_read_concern(self): # Do not add readConcern level to explain. listener = AllowListEventListener("explain") client = await self.async_rs_or_single_client(event_listeners=[listener]) - coll = client.pymongo_test.test.with_options(read_concern=ReadConcern(level="local")) + coll = client.db.coll.with_options(read_concern=ReadConcern(level="local")) self.assertTrue(await coll.find().explain()) started = listener.started_events self.assertEqual(len(started), 1) @@ -410,104 +408,104 @@ async def test_explain_csot(self): async def test_hint(self): db = self.db with self.assertRaises(TypeError): - db.test.find().hint(5.5) # type: ignore[arg-type] - await db.test.drop() + db.coll.find().hint(5.5) # type: ignore[arg-type] + await db.coll.drop() - await db.test.insert_many([{"num": i, "foo": i} for i in range(100)]) + await db.coll.insert_many([{"num": i, "foo": i} for i in range(100)]) with self.assertRaises(OperationFailure): - await db.test.find({"num": 17, "foo": 17}).hint([("num", ASCENDING)]).explain() + await db.coll.find({"num": 17, "foo": 17}).hint([("num", ASCENDING)]).explain() with self.assertRaises(OperationFailure): - await db.test.find({"num": 17, "foo": 17}).hint([("foo", ASCENDING)]).explain() + await db.coll.find({"num": 17, "foo": 17}).hint([("foo", ASCENDING)]).explain() spec: list[Any] = [("num", DESCENDING)] - _ = await db.test.create_index(spec) + _ = await db.coll.create_index(spec) - first = await anext(db.test.find()) + first = await anext(db.coll.find()) self.assertEqual(0, first.get("num")) - first = await anext(db.test.find().hint(spec)) + first = await anext(db.coll.find().hint(spec)) self.assertEqual(99, first.get("num")) with self.assertRaises(OperationFailure): - await db.test.find({"num": 17, "foo": 17}).hint([("foo", ASCENDING)]).explain() + await db.coll.find({"num": 17, "foo": 17}).hint([("foo", ASCENDING)]).explain() - a = db.test.find({"num": 17}) + a = db.coll.find({"num": 17}) a.hint(spec) async for _ in a: break self.assertRaises(InvalidOperation, a.hint, spec) - await db.test.drop() - await db.test.insert_many([{"num": i, "foo": i} for i in range(100)]) + await db.coll.drop() + await db.coll.insert_many([{"num": i, "foo": i} for i in range(100)]) spec: _IndexList = ["num", ("foo", DESCENDING)] - await db.test.create_index(spec) - first = await anext(db.test.find().hint(spec)) + await db.coll.create_index(spec) + first = await anext(db.coll.find().hint(spec)) self.assertEqual(0, first.get("num")) self.assertEqual(0, first.get("foo")) - await db.test.drop() - await db.test.insert_many([{"num": i, "foo": i} for i in range(100)]) + await db.coll.drop() + await db.coll.insert_many([{"num": i, "foo": i} for i in range(100)]) spec = ["num"] - await db.test.create_index(spec) - first = await anext(db.test.find().hint(spec)) + await db.coll.create_index(spec) + first = await anext(db.coll.find().hint(spec)) self.assertEqual(0, first.get("num")) async def test_hint_by_name(self): db = self.db - await db.test.drop() + await db.coll.drop() - await db.test.insert_many([{"i": i} for i in range(100)]) + await db.coll.insert_many([{"i": i} for i in range(100)]) - await db.test.create_index([("i", DESCENDING)], name="fooindex") - first = await anext(db.test.find()) + await db.coll.create_index([("i", DESCENDING)], name="fooindex") + first = await anext(db.coll.find()) self.assertEqual(0, first.get("i")) - first = await anext(db.test.find().hint("fooindex")) + first = await anext(db.coll.find().hint("fooindex")) self.assertEqual(99, first.get("i")) async def test_limit(self): db = self.db with self.assertRaises(TypeError): - db.test.find().limit(None) # type: ignore[arg-type] + db.coll.find().limit(None) # type: ignore[arg-type] with self.assertRaises(TypeError): - db.test.find().limit("hello") # type: ignore[arg-type] + db.coll.find().limit("hello") # type: ignore[arg-type] with self.assertRaises(TypeError): - db.test.find().limit(5.5) # type: ignore[arg-type] - self.assertTrue((db.test.find()).limit(5)) + db.coll.find().limit(5.5) # type: ignore[arg-type] + self.assertTrue((db.coll.find()).limit(5)) - await db.test.drop() - await db.test.insert_many([{"x": i} for i in range(100)]) + await db.coll.drop() + await db.coll.insert_many([{"x": i} for i in range(100)]) count = 0 - async for _ in db.test.find(): + async for _ in db.coll.find(): count += 1 self.assertEqual(count, 100) count = 0 - async for _ in db.test.find().limit(20): + async for _ in db.coll.find().limit(20): count += 1 self.assertEqual(count, 20) count = 0 - async for _ in db.test.find().limit(99): + async for _ in db.coll.find().limit(99): count += 1 self.assertEqual(count, 99) count = 0 - async for _ in db.test.find().limit(1): + async for _ in db.coll.find().limit(1): count += 1 self.assertEqual(count, 1) count = 0 - async for _ in db.test.find().limit(0): + async for _ in db.coll.find().limit(0): count += 1 self.assertEqual(count, 100) count = 0 - async for _ in db.test.find().limit(0).limit(50).limit(10): + async for _ in db.coll.find().limit(0).limit(50).limit(10): count += 1 self.assertEqual(count, 10) - a = db.test.find() + a = db.coll.find() a.limit(10) async for _ in a: break @@ -516,14 +514,14 @@ async def test_limit(self): async def test_max(self): db = self.db - await db.test.drop() + await db.coll.drop() j_index = [("j", ASCENDING)] - await db.test.create_index(j_index) + await db.coll.create_index(j_index) - await db.test.insert_many([{"j": j, "k": j} for j in range(10)]) + await db.coll.insert_many([{"j": j, "k": j} for j in range(10)]) def find(max_spec, expected_index): - return db.test.find().max(max_spec).hint(expected_index) + return db.coll.find().max(max_spec).hint(expected_index) cursor = find([("j", 3)], j_index) self.assertEqual(len(await cursor.to_list()), 3) @@ -534,7 +532,7 @@ def find(max_spec, expected_index): # Compound index. index_keys = [("j", ASCENDING), ("k", ASCENDING)] - await db.test.create_index(index_keys) + await db.coll.create_index(index_keys) cursor = find([("j", 3), ("k", 3)], index_keys) self.assertEqual(len(await cursor.to_list()), 3) @@ -548,20 +546,20 @@ def find(max_spec, expected_index): with self.assertRaises(OperationFailure): await cursor.to_list() with self.assertRaises(TypeError): - db.test.find().max(10) # type: ignore[arg-type] + db.coll.find().max(10) # type: ignore[arg-type] with self.assertRaises(TypeError): - db.test.find().max({"j": 10}) # type: ignore[arg-type] + db.coll.find().max({"j": 10}) # type: ignore[arg-type] async def test_min(self): db = self.db - await db.test.drop() + await db.coll.drop() j_index = [("j", ASCENDING)] - await db.test.create_index(j_index) + await db.coll.create_index(j_index) - await db.test.insert_many([{"j": j, "k": j} for j in range(10)]) + await db.coll.insert_many([{"j": j, "k": j} for j in range(10)]) def find(min_spec, expected_index): - return db.test.find().min(min_spec).hint(expected_index) + return db.coll.find().min(min_spec).hint(expected_index) cursor = find([("j", 3)], j_index) self.assertEqual(len(await cursor.to_list()), 7) @@ -572,7 +570,7 @@ def find(min_spec, expected_index): # Compound index. index_keys = [("j", ASCENDING), ("k", ASCENDING)] - await db.test.create_index(index_keys) + await db.coll.create_index(index_keys) cursor = find([("j", 3), ("k", 3)], index_keys) self.assertEqual(len(await cursor.to_list()), 7) @@ -587,12 +585,12 @@ def find(min_spec, expected_index): await cursor.to_list() with self.assertRaises(TypeError): - db.test.find().min(10) # type: ignore[arg-type] + db.coll.find().min(10) # type: ignore[arg-type] with self.assertRaises(TypeError): - db.test.find().min({"j": 10}) # type: ignore[arg-type] + db.coll.find().min({"j": 10}) # type: ignore[arg-type] async def test_min_max_without_hint(self): - coll = self.db.test + coll = self.db.coll j_index = [("j", ASCENDING)] await coll.create_index(j_index) @@ -603,19 +601,19 @@ async def test_min_max_without_hint(self): async def test_batch_size(self): db = self.db - await db.test.drop() - await db.test.insert_many([{"x": x} for x in range(200)]) + await db.coll.drop() + await db.coll.insert_many([{"x": x} for x in range(200)]) with self.assertRaises(TypeError): - db.test.find().batch_size(None) # type: ignore[arg-type] + db.coll.find().batch_size(None) # type: ignore[arg-type] with self.assertRaises(TypeError): - db.test.find().batch_size("hello") # type: ignore[arg-type] + db.coll.find().batch_size("hello") # type: ignore[arg-type] with self.assertRaises(TypeError): - db.test.find().batch_size(5.5) # type: ignore[arg-type] + db.coll.find().batch_size(5.5) # type: ignore[arg-type] with self.assertRaises(ValueError): - db.test.find().batch_size(-1) - self.assertTrue((db.test.find()).batch_size(5)) - a = db.test.find() + db.coll.find().batch_size(-1) + self.assertTrue((db.coll.find()).batch_size(5)) + a = db.coll.find() async for _ in a: break self.assertRaises(InvalidOperation, a.batch_size, 5) @@ -626,28 +624,28 @@ async def cursor_count(cursor, expected_count): count += 1 self.assertEqual(expected_count, count) - await cursor_count((db.test.find()).batch_size(0), 200) - await cursor_count((db.test.find()).batch_size(1), 200) - await cursor_count((db.test.find()).batch_size(2), 200) - await cursor_count((db.test.find()).batch_size(5), 200) - await cursor_count((db.test.find()).batch_size(100), 200) - await cursor_count((db.test.find()).batch_size(500), 200) - - await cursor_count((db.test.find()).batch_size(0).limit(1), 1) - await cursor_count((db.test.find()).batch_size(1).limit(1), 1) - await cursor_count((db.test.find()).batch_size(2).limit(1), 1) - await cursor_count((db.test.find()).batch_size(5).limit(1), 1) - await cursor_count((db.test.find()).batch_size(100).limit(1), 1) - await cursor_count((db.test.find()).batch_size(500).limit(1), 1) - - await cursor_count((db.test.find()).batch_size(0).limit(10), 10) - await cursor_count((db.test.find()).batch_size(1).limit(10), 10) - await cursor_count((db.test.find()).batch_size(2).limit(10), 10) - await cursor_count((db.test.find()).batch_size(5).limit(10), 10) - await cursor_count((db.test.find()).batch_size(100).limit(10), 10) - await cursor_count((db.test.find()).batch_size(500).limit(10), 10) - - cur = db.test.find().batch_size(1) + await cursor_count((db.coll.find()).batch_size(0), 200) + await cursor_count((db.coll.find()).batch_size(1), 200) + await cursor_count((db.coll.find()).batch_size(2), 200) + await cursor_count((db.coll.find()).batch_size(5), 200) + await cursor_count((db.coll.find()).batch_size(100), 200) + await cursor_count((db.coll.find()).batch_size(500), 200) + + await cursor_count((db.coll.find()).batch_size(0).limit(1), 1) + await cursor_count((db.coll.find()).batch_size(1).limit(1), 1) + await cursor_count((db.coll.find()).batch_size(2).limit(1), 1) + await cursor_count((db.coll.find()).batch_size(5).limit(1), 1) + await cursor_count((db.coll.find()).batch_size(100).limit(1), 1) + await cursor_count((db.coll.find()).batch_size(500).limit(1), 1) + + await cursor_count((db.coll.find()).batch_size(0).limit(10), 10) + await cursor_count((db.coll.find()).batch_size(1).limit(10), 10) + await cursor_count((db.coll.find()).batch_size(2).limit(10), 10) + await cursor_count((db.coll.find()).batch_size(5).limit(10), 10) + await cursor_count((db.coll.find()).batch_size(100).limit(10), 10) + await cursor_count((db.coll.find()).batch_size(500).limit(10), 10) + + cur = db.coll.find().batch_size(1) await anext(cur) # find command batchSize should be 1 self.assertEqual(0, len(cur._data)) @@ -660,54 +658,54 @@ async def cursor_count(cursor, expected_count): async def test_limit_and_batch_size(self): db = self.db - await db.test.drop() - await db.test.insert_many([{"x": x} for x in range(500)]) + await db.coll.drop() + await db.coll.insert_many([{"x": x} for x in range(500)]) - curs = db.test.find().limit(0).batch_size(10) + curs = db.coll.find().limit(0).batch_size(10) await anext(curs) self.assertEqual(10, curs._retrieved) - curs = db.test.find(limit=0, batch_size=10) + curs = db.coll.find(limit=0, batch_size=10) await anext(curs) self.assertEqual(10, curs._retrieved) - curs = db.test.find().limit(-2).batch_size(0) + curs = db.coll.find().limit(-2).batch_size(0) await anext(curs) self.assertEqual(2, curs._retrieved) - curs = db.test.find(limit=-2, batch_size=0) + curs = db.coll.find(limit=-2, batch_size=0) await anext(curs) self.assertEqual(2, curs._retrieved) - curs = db.test.find().limit(-4).batch_size(5) + curs = db.coll.find().limit(-4).batch_size(5) await anext(curs) self.assertEqual(4, curs._retrieved) - curs = db.test.find(limit=-4, batch_size=5) + curs = db.coll.find(limit=-4, batch_size=5) await anext(curs) self.assertEqual(4, curs._retrieved) - curs = db.test.find().limit(50).batch_size(500) + curs = db.coll.find().limit(50).batch_size(500) await anext(curs) self.assertEqual(50, curs._retrieved) - curs = db.test.find(limit=50, batch_size=500) + curs = db.coll.find(limit=50, batch_size=500) await anext(curs) self.assertEqual(50, curs._retrieved) - curs = db.test.find().batch_size(500) + curs = db.coll.find().batch_size(500) await anext(curs) self.assertEqual(500, curs._retrieved) - curs = db.test.find(batch_size=500) + curs = db.coll.find(batch_size=500) await anext(curs) self.assertEqual(500, curs._retrieved) - curs = db.test.find().limit(50) + curs = db.coll.find().limit(50) await anext(curs) self.assertEqual(50, curs._retrieved) - curs = db.test.find(limit=50) + curs = db.coll.find(limit=50) await anext(curs) self.assertEqual(50, curs._retrieved) @@ -715,15 +713,15 @@ async def test_limit_and_batch_size(self): # is set by the server. as of 2.0.0-rc0, 101 # or 1MB (whichever is smaller) is default # for queries without ntoreturn - curs = db.test.find() + curs = db.coll.find() await anext(curs) self.assertEqual(101, curs._retrieved) - curs = db.test.find().limit(0).batch_size(0) + curs = db.coll.find().limit(0).batch_size(0) await anext(curs) self.assertEqual(101, curs._retrieved) - curs = db.test.find(limit=0, batch_size=0) + curs = db.coll.find(limit=0, batch_size=0) await anext(curs) self.assertEqual(101, curs._retrieved) @@ -731,47 +729,47 @@ async def test_skip(self): db = self.db with self.assertRaises(TypeError): - db.test.find().skip(None) # type: ignore[arg-type] + db.coll.find().skip(None) # type: ignore[arg-type] with self.assertRaises(TypeError): - db.test.find().skip("hello") # type: ignore[arg-type] + db.coll.find().skip("hello") # type: ignore[arg-type] with self.assertRaises(TypeError): - db.test.find().skip(5.5) # type: ignore[arg-type] + db.coll.find().skip(5.5) # type: ignore[arg-type] with self.assertRaises(ValueError): - db.test.find().skip(-5) - self.assertTrue((db.test.find()).skip(5)) + db.coll.find().skip(-5) + self.assertTrue((db.coll.find()).skip(5)) - await db.drop_collection("test") + await db.drop_collection("coll") - await db.test.insert_many([{"x": i} for i in range(100)]) + await db.coll.insert_many([{"x": i} for i in range(100)]) - async for i in db.test.find(): + async for i in db.coll.find(): self.assertEqual(i["x"], 0) break - async for i in db.test.find().skip(20): + async for i in db.coll.find().skip(20): self.assertEqual(i["x"], 20) break - async for i in db.test.find().skip(99): + async for i in db.coll.find().skip(99): self.assertEqual(i["x"], 99) break - async for i in db.test.find().skip(1): + async for i in db.coll.find().skip(1): self.assertEqual(i["x"], 1) break - async for i in db.test.find().skip(0): + async for i in db.coll.find().skip(0): self.assertEqual(i["x"], 0) break - async for i in db.test.find().skip(0).skip(50).skip(10): + async for i in db.coll.find().skip(0).skip(50).skip(10): self.assertEqual(i["x"], 10) break - async for _ in db.test.find().skip(1000): + async for _ in db.coll.find().skip(1000): self.fail() - a = db.test.find() + a = db.coll.find() a.skip(10) async for _ in a: break @@ -781,53 +779,53 @@ async def test_sort(self): db = self.db with self.assertRaises(TypeError): - db.test.find().sort(5) # type: ignore[arg-type] + db.coll.find().sort(5) # type: ignore[arg-type] with self.assertRaises(ValueError): - db.test.find().sort([]) # type: ignore[arg-type] + db.coll.find().sort([]) # type: ignore[arg-type] with self.assertRaises(TypeError): - db.test.find().sort([], ASCENDING) # type: ignore[arg-type] + db.coll.find().sort([], ASCENDING) # type: ignore[arg-type] with self.assertRaises(TypeError): - db.test.find().sort([("hello", DESCENDING)], DESCENDING) # type: ignore[arg-type] + db.coll.find().sort([("hello", DESCENDING)], DESCENDING) # type: ignore[arg-type] - await db.test.drop() + await db.coll.drop() unsort = list(range(10)) random.shuffle(unsort) - await db.test.insert_many([{"x": i} for i in unsort]) + await db.coll.insert_many([{"x": i} for i in unsort]) - asc = [i["x"] async for i in db.test.find().sort("x", ASCENDING)] + asc = [i["x"] async for i in db.coll.find().sort("x", ASCENDING)] self.assertEqual(asc, list(range(10))) - asc = [i["x"] async for i in db.test.find().sort("x")] + asc = [i["x"] async for i in db.coll.find().sort("x")] self.assertEqual(asc, list(range(10))) - asc = [i["x"] async for i in db.test.find().sort([("x", ASCENDING)])] + asc = [i["x"] async for i in db.coll.find().sort([("x", ASCENDING)])] self.assertEqual(asc, list(range(10))) expect = list(reversed(range(10))) - desc = [i["x"] async for i in db.test.find().sort("x", DESCENDING)] + desc = [i["x"] async for i in db.coll.find().sort("x", DESCENDING)] self.assertEqual(desc, expect) - desc = [i["x"] async for i in db.test.find().sort([("x", DESCENDING)])] + desc = [i["x"] async for i in db.coll.find().sort([("x", DESCENDING)])] self.assertEqual(desc, expect) - desc = [i["x"] async for i in db.test.find().sort("x", ASCENDING).sort("x", DESCENDING)] + desc = [i["x"] async for i in db.coll.find().sort("x", ASCENDING).sort("x", DESCENDING)] self.assertEqual(desc, expect) expected = [(1, 5), (2, 5), (0, 3), (7, 3), (9, 2), (2, 1), (3, 1)] shuffled = list(expected) random.shuffle(shuffled) - await db.test.drop() + await db.coll.drop() for a, b in shuffled: - await db.test.insert_one({"a": a, "b": b}) + await db.coll.insert_one({"a": a, "b": b}) result = [ (i["a"], i["b"]) - async for i in db.test.find().sort([("b", DESCENDING), ("a", ASCENDING)]) + async for i in db.coll.find().sort([("b", DESCENDING), ("a", ASCENDING)]) ] self.assertEqual(result, expected) - result = [(i["a"], i["b"]) async for i in db.test.find().sort([("b", DESCENDING), "a"])] + result = [(i["a"], i["b"]) async for i in db.coll.find().sort([("b", DESCENDING), "a"])] self.assertEqual(result, expected) - a = db.test.find() + a = db.coll.find() a.sort("x", ASCENDING) async for _ in a: break @@ -839,9 +837,9 @@ async def test_sort(self): ) async def test_where(self): db = self.db - await db.test.drop() + await db.coll.drop() - a = db.test.find() + a = db.coll.find() with self.assertRaises(TypeError): a.where(5) # type: ignore[arg-type] with self.assertRaises(TypeError): @@ -849,41 +847,41 @@ async def test_where(self): with self.assertRaises(TypeError): a.where({}) # type: ignore[arg-type] - await db.test.insert_many([{"x": i} for i in range(10)]) + await db.coll.insert_many([{"x": i} for i in range(10)]) - self.assertEqual(3, len(await db.test.find().where("this.x < 3").to_list())) - self.assertEqual(3, len(await db.test.find().where(Code("this.x < 3")).to_list())) + self.assertEqual(3, len(await db.coll.find().where("this.x < 3").to_list())) + self.assertEqual(3, len(await db.coll.find().where(Code("this.x < 3")).to_list())) code_with_scope = Code("this.x < i", {"i": 3}) if async_client_context.version.at_least(4, 3, 3): # MongoDB 4.4 removed support for Code with scope. with self.assertRaises(OperationFailure): - await db.test.find().where(code_with_scope).to_list() + await db.coll.find().where(code_with_scope).to_list() code_with_empty_scope = Code("this.x < 3", {}) with self.assertRaises(OperationFailure): - await db.test.find().where(code_with_empty_scope).to_list() + await db.coll.find().where(code_with_empty_scope).to_list() else: - self.assertEqual(3, len(await db.test.find().where(code_with_scope).to_list())) + self.assertEqual(3, len(await db.coll.find().where(code_with_scope).to_list())) - self.assertEqual(10, len(await db.test.find().to_list())) - self.assertEqual([0, 1, 2], [a["x"] async for a in db.test.find().where("this.x < 3")]) - self.assertEqual([], [a["x"] async for a in db.test.find({"x": 5}).where("this.x < 3")]) - self.assertEqual([5], [a["x"] async for a in db.test.find({"x": 5}).where("this.x > 3")]) + self.assertEqual(10, len(await db.coll.find().to_list())) + self.assertEqual([0, 1, 2], [a["x"] async for a in db.coll.find().where("this.x < 3")]) + self.assertEqual([], [a["x"] async for a in db.coll.find({"x": 5}).where("this.x < 3")]) + self.assertEqual([5], [a["x"] async for a in db.coll.find({"x": 5}).where("this.x > 3")]) - cursor = db.test.find().where("this.x < 3").where("this.x > 7") + cursor = db.coll.find().where("this.x < 3").where("this.x > 7") self.assertEqual([8, 9], [a["x"] async for a in cursor]) - a = db.test.find() + a = db.coll.find() _ = a.where("this.x > 3") async for _ in a: break self.assertRaises(InvalidOperation, a.where, "this.x < 3") async def test_rewind(self): - await self.db.test.insert_many([{"x": i} for i in range(1, 4)]) + await self.db.coll.insert_many([{"x": i} for i in range(1, 4)]) - cursor = self.db.test.find().limit(2) + cursor = self.db.coll.find().limit(2) count = 0 async for _ in cursor: @@ -915,9 +913,9 @@ async def test_rewind(self): # oplog_reply, and snapshot are all deprecated. @ignore_deprecations async def test_clone(self): - await self.db.test.insert_many([{"x": i} for i in range(1, 4)]) + await self.db.coll.insert_many([{"x": i} for i in range(1, 4)]) - cursor = self.db.test.find().limit(2) + cursor = self.db.coll.find().limit(2) count = 0 async for _ in cursor: @@ -952,7 +950,7 @@ async def test_clone(self): # Just test attributes cursor = ( - self.db.test.find( + self.db.coll.find( {"x": re.compile("^hello.*")}, projection={"_id": False}, skip=1, @@ -1000,7 +998,7 @@ async def test_clone(self): # Test memo when deepcopying queries query = {"hello": "world"} query["reflexive"] = query - cursor = self.db.test.find(query) + cursor = self.db.coll.find(query) cursor2 = copy.deepcopy(cursor) @@ -1009,7 +1007,7 @@ async def test_clone(self): self.assertEqual(len(cursor2._spec), 2) # Ensure hints are cloned as the correct type - cursor = self.db.test.find().hint([("z", 1), ("a", 1)]) + cursor = self.db.coll.find().hint([("z", 1), ("a", 1)]) cursor2 = copy.deepcopy(cursor) # Internal types are now dict rather than SON by default self.assertIsInstance(cursor2._hint, dict) @@ -1017,9 +1015,9 @@ async def test_clone(self): @async_client_context.require_sync def test_clone_empty(self): - self.db.test.delete_many({}) - self.db.test.insert_many([{"x": i} for i in range(1, 4)]) - cursor = self.db.test.find()[2:2] + self.db.coll.delete_many({}) + self.db.coll.insert_many([{"x": i} for i in range(1, 4)]) + cursor = self.db.coll.find()[2:2] cursor2 = cursor.clone() self.assertRaises(StopIteration, cursor.next) self.assertRaises(StopIteration, cursor2.next) @@ -1027,130 +1025,130 @@ def test_clone_empty(self): # AsyncCursors don't support slicing @async_client_context.require_sync def test_bad_getitem(self): - self.assertRaises(TypeError, lambda x: self.db.test.find()[x], "hello") - self.assertRaises(TypeError, lambda x: self.db.test.find()[x], 5.5) - self.assertRaises(TypeError, lambda x: self.db.test.find()[x], None) + self.assertRaises(TypeError, lambda x: self.db.coll.find()[x], "hello") + self.assertRaises(TypeError, lambda x: self.db.coll.find()[x], 5.5) + self.assertRaises(TypeError, lambda x: self.db.coll.find()[x], None) # AsyncCursors don't support slicing @async_client_context.require_sync def test_getitem_slice_index(self): - self.db.drop_collection("test") - self.db.test.insert_many([{"i": i} for i in range(100)]) + self.db.drop_collection("coll") + self.db.coll.insert_many([{"i": i} for i in range(100)]) count = itertools.count - self.assertRaises(IndexError, lambda: self.db.test.find()[-1:]) - self.assertRaises(IndexError, lambda: self.db.test.find()[1:2:2]) + self.assertRaises(IndexError, lambda: self.db.coll.find()[-1:]) + self.assertRaises(IndexError, lambda: self.db.coll.find()[1:2:2]) - for a, b in zip(count(0), self.db.test.find()): # type: ignore[call-overload] + for a, b in zip(count(0), self.db.coll.find()): # type: ignore[call-overload] self.assertEqual(a, b["i"]) - self.assertEqual(100, len(list(self.db.test.find()[0:]))) # type: ignore[call-overload] - for a, b in zip(count(0), self.db.test.find()[0:]): # type: ignore[call-overload] + self.assertEqual(100, len(list(self.db.coll.find()[0:]))) # type: ignore[call-overload] + for a, b in zip(count(0), self.db.coll.find()[0:]): # type: ignore[call-overload] self.assertEqual(a, b["i"]) - self.assertEqual(80, len(list(self.db.test.find()[20:]))) # type: ignore[call-overload] - for a, b in zip(count(20), self.db.test.find()[20:]): # type: ignore[call-overload] + self.assertEqual(80, len(list(self.db.coll.find()[20:]))) # type: ignore[call-overload] + for a, b in zip(count(20), self.db.coll.find()[20:]): # type: ignore[call-overload] self.assertEqual(a, b["i"]) - for a, b in zip(count(99), self.db.test.find()[99:]): # type: ignore[call-overload] + for a, b in zip(count(99), self.db.coll.find()[99:]): # type: ignore[call-overload] self.assertEqual(a, b["i"]) - for _i in self.db.test.find()[1000:]: + for _i in self.db.coll.find()[1000:]: self.fail() - self.assertEqual(5, len(list(self.db.test.find()[20:25]))) # type: ignore[call-overload] - self.assertEqual(5, len(list(self.db.test.find()[20:25]))) # type: ignore[call-overload] - for a, b in zip(count(20), self.db.test.find()[20:25]): # type: ignore[call-overload] + self.assertEqual(5, len(list(self.db.coll.find()[20:25]))) # type: ignore[call-overload] + self.assertEqual(5, len(list(self.db.coll.find()[20:25]))) # type: ignore[call-overload] + for a, b in zip(count(20), self.db.coll.find()[20:25]): # type: ignore[call-overload] self.assertEqual(a, b["i"]) - self.assertEqual(80, len(list(self.db.test.find()[40:45][20:]))) # type: ignore[call-overload] - for a, b in zip(count(20), self.db.test.find()[40:45][20:]): # type: ignore[call-overload] + self.assertEqual(80, len(list(self.db.coll.find()[40:45][20:]))) # type: ignore[call-overload] + for a, b in zip(count(20), self.db.coll.find()[40:45][20:]): # type: ignore[call-overload] self.assertEqual(a, b["i"]) - self.assertEqual(80, len(list(self.db.test.find()[40:45].limit(0).skip(20)))) # type: ignore[call-overload] - for a, b in zip(count(20), self.db.test.find()[40:45].limit(0).skip(20)): # type: ignore[call-overload] + self.assertEqual(80, len(list(self.db.coll.find()[40:45].limit(0).skip(20)))) # type: ignore[call-overload] + for a, b in zip(count(20), self.db.coll.find()[40:45].limit(0).skip(20)): # type: ignore[call-overload] self.assertEqual(a, b["i"]) - self.assertEqual(80, len(list(self.db.test.find().limit(10).skip(40)[20:]))) # type: ignore[call-overload] - for a, b in zip(count(20), self.db.test.find().limit(10).skip(40)[20:]): # type: ignore[call-overload] + self.assertEqual(80, len(list(self.db.coll.find().limit(10).skip(40)[20:]))) # type: ignore[call-overload] + for a, b in zip(count(20), self.db.coll.find().limit(10).skip(40)[20:]): # type: ignore[call-overload] self.assertEqual(a, b["i"]) - self.assertEqual(1, len(list(self.db.test.find()[:1]))) # type: ignore[call-overload] - self.assertEqual(5, len(list(self.db.test.find()[:5]))) # type: ignore[call-overload] + self.assertEqual(1, len(list(self.db.coll.find()[:1]))) # type: ignore[call-overload] + self.assertEqual(5, len(list(self.db.coll.find()[:5]))) # type: ignore[call-overload] - self.assertEqual(1, len(list(self.db.test.find()[99:100]))) # type: ignore[call-overload] - self.assertEqual(1, len(list(self.db.test.find()[99:1000]))) # type: ignore[call-overload] - self.assertEqual(0, len(list(self.db.test.find()[10:10]))) # type: ignore[call-overload] - self.assertEqual(0, len(list(self.db.test.find()[:0]))) # type: ignore[call-overload] - self.assertEqual(80, len(list(self.db.test.find()[10:10].limit(0).skip(20)))) # type: ignore[call-overload] + self.assertEqual(1, len(list(self.db.coll.find()[99:100]))) # type: ignore[call-overload] + self.assertEqual(1, len(list(self.db.coll.find()[99:1000]))) # type: ignore[call-overload] + self.assertEqual(0, len(list(self.db.coll.find()[10:10]))) # type: ignore[call-overload] + self.assertEqual(0, len(list(self.db.coll.find()[:0]))) # type: ignore[call-overload] + self.assertEqual(80, len(list(self.db.coll.find()[10:10].limit(0).skip(20)))) # type: ignore[call-overload] - self.assertRaises(IndexError, lambda: self.db.test.find()[10:8]) + self.assertRaises(IndexError, lambda: self.db.coll.find()[10:8]) # AsyncCursors don't support slicing @async_client_context.require_sync def test_getitem_numeric_index(self): - self.db.drop_collection("test") - self.db.test.insert_many([{"i": i} for i in range(100)]) + self.db.drop_collection("coll") + self.db.coll.insert_many([{"i": i} for i in range(100)]) - self.assertEqual(0, self.db.test.find()[0]["i"]) - self.assertEqual(50, self.db.test.find()[50]["i"]) - self.assertEqual(50, self.db.test.find().skip(50)[0]["i"]) - self.assertEqual(50, self.db.test.find().skip(49)[1]["i"]) - self.assertEqual(50, self.db.test.find()[50]["i"]) - self.assertEqual(99, self.db.test.find()[99]["i"]) + self.assertEqual(0, self.db.coll.find()[0]["i"]) + self.assertEqual(50, self.db.coll.find()[50]["i"]) + self.assertEqual(50, self.db.coll.find().skip(50)[0]["i"]) + self.assertEqual(50, self.db.coll.find().skip(49)[1]["i"]) + self.assertEqual(50, self.db.coll.find()[50]["i"]) + self.assertEqual(99, self.db.coll.find()[99]["i"]) - self.assertRaises(IndexError, lambda x: self.db.test.find()[x], -1) - self.assertRaises(IndexError, lambda x: self.db.test.find()[x], 100) - self.assertRaises(IndexError, lambda x: self.db.test.find().skip(50)[x], 50) + self.assertRaises(IndexError, lambda x: self.db.coll.find()[x], -1) + self.assertRaises(IndexError, lambda x: self.db.coll.find()[x], 100) + self.assertRaises(IndexError, lambda x: self.db.coll.find().skip(50)[x], 50) @async_client_context.require_sync def test_iteration_with_list(self): - self.db.drop_collection("test") - self.db.test.insert_many([{"i": i} for i in range(100)]) + self.db.drop_collection("coll") + self.db.coll.insert_many([{"i": i} for i in range(100)]) - cur = self.db.test.find().batch_size(10) + cur = self.db.coll.find().batch_size(10) self.assertEqual(100, len(list(cur))) # type: ignore[call-overload] def test_len(self): with self.assertRaises(TypeError): - len(self.db.test.find()) # type: ignore[arg-type] + len(self.db.coll.find()) # type: ignore[arg-type] def test_properties(self): - self.assertEqual(self.db.test, self.db.test.find().collection) + self.assertEqual(self.db.coll, self.db.coll.find().collection) with self.assertRaises(AttributeError): - self.db.test.find().collection = "hello" # type: ignore + self.db.coll.find().collection = "hello" # type: ignore async def test_get_more(self): db = self.db - await db.drop_collection("test") - await db.test.insert_many([{"i": i} for i in range(10)]) - self.assertEqual(10, len(await db.test.find().batch_size(5).to_list())) + await db.drop_collection("coll") + await db.coll.insert_many([{"i": i} for i in range(10)]) + self.assertEqual(10, len(await db.coll.find().batch_size(5).to_list())) async def test_tailable(self): db = self.db - await db.drop_collection("test") - await db.create_collection("test", capped=True, size=1000, max=3) - self.addAsyncCleanup(db.drop_collection, "test") - cursor = db.test.find(cursor_type=CursorType.TAILABLE) + await db.drop_collection("coll") + await db.create_collection("coll", capped=True, size=1000, max=3) + self.addAsyncCleanup(db.drop_collection, "coll") + cursor = db.coll.find(cursor_type=CursorType.TAILABLE) - await db.test.insert_one({"x": 1}) + await db.coll.insert_one({"x": 1}) count = 0 async for doc in cursor: count += 1 self.assertEqual(1, doc["x"]) self.assertEqual(1, count) - await db.test.insert_one({"x": 2}) + await db.coll.insert_one({"x": 2}) count = 0 async for doc in cursor: count += 1 self.assertEqual(2, doc["x"]) self.assertEqual(1, count) - await db.test.insert_one({"x": 3}) + await db.coll.insert_one({"x": 3}) count = 0 async for doc in cursor: count += 1 @@ -1160,19 +1158,19 @@ async def test_tailable(self): # Capped rollover - the collection can never # have more than 3 documents. Just make sure # this doesn't raise... - await db.test.insert_many([{"x": i} for i in range(4, 7)]) + await db.coll.insert_many([{"x": i} for i in range(4, 7)]) self.assertEqual(0, len(await cursor.to_list())) # and that the cursor doesn't think it's still alive. self.assertFalse(cursor.alive) - self.assertEqual(3, await db.test.count_documents({})) + self.assertEqual(3, await db.coll.count_documents({})) # __getitem__(index) if _IS_SYNC: for cursor in ( - db.test.find(cursor_type=CursorType.TAILABLE), - db.test.find(cursor_type=CursorType.TAILABLE_AWAIT), + db.coll.find(cursor_type=CursorType.TAILABLE), + db.coll.find(cursor_type=CursorType.TAILABLE_AWAIT), ): self.assertEqual(4, cursor[0]["x"]) self.assertEqual(5, cursor[1]["x"]) @@ -1196,10 +1194,10 @@ async def test_tailable(self): def test_concurrent_close(self): """Ensure a tailable can be closed from another thread.""" db = self.db - db.drop_collection("test") - db.create_collection("test", capped=True, size=1000, max=3) - self.addCleanup(db.drop_collection, "test") - cursor = db.test.find(cursor_type=CursorType.TAILABLE) + db.drop_collection("coll") + db.create_collection("coll", capped=True, size=1000, max=3) + self.addCleanup(db.drop_collection, "coll") + cursor = db.coll.find(cursor_type=CursorType.TAILABLE) def iterate_cursor(): while cursor.alive: @@ -1219,37 +1217,37 @@ def iterate_cursor(): self.assertFalse(t.is_alive()) async def test_distinct(self): - await self.db.drop_collection("test") + await self.db.drop_collection("coll") - await self.db.test.insert_many([{"a": 1}, {"a": 2}, {"a": 2}, {"a": 2}, {"a": 3}]) + await self.db.coll.insert_many([{"a": 1}, {"a": 2}, {"a": 2}, {"a": 2}, {"a": 3}]) - distinct = await self.db.test.find({"a": {"$lt": 3}}).distinct("a") + distinct = await self.db.coll.find({"a": {"$lt": 3}}).distinct("a") distinct.sort() self.assertEqual([1, 2], distinct) - await self.db.drop_collection("test") + await self.db.drop_collection("coll") - await self.db.test.insert_one({"a": {"b": "a"}, "c": 12}) - await self.db.test.insert_one({"a": {"b": "b"}, "c": 8}) - await self.db.test.insert_one({"a": {"b": "c"}, "c": 12}) - await self.db.test.insert_one({"a": {"b": "c"}, "c": 8}) + await self.db.coll.insert_one({"a": {"b": "a"}, "c": 12}) + await self.db.coll.insert_one({"a": {"b": "b"}, "c": 8}) + await self.db.coll.insert_one({"a": {"b": "c"}, "c": 12}) + await self.db.coll.insert_one({"a": {"b": "c"}, "c": 8}) - distinct = await self.db.test.find({"c": 8}).distinct("a.b") + distinct = await self.db.coll.find({"c": 8}).distinct("a.b") distinct.sort() self.assertEqual(["b", "c"], distinct) async def test_with_statement(self): - await self.db.drop_collection("test") - await self.db.test.insert_many([{} for _ in range(100)]) + await self.db.drop_collection("coll") + await self.db.coll.insert_many([{} for _ in range(100)]) - c1 = self.db.test.find() - async with self.db.test.find() as c2: + c1 = self.db.coll.find() + async with self.db.coll.find() as c2: self.assertTrue(c2.alive) self.assertFalse(c2.alive) - async with self.db.test.find() as c2: + async with self.db.coll.find() as c2: self.assertEqual(100, len(await c2.to_list())) self.assertFalse(c2.alive) self.assertTrue(c1.alive) @@ -1259,18 +1257,18 @@ async def test_comment(self): await self.client.drop_database(self.db) await self.db.command("profile", 2) # Profile ALL commands. try: - await self.db.test.find().comment("foo").to_list() + await self.db.coll.find().comment("foo").to_list() count = await self.db.system.profile.count_documents( - {"ns": "pymongo_test.test", "op": "query", "command.comment": "foo"} + {"ns": "db.coll", "op": "query", "command.comment": "foo"} ) self.assertEqual(count, 1) - await self.db.test.find().comment("foo").distinct("type") + await self.db.coll.find().comment("foo").distinct("type") count = await self.db.system.profile.count_documents( { - "ns": "pymongo_test.test", + "ns": "db.coll", "op": "command", - "command.distinct": "test", + "command.distinct": "coll", "command.comment": "foo", } ) @@ -1279,16 +1277,16 @@ async def test_comment(self): await self.db.command("profile", 0) # Turn off profiling. await self.db.system.profile.drop() - await self.db.test.insert_many([{}, {}]) - cursor = self.db.test.find() + await self.db.coll.insert_many([{}, {}]) + cursor = self.db.coll.find() await anext(cursor) self.assertRaises(InvalidOperation, cursor.comment, "hello") async def test_alive(self): - await self.db.test.delete_many({}) - await self.db.test.insert_many([{} for _ in range(3)]) - self.addAsyncCleanup(self.db.test.delete_many, {}) - cursor = self.db.test.find().batch_size(2) + await self.db.coll.delete_many({}) + await self.db.coll.insert_many([{} for _ in range(3)]) + self.addAsyncCleanup(self.db.coll.delete_many, {}) + cursor = self.db.coll.find().batch_size(2) n = 0 while True: await cursor.next() @@ -1403,7 +1401,7 @@ async def test_getMore_does_not_send_readPreference(self): client = await self.async_rs_or_single_client(event_listeners=[listener]) # We never send primary read preference so override the default. coll = client[self.db.name].get_collection( - "test", read_preference=ReadPreference.PRIMARY_PREFERRED + "coll", read_preference=ReadPreference.PRIMARY_PREFERRED ) await coll.delete_many({}) @@ -1443,7 +1441,7 @@ async def test_to_list_empty(self): self.assertEqual([], docs) async def test_to_list_length(self): - coll = self.db.test + coll = self.db.coll await coll.insert_many([{} for _ in range(5)]) self.addAsyncCleanup(coll.drop) c = coll.find() @@ -1471,7 +1469,7 @@ async def test_to_list_csot_applied(self): @async_client_context.require_change_streams async def test_command_cursor_to_list(self): # Set maxAwaitTimeMS=1 to speed up the test. - c = await self.db.test.aggregate([{"$changeStream": {}}], maxAwaitTimeMS=1) + c = await self.db.coll.aggregate([{"$changeStream": {}}], maxAwaitTimeMS=1) self.addAsyncCleanup(c.close) docs = await c.to_list() self.assertGreaterEqual(len(docs), 0) @@ -1487,14 +1485,14 @@ async def test_command_cursor_to_list_empty(self): @async_client_context.require_change_streams async def test_command_cursor_to_list_length(self): db = self.db - await db.drop_collection("test") - await db.test.insert_many([{"foo": 1}, {"foo": 2}]) + await db.drop_collection("coll") + await db.coll.insert_many([{"foo": 1}, {"foo": 2}]) pipeline = {"$project": {"_id": False, "foo": True}} - result = await db.test.aggregate([pipeline]) + result = await db.coll.aggregate([pipeline]) self.assertEqual(len(await result.to_list()), 2) - result = await db.test.aggregate([pipeline]) + result = await db.coll.aggregate([pipeline]) self.assertEqual(len(await result.to_list(1)), 1) @async_client_context.require_failCommand_blockConnection @@ -1520,10 +1518,10 @@ async def test_command_cursor_to_list_csot_applied(self): class TestRawBatchCursor(AsyncIntegrationTest): async def asyncSetUp(self): await super().asyncSetUp() - await self.db.test.drop() + await self.db.coll.drop() async def test_find_raw(self): - c = self.db.test + c = self.db.coll docs = [{"_id": i, "x": 3.0 * i} for i in range(10)] await c.insert_many(docs) batches = await c.find_raw_batches().sort("_id").to_list() @@ -1532,7 +1530,7 @@ async def test_find_raw(self): @async_client_context.require_transactions async def test_find_raw_transaction(self): - c = self.db.test + c = self.db.coll docs = [{"_id": i, "x": 3.0 * i} for i in range(10)] await c.insert_many(docs) @@ -1561,7 +1559,7 @@ async def test_find_raw_transaction(self): @async_client_context.require_sessions @async_client_context.require_failCommand_fail_point async def test_find_raw_retryable_reads(self): - c = self.db.test + c = self.db.coll docs = [{"_id": i, "x": 3.0 * i} for i in range(10)] await c.insert_many(docs) @@ -1581,7 +1579,7 @@ async def test_find_raw_retryable_reads(self): @async_client_context.require_version_min(5, 0, 0) @async_client_context.require_no_standalone async def test_find_raw_snapshot_reads(self): - c = self.db.get_collection("test", write_concern=WriteConcern(w="majority")) + c = self.db.get_collection("coll", write_concern=WriteConcern(w="majority")) docs = [{"_id": i, "x": 3.0 * i} for i in range(10)] await c.insert_many(docs) @@ -1589,8 +1587,8 @@ async def test_find_raw_snapshot_reads(self): client = await self.async_rs_or_single_client(event_listeners=[listener], retryReads=True) db = client[self.db.name] async with client.start_session(snapshot=True) as session: - await db.test.distinct("x", {}, session=session) - batches = await db.test.find_raw_batches(session=session).sort("_id").to_list() + await db.coll.distinct("x", {}, session=session) + batches = await db.coll.find_raw_batches(session=session).sort("_id").to_list() self.assertEqual(1, len(batches)) self.assertEqual(docs, decode_all(batches[0])) @@ -1599,55 +1597,55 @@ async def test_find_raw_snapshot_reads(self): self.assertIsNotNone(find_cmd["readConcern"]["atClusterTime"]) async def test_explain(self): - c = self.db.test + c = self.db.coll explanation = await c.find_raw_batches().explain() self.assertIsInstance(explanation, dict) async def test_empty(self): - cursor = self.db.test.find_raw_batches() + cursor = self.db.coll.find_raw_batches() with self.assertRaises(StopAsyncIteration): await anext(cursor) async def test_clone(self): - await self.db.test.insert_one({}) - cursor = self.db.test.find_raw_batches() + await self.db.coll.insert_one({}) + cursor = self.db.coll.find_raw_batches() # Copy of a RawBatchCursor is also a RawBatchCursor, not a Cursor. self.assertIsInstance(await anext(cursor.clone()), bytes) self.assertIsInstance(await anext(copy.copy(cursor)), bytes) @async_client_context.require_no_mongos async def test_exhaust(self): - c = self.db.test + c = self.db.coll await c.insert_many({"_id": i} for i in range(200)) result = b"".join(await c.find_raw_batches(cursor_type=CursorType.EXHAUST).to_list()) self.assertEqual([{"_id": i} for i in range(200)], decode_all(result)) async def test_server_error(self): with self.assertRaises(OperationFailure) as exc: - await anext(self.db.test.find_raw_batches({"x": {"$bad": 1}})) + await anext(self.db.coll.find_raw_batches({"x": {"$bad": 1}})) # The server response was decoded, not left raw. self.assertIsInstance(exc.exception.details, dict) async def test_get_item(self): with self.assertRaises(InvalidOperation): - self.db.test.find_raw_batches()[0] + self.db.coll.find_raw_batches()[0] async def test_collation(self): - await self.db.test.insert_one({}) - await anext(self.db.test.find_raw_batches(collation=Collation("en_US"))) + await self.db.coll.insert_one({}) + await anext(self.db.coll.find_raw_batches(collation=Collation("en_US"))) async def test_read_concern(self): - await self.db.get_collection("test", write_concern=WriteConcern(w="majority")).insert_one( + await self.db.get_collection("coll", write_concern=WriteConcern(w="majority")).insert_one( {} ) - c = self.db.get_collection("test", read_concern=ReadConcern("majority")) + c = self.db.get_collection("coll", read_concern=ReadConcern("majority")) await anext(c.find_raw_batches()) async def test_monitoring(self): listener = OvertCommandListener() client = await self.async_rs_or_single_client(event_listeners=[listener]) - c = client.pymongo_test.test + c = client.db.coll await c.insert_many([{"_id": i} for i in range(10)]) listener.reset() @@ -1660,10 +1658,10 @@ async def test_monitoring(self): succeeded = listener.succeeded_events[0] self.assertEqual(0, len(listener.failed_events)) self.assertEqual("find", started.command_name) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertEqual("find", succeeded.command_name) csr = succeeded.reply["cursor"] - self.assertEqual(csr["ns"], "pymongo_test.test") + self.assertEqual(csr["ns"], "db.coll") # The batch is a list of one raw bytes object. self.assertEqual(len(csr["firstBatch"]), 1) @@ -1678,10 +1676,10 @@ async def test_monitoring(self): succeeded = listener.succeeded_events[0] self.assertEqual(0, len(listener.failed_events)) self.assertEqual("getMore", started.command_name) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertEqual("getMore", succeeded.command_name) csr = succeeded.reply["cursor"] - self.assertEqual(csr["ns"], "pymongo_test.test") + self.assertEqual(csr["ns"], "db.coll") self.assertEqual(len(csr["nextBatch"]), 1) self.assertEqual(decode_all(csr["nextBatch"][0]), [{"_id": i} for i in range(4, 8)]) finally: @@ -1691,7 +1689,7 @@ async def test_monitoring(self): class TestRawBatchCommandCursor(AsyncIntegrationTest): async def test_aggregate_raw(self): - c = self.db.test + c = self.db.coll await c.drop() docs = [{"_id": i, "x": 3.0 * i} for i in range(10)] await c.insert_many(docs) @@ -1701,7 +1699,7 @@ async def test_aggregate_raw(self): @async_client_context.require_transactions async def test_aggregate_raw_transaction(self): - c = self.db.test + c = self.db.coll await c.drop() docs = [{"_id": i, "x": 3.0 * i} for i in range(10)] await c.insert_many(docs) @@ -1732,7 +1730,7 @@ async def test_aggregate_raw_transaction(self): @async_client_context.require_sessions @async_client_context.require_failCommand_fail_point async def test_aggregate_raw_retryable_reads(self): - c = self.db.test + c = self.db.coll await c.drop() docs = [{"_id": i, "x": 3.0 * i} for i in range(10)] await c.insert_many(docs) @@ -1756,7 +1754,7 @@ async def test_aggregate_raw_retryable_reads(self): @async_client_context.require_version_min(5, 0, -1) @async_client_context.require_no_standalone async def test_aggregate_raw_snapshot_reads(self): - c = self.db.get_collection("test", write_concern=WriteConcern(w="majority")) + c = self.db.get_collection("coll", write_concern=WriteConcern(w="majority")) await c.drop() docs = [{"_id": i, "x": 3.0 * i} for i in range(10)] await c.insert_many(docs) @@ -1765,9 +1763,9 @@ async def test_aggregate_raw_snapshot_reads(self): client = await self.async_rs_or_single_client(event_listeners=[listener], retryReads=True) db = client[self.db.name] async with client.start_session(snapshot=True) as session: - await db.test.distinct("x", {}, session=session) + await db.coll.distinct("x", {}, session=session) batches = await ( - await db.test.aggregate_raw_batches([{"$sort": {"_id": 1}}], session=session) + await db.coll.aggregate_raw_batches([{"$sort": {"_id": 1}}], session=session) ).to_list() self.assertEqual(1, len(batches)) self.assertEqual(docs, decode_all(batches[0])) @@ -1777,7 +1775,7 @@ async def test_aggregate_raw_snapshot_reads(self): self.assertIsNotNone(find_cmd["readConcern"]["atClusterTime"]) async def test_server_error(self): - c = self.db.test + c = self.db.coll await c.drop() docs = [{"_id": i, "x": 3.0 * i} for i in range(10)] await c.insert_many(docs) @@ -1785,7 +1783,7 @@ async def test_server_error(self): with self.assertRaises(OperationFailure) as exc: await ( - await self.db.test.aggregate_raw_batches( + await self.db.coll.aggregate_raw_batches( [ { "$sort": {"_id": 1}, @@ -1801,15 +1799,15 @@ async def test_server_error(self): async def test_get_item(self): with self.assertRaises(InvalidOperation): - (await self.db.test.aggregate_raw_batches([]))[0] + (await self.db.coll.aggregate_raw_batches([]))[0] async def test_collation(self): - await anext(await self.db.test.aggregate_raw_batches([], collation=Collation("en_US"))) + await anext(await self.db.coll.aggregate_raw_batches([], collation=Collation("en_US"))) async def test_monitoring(self): listener = OvertCommandListener() client = await self.async_rs_or_single_client(event_listeners=[listener]) - c = client.pymongo_test.test + c = client.db.coll await c.drop() await c.insert_many([{"_id": i} for i in range(10)]) @@ -1821,10 +1819,10 @@ async def test_monitoring(self): succeeded = listener.succeeded_events[0] self.assertEqual(0, len(listener.failed_events)) self.assertEqual("aggregate", started.command_name) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertEqual("aggregate", succeeded.command_name) csr = succeeded.reply["cursor"] - self.assertEqual(csr["ns"], "pymongo_test.test") + self.assertEqual(csr["ns"], "db.coll") # First batch is empty. self.assertEqual(len(csr["firstBatch"]), 0) @@ -1837,10 +1835,10 @@ async def test_monitoring(self): succeeded = listener.succeeded_events[0] self.assertEqual(0, len(listener.failed_events)) self.assertEqual("getMore", started.command_name) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertEqual("getMore", succeeded.command_name) csr = succeeded.reply["cursor"] - self.assertEqual(csr["ns"], "pymongo_test.test") + self.assertEqual(csr["ns"], "db.coll") self.assertEqual(len(csr["nextBatch"]), 1) self.assertEqual(csr["nextBatch"][0], batch) self.assertEqual(decode_all(batch), [{"_id": i} for i in range(n, min(n + 4, 10))]) @@ -1854,7 +1852,7 @@ async def test_monitoring(self): async def test_exhaust_cursor_db_set(self): listener = OvertCommandListener() client = await self.async_rs_or_single_client(event_listeners=[listener]) - c = client.pymongo_test.test + c = client.db.coll await c.delete_many({}) await c.insert_many([{"_id": i} for i in range(3)]) @@ -1868,7 +1866,7 @@ async def test_exhaust_cursor_db_set(self): listener.started_command_names(), ["find", "getMore", "getMore", "getMore"] ) for cmd in listener.started_events: - self.assertEqual(cmd.command["$db"], "pymongo_test") + self.assertEqual(cmd.command["$db"], "db") if __name__ == "__main__": diff --git a/test/asynchronous/test_custom_types.py b/test/asynchronous/test_custom_types.py index 82c54512cc..48ed531cb6 100644 --- a/test/asynchronous/test_custom_types.py +++ b/test/asynchronous/test_custom_types.py @@ -625,15 +625,15 @@ class MyType(pytype): # type: ignore class TestCollectionWCustomType(AsyncIntegrationTest): async def asyncSetUp(self): await super().asyncSetUp() - await self.db.test.drop() + await self.db.coll.drop() async def asyncTearDown(self): - await self.db.test.drop() + await self.db.coll.drop() async def test_overflow_int_w_custom_decoder(self): type_registry = TypeRegistry(fallback_encoder=lambda val: str(val)) codec_options = CodecOptions(type_registry=type_registry) - collection = self.db.get_collection("test", codec_options=codec_options) + collection = self.db.get_collection("coll", codec_options=codec_options) await collection.insert_one({"_id": 1, "data": 2**520}) ret = await collection.find_one() @@ -642,7 +642,7 @@ async def test_overflow_int_w_custom_decoder(self): async def test_command_errors_w_custom_type_decoder(self): db = self.db test_doc = {"_id": 1, "data": "a"} - test = db.get_collection("test", codec_options=UNINT_DECODER_CODECOPTS) + test = db.get_collection("coll", codec_options=UNINT_DECODER_CODECOPTS) result = await test.insert_one(test_doc) self.assertEqual(result.inserted_id, test_doc["_id"]) @@ -653,9 +653,9 @@ async def test_find_w_custom_type_decoder(self): db = self.db input_docs = [{"x": Int64(k)} for k in [1, 2, 3]] for doc in input_docs: - await db.test.insert_one(doc) + await db.coll.insert_one(doc) - test = db.get_collection("test", codec_options=UNINT_DECODER_CODECOPTS) + test = db.get_collection("coll", codec_options=UNINT_DECODER_CODECOPTS) async for doc in test.find({}, batch_size=1): self.assertIsInstance(doc["x"], UndecipherableInt64Type) @@ -664,10 +664,10 @@ async def run_test(doc_cls): db = self.db input_docs = [{"x": Int64(k)} for k in [1, 2, 3]] for doc in input_docs: - await db.test.insert_one(doc) + await db.coll.insert_one(doc) test = db.get_collection( - "test", + "coll", codec_options=CodecOptions( type_registry=TypeRegistry([UndecipherableIntDecoder()]), document_class=doc_cls ), @@ -681,7 +681,7 @@ async def run_test(doc_cls): async def test_aggregate_w_custom_type_decoder(self): db = self.db - await db.test.insert_many( + await db.coll.insert_many( [ {"status": "in progress", "qty": Int64(1)}, {"status": "complete", "qty": Int64(10)}, @@ -690,7 +690,7 @@ async def test_aggregate_w_custom_type_decoder(self): {"status": "in progress", "qty": Int64(1)}, ] ) - test = db.get_collection("test", codec_options=UNINT_DECODER_CODECOPTS) + test = db.get_collection("coll", codec_options=UNINT_DECODER_CODECOPTS) pipeline: list = [ {"$match": {"status": "complete"}}, @@ -704,9 +704,9 @@ async def test_aggregate_w_custom_type_decoder(self): self.assertEqual(res["total_qty"].value, 20) async def test_distinct_w_custom_type(self): - await self.db.drop_collection("test") + await self.db.drop_collection("coll") - test = self.db.get_collection("test", codec_options=UNINT_CODECOPTS) + test = self.db.get_collection("coll", codec_options=UNINT_CODECOPTS) values = [ UndecipherableInt64Type(1), UndecipherableInt64Type(2), @@ -719,7 +719,7 @@ async def test_distinct_w_custom_type(self): async def test_find_one_and__w_custom_type_decoder(self): db = self.db - c = db.get_collection("test", codec_options=UNINT_DECODER_CODECOPTS) + c = db.get_collection("coll", codec_options=UNINT_DECODER_CODECOPTS) await c.insert_one({"_id": 1, "x": Int64(1)}) doc = await c.find_one_and_update( @@ -866,7 +866,7 @@ async def test_break_resume_token(self): # Get one document from a change stream to determine resumeToken type. await self.create_targets() change_stream = await self.change_stream() - await self.input_target.insert_one({"data": "test"}) + await self.input_target.insert_one({"data": "coll"}) change = await anext(change_stream) resume_token_decoder = type_obfuscating_decoder_factory(type(change["_id"]["_data"])) @@ -916,13 +916,13 @@ class TestCollectionChangeStreamsWCustomTypes( @async_client_context.require_change_streams async def asyncSetUp(self): await super().asyncSetUp() - await self.db.test.delete_many({}) + await self.db.coll.delete_many({}) async def asyncTearDown(self): await self.input_target.drop() async def create_targets(self, *args, **kwargs): - self.watched_target = self.db.get_collection("test", *args, **kwargs) + self.watched_target = self.db.get_collection("coll", *args, **kwargs) self.input_target = self.watched_target # Ensure the collection exists and is empty. await self.input_target.insert_one({}) @@ -936,7 +936,7 @@ class TestDatabaseChangeStreamsWCustomTypes( @async_client_context.require_change_streams async def asyncSetUp(self): await super().asyncSetUp() - await self.db.test.delete_many({}) + await self.db.coll.delete_many({}) async def asyncTearDown(self): await self.input_target.drop() @@ -944,7 +944,7 @@ async def asyncTearDown(self): async def create_targets(self, *args, **kwargs): self.watched_target = self.client.get_database(self.db.name, *args, **kwargs) - self.input_target = self.watched_target.test + self.input_target = self.watched_target.coll # Insert a record to ensure db, coll are created. await self.input_target.insert_one({"data": "dummy"}) @@ -956,7 +956,7 @@ class TestClusterChangeStreamsWCustomTypes( @async_client_context.require_change_streams async def asyncSetUp(self): await super().asyncSetUp() - await self.db.test.delete_many({}) + await self.db.coll.delete_many({}) async def asyncTearDown(self): await self.input_target.drop() @@ -968,7 +968,7 @@ async def create_targets(self, *args, **kwargs): kwargs["type_registry"] = codec_options.type_registry kwargs["document_class"] = codec_options.document_class self.watched_target = await self.async_rs_client(*args, **kwargs) - self.input_target = self.watched_target[self.db.name].test + self.input_target = self.watched_target[self.db.name].coll # Insert a record to ensure db, coll are created. await self.input_target.insert_one({"data": "dummy"}) diff --git a/test/asynchronous/test_database.py b/test/asynchronous/test_database.py index 22213d6e8a..e0b8548200 100644 --- a/test/asynchronous/test_database.py +++ b/test/asynchronous/test_database.py @@ -80,7 +80,7 @@ def test_get_collection(self): codec_options = CodecOptions(tz_aware=True) write_concern = WriteConcern(w=2, j=True) read_concern = ReadConcern("majority") - coll = self.client.pymongo_test.get_collection( + coll = self.client.db.get_collection( "foo", codec_options, ReadPreference.SECONDARY, write_concern, read_concern ) self.assertEqual("foo", coll.name) @@ -90,7 +90,7 @@ def test_get_collection(self): self.assertEqual(read_concern, coll.read_concern) def test_getattr(self): - db = self.client.pymongo_test + db = self.client.db self.assertIsInstance(db["_does_not_exist"], AsyncCollection) with self.assertRaises(AttributeError) as context: @@ -102,7 +102,7 @@ def test_getattr(self): self.assertIn("has no attribute '_does_not_exist'", str(context.exception)) def test_iteration(self): - db = self.client.pymongo_test + db = self.client.db msg = "'AsyncDatabase' object is not iterable" # Iteration fails with self.assertRaisesRegex(TypeError, msg): @@ -133,27 +133,27 @@ def test_hashable(self): self.assertIn(self.client.test, {AsyncDatabase(self.client, "test")}) def test_get_coll(self): - db = AsyncDatabase(self.client, "pymongo_test") - self.assertEqual(db.test, db["test"]) - self.assertEqual(db.test, AsyncCollection(db, "test")) - self.assertNotEqual(db.test, AsyncCollection(db, "mike")) - self.assertEqual(db.test.mike, db["test.mike"]) + db = AsyncDatabase(self.client, "db") + self.assertEqual(db.coll, db["test"]) + self.assertEqual(db.coll, AsyncCollection(db, "test")) + self.assertNotEqual(db.coll, AsyncCollection(db, "mike")) + self.assertEqual(db.coll.mike, db["test.mike"]) def test_repr(self): name = "AsyncDatabase" self.assertEqual( - repr(AsyncDatabase(self.client, "pymongo_test")), - "{}({!r}, {})".format(name, self.client, repr("pymongo_test")), + repr(AsyncDatabase(self.client, "db")), + "{}({!r}, {})".format(name, self.client, repr("db")), ) async def test_create_collection(self): - db = AsyncDatabase(self.client, "pymongo_test") + db = AsyncDatabase(self.client, "db") - await db.test.insert_one({"hello": "world"}) + await db.coll.insert_one({"hello": "world"}) with self.assertRaises(CollectionInvalid): - await db.create_collection("test") + await db.create_collection("coll") - await db.drop_collection("test") + await db.drop_collection("coll") with self.assertRaises(TypeError): await db.create_collection(5) # type: ignore[arg-type] @@ -162,10 +162,10 @@ async def test_create_collection(self): with self.assertRaises(InvalidName): await db.create_collection("coll..ection") # type: ignore[arg-type] - test = await db.create_collection("test") + test = await db.create_collection("coll") self.assertIn("test", await db.list_collection_names()) await test.insert_one({"hello": "world"}) - self.assertEqual((await db.test.find_one())["hello"], "world") + self.assertEqual((await db.coll.find_one())["hello"], "world") await db.drop_collection("test.foo") await db.create_collection("test.foo") @@ -174,9 +174,9 @@ async def test_create_collection(self): await db.create_collection("test.foo") async def test_list_collection_names(self): - db = AsyncDatabase(self.client, "pymongo_test") - await db.test.insert_one({"dummy": "object"}) - await db.test.mike.insert_one({"dummy": "object"}) + db = AsyncDatabase(self.client, "db") + await db.coll.insert_one({"dummy": "object"}) + await db.coll.mike.insert_one({"dummy": "object"}) colls = await db.list_collection_names() self.assertIn("test", colls) @@ -243,10 +243,10 @@ async def test_check_exists(self): self.assertNotIn("listCollections", listener.started_command_names()) async def test_list_collections(self): - await self.client.drop_database("pymongo_test") - db = AsyncDatabase(self.client, "pymongo_test") - await db.test.insert_one({"dummy": "object"}) - await db.test.mike.insert_one({"dummy": "object"}) + await self.client.drop_database("db") + db = AsyncDatabase(self.client, "db") + await db.coll.insert_one({"dummy": "object"}) + await db.coll.mike.insert_one({"dummy": "object"}) results = await db.list_collections() colls = [result["name"] async for result in results] @@ -281,9 +281,9 @@ async def test_list_collections(self): ).to_list() self.assertEqual(1, len(colls)) - await db.drop_collection("test") + await db.drop_collection("coll") - await db.create_collection("test", capped=True, size=4096) + await db.create_collection("coll", capped=True, size=4096) results = await db.list_collections(filter={"options.capped": True}) colls = [result["name"] async for result in results] @@ -309,7 +309,7 @@ async def test_list_collections(self): # Check if there are any collections which don't exist. self.assertLessEqual(set(colls), {"test", "system.indexes"}) - await self.client.drop_database("pymongo_test") + await self.client.drop_database("db") async def test_list_collection_names_single_socket(self): client = await self.async_rs_or_single_client(maxPoolSize=1) @@ -322,71 +322,69 @@ async def test_list_collection_names_single_socket(self): await client.drop_database("test_collection_names_single_socket") async def test_drop_collection(self): - db = AsyncDatabase(self.client, "pymongo_test") + db = AsyncDatabase(self.client, "db") with self.assertRaises(TypeError): await db.drop_collection(5) # type: ignore[arg-type] with self.assertRaises(TypeError): await db.drop_collection(None) # type: ignore[arg-type] - await db.test.insert_one({"dummy": "object"}) + await db.coll.insert_one({"dummy": "object"}) self.assertIn("test", await db.list_collection_names()) - await db.drop_collection("test") + await db.drop_collection("coll") self.assertNotIn("test", await db.list_collection_names()) - await db.test.insert_one({"dummy": "object"}) + await db.coll.insert_one({"dummy": "object"}) self.assertIn("test", await db.list_collection_names()) - await db.drop_collection("test") + await db.drop_collection("coll") self.assertNotIn("test", await db.list_collection_names()) - await db.test.insert_one({"dummy": "object"}) + await db.coll.insert_one({"dummy": "object"}) self.assertIn("test", await db.list_collection_names()) - await db.drop_collection(db.test) + await db.drop_collection(db.coll) self.assertNotIn("test", await db.list_collection_names()) - await db.test.insert_one({"dummy": "object"}) + await db.coll.insert_one({"dummy": "object"}) self.assertIn("test", await db.list_collection_names()) - await db.test.drop() + await db.coll.drop() self.assertNotIn("test", await db.list_collection_names()) - await db.test.drop() + await db.coll.drop() - await db.drop_collection(db.test.doesnotexist) + await db.drop_collection(db.coll.doesnotexist) if async_client_context.is_rs: - db_wc = AsyncDatabase( - self.client, "pymongo_test", write_concern=IMPOSSIBLE_WRITE_CONCERN - ) + db_wc = AsyncDatabase(self.client, "db", write_concern=IMPOSSIBLE_WRITE_CONCERN) with self.assertRaises(WriteConcernError): - await db_wc.drop_collection("test") + await db_wc.drop_collection("coll") async def test_validate_collection(self): - db = self.client.pymongo_test + db = self.client.db with self.assertRaises(TypeError): await db.validate_collection(5) # type: ignore[arg-type] with self.assertRaises(TypeError): await db.validate_collection(None) # type: ignore[arg-type] - await db.test.insert_one({"dummy": "object"}) + await db.coll.insert_one({"dummy": "object"}) with self.assertRaises(OperationFailure): await db.validate_collection("test.doesnotexist") with self.assertRaises(OperationFailure): - await db.validate_collection(db.test.doesnotexist) + await db.validate_collection(db.coll.doesnotexist) - self.assertTrue(await db.validate_collection("test")) - self.assertTrue(await db.validate_collection(db.test)) - self.assertTrue(await db.validate_collection(db.test, full=True)) - self.assertTrue(await db.validate_collection(db.test, scandata=True)) - self.assertTrue(await db.validate_collection(db.test, scandata=True, full=True)) - self.assertTrue(await db.validate_collection(db.test, True, True)) + self.assertTrue(await db.validate_collection("coll")) + self.assertTrue(await db.validate_collection(db.coll)) + self.assertTrue(await db.validate_collection(db.coll, full=True)) + self.assertTrue(await db.validate_collection(db.coll, scandata=True)) + self.assertTrue(await db.validate_collection(db.coll, scandata=True, full=True)) + self.assertTrue(await db.validate_collection(db.coll, True, True)) @async_client_context.require_version_min(4, 3, 3) @async_client_context.require_no_standalone async def test_validate_collection_background(self): - db = self.client.pymongo_test.with_options(write_concern=WriteConcern(w="majority")) - await db.test.insert_one({"dummy": "object"}) - coll = db.test + db = self.client.db.with_options(write_concern=WriteConcern(w="majority")) + await db.coll.insert_one({"dummy": "object"}) + coll = db.coll self.assertTrue(await db.validate_collection(coll, background=False)) # The inMemory storage engine does not support background=True. if async_client_context.storage_engine != "inMemory": @@ -412,10 +410,10 @@ async def test_command(self): # We use 'aggregate' as our example command, since it's an easy way to # retrieve a BSON regex from a collection using a command. async def test_command_with_regex(self): - db = self.client.pymongo_test - await db.test.drop() - await db.test.insert_one({"r": re.compile(".*")}) - await db.test.insert_one({"r": Regex(".*")}) + db = self.client.db + await db.coll.drop() + await db.coll.insert_one({"r": re.compile(".*")}) + await db.coll.insert_one({"r": Regex(".*")}) result = await db.command("aggregate", "test", pipeline=[], cursor={}) for doc in result["cursor"]["firstBatch"]: @@ -427,21 +425,21 @@ async def test_command_bulkWrite(self): await self.client.admin.command( { "bulkWrite": 1, - "nsInfo": [{"ns": self.db.test.full_name}], + "nsInfo": [{"ns": self.db.coll.full_name}], "ops": [{"insert": 0, "document": {}}], } ) await self.db.command({"insert": "test", "documents": [{}]}) await self.db.command({"update": "test", "updates": [{"q": {}, "u": {"$set": {"x": 1}}}]}) await self.db.command({"delete": "test", "deletes": [{"q": {}, "limit": 1}]}) - await self.db.test.drop() + await self.db.coll.drop() async def test_cursor_command(self): - db = self.client.pymongo_test - await db.test.drop() + db = self.client.db + await db.coll.drop() docs = [{"_id": i, "doc": i} for i in range(3)] - await db.test.insert_many(docs) + await db.coll.insert_many(docs) cursor = await db.cursor_command("find", "test") @@ -478,22 +476,22 @@ async def test_id_ordering(self): # guarantee any particular order. This will never # work right in any Python or environment # with hash randomization enabled (e.g. tox). - db = self.client.pymongo_test - await db.test.drop() - await db.test.insert_one(SON([("hello", "world"), ("_id", 5)])) + db = self.client.db + await db.coll.drop() + await db.coll.insert_one(SON([("hello", "world"), ("_id", 5)])) db = self.client.get_database( - "pymongo_test", codec_options=CodecOptions(document_class=SON[str, Any]) + "db", codec_options=CodecOptions(document_class=SON[str, Any]) ) - cursor = db.test.find() + cursor = db.coll.find() async for x in cursor: for k, _v in x.items(): self.assertEqual(k, "_id") break async def test_deref(self): - db = self.client.pymongo_test - await db.test.drop() + db = self.client.db + await db.coll.drop() with self.assertRaises(TypeError): await db.dereference(5) # type: ignore[arg-type] @@ -504,24 +502,24 @@ async def test_deref(self): self.assertEqual(None, await db.dereference(DBRef("test", ObjectId()))) obj: dict[str, Any] = {"x": True} - key = (await db.test.insert_one(obj)).inserted_id + key = (await db.coll.insert_one(obj)).inserted_id self.assertEqual(obj, await db.dereference(DBRef("test", key))) - self.assertEqual(obj, await db.dereference(DBRef("test", key, "pymongo_test"))) + self.assertEqual(obj, await db.dereference(DBRef("test", key, "db"))) with self.assertRaises(ValueError): await db.dereference(DBRef("test", key, "foo")) self.assertEqual(None, await db.dereference(DBRef("test", 4))) obj = {"_id": 4} - await db.test.insert_one(obj) + await db.coll.insert_one(obj) self.assertEqual(obj, await db.dereference(DBRef("test", 4))) async def test_deref_kwargs(self): - db = self.client.pymongo_test - await db.test.drop() + db = self.client.db + await db.coll.drop() - await db.test.insert_one({"_id": 4, "foo": "bar"}) + await db.coll.insert_one({"_id": 4, "foo": "bar"}) db = self.client.get_database( - "pymongo_test", codec_options=CodecOptions(document_class=SON[str, Any]) + "db", codec_options=CodecOptions(document_class=SON[str, Any]) ) self.assertEqual( SON([("foo", "bar")]), await db.dereference(DBRef("test", 4), projection={"_id": False}) @@ -529,79 +527,79 @@ async def test_deref_kwargs(self): # TODO some of these tests belong in the collection level testing. async def test_insert_find_one(self): - db = self.client.pymongo_test - await db.test.drop() + db = self.client.db + await db.coll.drop() a_doc = SON({"hello": "world"}) - a_key = (await db.test.insert_one(a_doc)).inserted_id + a_key = (await db.coll.insert_one(a_doc)).inserted_id self.assertIsInstance(a_doc["_id"], ObjectId) self.assertEqual(a_doc["_id"], a_key) - self.assertEqual(a_doc, await db.test.find_one({"_id": a_doc["_id"]})) - self.assertEqual(a_doc, await db.test.find_one(a_key)) - self.assertEqual(None, await db.test.find_one(ObjectId())) - self.assertEqual(a_doc, await db.test.find_one({"hello": "world"})) - self.assertEqual(None, await db.test.find_one({"hello": "test"})) + self.assertEqual(a_doc, await db.coll.find_one({"_id": a_doc["_id"]})) + self.assertEqual(a_doc, await db.coll.find_one(a_key)) + self.assertEqual(None, await db.coll.find_one(ObjectId())) + self.assertEqual(a_doc, await db.coll.find_one({"hello": "world"})) + self.assertEqual(None, await db.coll.find_one({"hello": "test"})) - b = await db.test.find_one() + b = await db.coll.find_one() assert b is not None b["hello"] = "mike" - await db.test.replace_one({"_id": b["_id"]}, b) + await db.coll.replace_one({"_id": b["_id"]}, b) - self.assertNotEqual(a_doc, await db.test.find_one(a_key)) - self.assertEqual(b, await db.test.find_one(a_key)) - self.assertEqual(b, await db.test.find_one()) + self.assertNotEqual(a_doc, await db.coll.find_one(a_key)) + self.assertEqual(b, await db.coll.find_one(a_key)) + self.assertEqual(b, await db.coll.find_one()) count = 0 - async for _ in db.test.find(): + async for _ in db.coll.find(): count += 1 self.assertEqual(count, 1) async def test_long(self): - db = self.client.pymongo_test - await db.test.drop() - await db.test.insert_one({"x": 9223372036854775807}) - retrieved = (await db.test.find_one())["x"] + db = self.client.db + await db.coll.drop() + await db.coll.insert_one({"x": 9223372036854775807}) + retrieved = (await db.coll.find_one())["x"] self.assertEqual(Int64(9223372036854775807), retrieved) self.assertIsInstance(retrieved, Int64) - await db.test.delete_many({}) - await db.test.insert_one({"x": Int64(1)}) - retrieved = (await db.test.find_one())["x"] + await db.coll.delete_many({}) + await db.coll.insert_one({"x": Int64(1)}) + retrieved = (await db.coll.find_one())["x"] self.assertEqual(Int64(1), retrieved) self.assertIsInstance(retrieved, Int64) async def test_delete(self): - db = self.client.pymongo_test - await db.test.drop() + db = self.client.db + await db.coll.drop() - await db.test.insert_one({"x": 1}) - await db.test.insert_one({"x": 2}) - await db.test.insert_one({"x": 3}) + await db.coll.insert_one({"x": 1}) + await db.coll.insert_one({"x": 2}) + await db.coll.insert_one({"x": 3}) length = 0 - async for _ in db.test.find(): + async for _ in db.coll.find(): length += 1 self.assertEqual(length, 3) - await db.test.delete_one({"x": 1}) + await db.coll.delete_one({"x": 1}) length = 0 - async for _ in db.test.find(): + async for _ in db.coll.find(): length += 1 self.assertEqual(length, 2) - await db.test.delete_one(await db.test.find_one()) # type: ignore[arg-type] - await db.test.delete_one(await db.test.find_one()) # type: ignore[arg-type] - self.assertEqual(await db.test.find_one(), None) + await db.coll.delete_one(await db.coll.find_one()) # type: ignore[arg-type] + await db.coll.delete_one(await db.coll.find_one()) # type: ignore[arg-type] + self.assertEqual(await db.coll.find_one(), None) - await db.test.insert_one({"x": 1}) - await db.test.insert_one({"x": 2}) - await db.test.insert_one({"x": 3}) + await db.coll.insert_one({"x": 1}) + await db.coll.insert_one({"x": 2}) + await db.coll.insert_one({"x": 3}) - self.assertTrue(await db.test.find_one({"x": 2})) - await db.test.delete_one({"x": 2}) - self.assertFalse(await db.test.find_one({"x": 2})) + self.assertTrue(await db.coll.find_one({"x": 2})) + await db.coll.delete_one({"x": 2}) + self.assertFalse(await db.coll.find_one({"x": 2})) - self.assertTrue(await db.test.find_one()) - await db.test.delete_many({}) - self.assertFalse(await db.test.find_one()) + self.assertTrue(await db.coll.find_one()) + await db.coll.delete_many({}) + self.assertFalse(await db.coll.find_one()) def test_command_response_without_ok(self): # Sometimes (SERVER-10891) the server's response to a badly-formatted @@ -624,7 +622,7 @@ async def test_command_max_time_ms(self): "configureFailPoint", "maxTimeAlwaysTimeOut", mode="alwaysOn" ) try: - db = self.client.pymongo_test + db = self.client.db await db.command("count", "test") with self.assertRaises(ExecutionTimeout): await db.command("count", "test", maxTimeMS=1) @@ -640,9 +638,9 @@ async def test_command_max_time_ms(self): maxTimeMS=1, ) # Collection helper. - await db.test.aggregate(pipeline=pipeline) + await db.coll.aggregate(pipeline=pipeline) with self.assertRaises(ExecutionTimeout): - await db.test.aggregate(pipeline, maxTimeMS=1) + await db.coll.aggregate(pipeline, maxTimeMS=1) finally: await self.client.admin.command( "configureFailPoint", "maxTimeAlwaysTimeOut", mode="off" @@ -716,7 +714,7 @@ async def test_database_aggregation_fake_cursor(self): else: # SERVER-43287 disallows writing with $out to the admin db, use # $merge instead. - db_name = "pymongo_test" + db_name = "db" write_stage = {"$merge": {"into": {"db": db_name, "coll": coll_name}}} output_coll = self.client[db_name][coll_name] await output_coll.drop() diff --git a/test/asynchronous/test_discovery_and_monitoring.py b/test/asynchronous/test_discovery_and_monitoring.py index b262361c1f..b0e4c1cf72 100644 --- a/test/asynchronous/test_discovery_and_monitoring.py +++ b/test/asynchronous/test_discovery_and_monitoring.py @@ -331,7 +331,7 @@ async def mock_command(*args, **kwargs): async def insert_command(i): try: - await client.test.command("insert", "test", documents=[{"i": i}]) + await client.coll.command("insert", "coll", documents=[{"i": i}]) except AutoReconnect: pass @@ -404,7 +404,7 @@ async def test_connection_close_does_not_block_other_operations(self): "pool initialized with 10 connections", ) - await client.db.test.insert_one({"x": 1}) + await client.db.coll.insert_one({"x": 1}) close_delay = 0.1 latencies = [] should_exit = [] @@ -412,7 +412,7 @@ async def test_connection_close_does_not_block_other_operations(self): async def run_task(): while True: start_time = time.monotonic() - await client.db.test.find_one({}) + await client.db.coll.find_one({}) elapsed = time.monotonic() - start_time latencies.append(elapsed) if should_exit: @@ -487,13 +487,13 @@ async def teardown(): self.addAsyncCleanup(teardown) # Make sure the collection has at least one document. - await client.test.test.delete_many({}) - await client.test.test.insert_one({}) + await client.db.coll.delete_many({}) + await client.db.coll.insert_one({}) # Run a slow operation to tie up the connection. async def target(): try: - await client.test.test.find_one({"$where": delay(0.1)}) + await client.db.coll.find_one({"$where": delay(0.1)}) except ConnectionFailure: pass diff --git a/test/asynchronous/test_encryption.py b/test/asynchronous/test_encryption.py index 455b1940c4..d4d185b496 100644 --- a/test/asynchronous/test_encryption.py +++ b/test/asynchronous/test_encryption.py @@ -316,7 +316,7 @@ async def _test_auto_encrypt(self, opts): {"_id": 4, "ssn": "444"}, {"_id": 5, "ssn": "555"}, ] - encrypted_coll = client.pymongo_test.test + encrypted_coll = client.db.coll await encrypted_coll.insert_one(docs[0]) await encrypted_coll.insert_many(docs[1:3]) unack = encrypted_coll.with_options(write_concern=WriteConcern(w=0)) @@ -324,12 +324,12 @@ async def _test_auto_encrypt(self, opts): await unack.insert_many(docs[4:], ordered=False) async def count_documents(): - return await self.db.test.count_documents({}) == len(docs) + return await self.db.coll.count_documents({}) == len(docs) await async_wait_until(count_documents, "insert documents with w=0") # Database.command auto decrypts. - res = await client.pymongo_test.command("find", "test", filter={"ssn": "000"}) + res = await client.db.command("find", "test", filter={"ssn": "000"}) decrypted_docs = res["cursor"]["firstBatch"] self.assertEqual(decrypted_docs, [{"_id": 0, "ssn": "000"}]) @@ -354,7 +354,7 @@ async def count_documents(): self.assertEqual(set(decrypted_ssns), {d["ssn"] for d in docs}) # Make sure the field is actually encrypted. - async for encrypted_doc in self.db.test.find(): + async for encrypted_doc in self.db.coll.find(): self.assertIsInstance(encrypted_doc["_id"], int) self.assertEncrypted(encrypted_doc["ssn"]) @@ -365,15 +365,15 @@ async def count_documents(): async def test_auto_encrypt(self): # Configure the encrypted field via jsonSchema. json_schema = json_data("custom", "schema.json") - await create_with_schema(self.db.test, json_schema) - self.addAsyncCleanup(self.db.test.drop) + await create_with_schema(self.db.coll, json_schema) + self.addAsyncCleanup(self.db.coll.drop) opts = AutoEncryptionOpts(KMS_PROVIDERS, "keyvault.datakeys") await self._test_auto_encrypt(opts) async def test_auto_encrypt_local_schema_map(self): # Configure the encrypted field via the local schema_map option. - schemas = {"pymongo_test.test": json_data("custom", "schema.json")} + schemas = {"db.coll": json_data("custom", "schema.json")} opts = AutoEncryptionOpts(KMS_PROVIDERS, "keyvault.datakeys", schema_map=schemas) await self._test_auto_encrypt(opts) @@ -416,7 +416,7 @@ async def test_upsert_uuid_standard_encrypt(self): client = await self.async_rs_or_single_client(auto_encryption_opts=opts) options = CodecOptions(uuid_representation=UuidRepresentation.STANDARD) - encrypted_coll = client.pymongo_test.test + encrypted_coll = client.db.coll coll = encrypted_coll.with_options(codec_options=options) uuids = [uuid.uuid4() for _ in range(3)] result = await coll.bulk_write( @@ -454,18 +454,18 @@ async def test_raise_unsupported_error(self): client = await self.async_rs_or_single_client(auto_encryption_opts=opts) msg = "find_raw_batches does not support auto encryption" with self.assertRaisesRegex(InvalidOperation, msg): - await client.test.test.find_raw_batches({}) + await client.db.coll.find_raw_batches({}) msg = "aggregate_raw_batches does not support auto encryption" with self.assertRaisesRegex(InvalidOperation, msg): - await client.test.test.aggregate_raw_batches([]) + await client.db.coll.aggregate_raw_batches([]) if async_client_context.is_mongos: msg = "Exhaust cursors are not supported by mongos" else: msg = "exhaust cursors do not support auto encryption" with self.assertRaisesRegex(InvalidOperation, msg): - await anext(client.test.test.find(cursor_type=CursorType.EXHAUST)) + await anext(client.db.coll.find(cursor_type=CursorType.EXHAUST)) class TestExplicitSimple(AsyncEncryptionIntegrationTest): @@ -3600,12 +3600,12 @@ async def asyncSetUp(self) -> None: async def test_implicit_session_ignored_when_unsupported(self): self.listener.reset() with self.assertRaises(OperationFailure): - await self.mongocryptd_client.db.test.find_one() + await self.mongocryptd_client.db.coll.find_one() self.assertNotIn("lsid", self.listener.started_events[0].command) with self.assertRaises(OperationFailure): - await self.mongocryptd_client.db.test.insert_one({"x": 1}) + await self.mongocryptd_client.db.coll.insert_one({"x": 1}) self.assertNotIn("lsid", self.listener.started_events[1].command) @@ -3617,11 +3617,11 @@ async def test_explicit_session_errors_when_unsupported(self): with self.assertRaisesRegex( ConfigurationError, r"Sessions are not supported by this MongoDB deployment" ): - await self.mongocryptd_client.db.test.find_one(session=s) + await self.mongocryptd_client.db.coll.find_one(session=s) with self.assertRaisesRegex( ConfigurationError, r"Sessions are not supported by this MongoDB deployment" ): - await self.mongocryptd_client.db.test.insert_one({"x": 1}, session=s) + await self.mongocryptd_client.db.coll.insert_one({"x": 1}, session=s) await self.mongocryptd_client.close() diff --git a/test/asynchronous/test_examples.py b/test/asynchronous/test_examples.py index dd27623654..16b50b7e2b 100644 --- a/test/asynchronous/test_examples.py +++ b/test/asynchronous/test_examples.py @@ -47,7 +47,7 @@ async def asyncSetUp(self): async def asyncTearDown(self): # Run after every test. await self.db.inventory.drop() - await self.client.drop_database("pymongo_test") + await self.client.drop_database("db") async def test_first_three_examples(self): db = self.db @@ -923,11 +923,11 @@ async def test_index_management(self): async def test_misc(self): # Marketing examples client = self.client - self.addAsyncCleanup(client.drop_database, "test") - self.addAsyncCleanup(client.drop_database, "my_database") + self.addAsyncCleanup(client.drop_database, "db") + self.addAsyncCleanup(client.drop_database, "db2") # 2. Tunable consistency controls - collection = client.my_database.my_collection + collection = client.db2.coll async with client.start_session() as session: await collection.insert_one({"_id": 1}, session=session) await collection.update_one({"_id": 1}, {"$set": {"a": 1}}, session=session) @@ -935,7 +935,7 @@ async def test_misc(self): pass # 3. Exploiting the power of arrays - collection = client.test.array_updates_test + collection = client.db.array_updates_test await collection.update_one( {"_id": 1}, {"$set": {"a.$[i].b": 2}}, array_filters=[{"i.b": 0}] ) @@ -1165,9 +1165,9 @@ class TestCausalConsistencyExamples(AsyncIntegrationTest): async def test_causal_consistency(self): # Causal consistency examples client = self.client - self.addAsyncCleanup(client.drop_database, "test") - await client.test.drop_collection("items") - await client.test.items.insert_one( + self.addAsyncCleanup(client.drop_database, "db") + await client.db.drop_collection("items") + await client.db.items.insert_one( {"sku": "111", "name": "Peanuts", "start": datetime.datetime.today()} ) @@ -1175,7 +1175,7 @@ async def test_causal_consistency(self): async with client.start_session(causal_consistency=True) as s1: current_date = datetime.datetime.today() items = client.get_database( - "test", + "db", read_concern=ReadConcern("majority"), write_concern=WriteConcern("majority", wtimeout=1000), ).items @@ -1196,7 +1196,7 @@ async def test_causal_consistency(self): s2.advance_operation_time(s1.operation_time) items = client.get_database( - "test", + "db", read_preference=ReadPreference.SECONDARY, read_concern=ReadConcern("majority"), write_concern=WriteConcern("majority", wtimeout=1000), diff --git a/test/asynchronous/test_grid_file.py b/test/asynchronous/test_grid_file.py index f3ca596142..6d62ca74bb 100644 --- a/test/asynchronous/test_grid_file.py +++ b/test/asynchronous/test_grid_file.py @@ -61,7 +61,7 @@ class AsyncTestGridFileNoConnect(AsyncUnitTest): @classmethod def setUpClass(cls): - cls.db = AsyncMongoClient(connect=False).pymongo_test + cls.db = AsyncMongoClient(connect=False).db def test_grid_in_custom_opts(self): self.assertRaises(TypeError, AsyncGridIn, "foo") @@ -804,7 +804,7 @@ async def test_grid_in_lazy_connect(self): async def test_unacknowledged(self): # w=0 is prohibited. with self.assertRaises(ConfigurationError): - AsyncGridIn((await self.async_rs_or_single_client(w=0)).pymongo_test.fs) + AsyncGridIn((await self.async_rs_or_single_client(w=0)).db.fs) async def test_survive_cursor_not_found(self): # By default the find command returns 101 documents in the first batch. @@ -813,7 +813,7 @@ async def test_survive_cursor_not_found(self): data = b"d" * (102 * chunk_size) listener = OvertCommandListener() client = await self.async_rs_or_single_client(event_listeners=[listener]) - db = client.pymongo_test + db = client.db async with AsyncGridIn(db.fs, chunk_size=chunk_size) as infile: await infile.write(data) diff --git a/test/asynchronous/test_gridfs.py b/test/asynchronous/test_gridfs.py index f60352f3cb..054d323362 100644 --- a/test/asynchronous/test_gridfs.py +++ b/test/asynchronous/test_gridfs.py @@ -82,7 +82,7 @@ class TestGridfsNoConnect(unittest.IsolatedAsyncioTestCase): async def asyncSetUp(self): await super().asyncSetUp() - self.db = AsyncMongoClient(connect=False).pymongo_test + self.db = AsyncMongoClient(connect=False).db async def test_gridfs(self): self.assertRaises(TypeError, gridfs.AsyncGridFS, "foo") @@ -527,7 +527,7 @@ async def test_grid_in_non_int_chunksize(self): async def test_unacknowledged(self): # w=0 is prohibited. with self.assertRaises(ConfigurationError): - gridfs.AsyncGridFS((await self.async_rs_or_single_client(w=0)).pymongo_test) + gridfs.AsyncGridFS((await self.async_rs_or_single_client(w=0)).db) async def test_md5(self): gin = self.fs.new_file() diff --git a/test/asynchronous/test_gridfs_bucket.py b/test/asynchronous/test_gridfs_bucket.py index fd9b9883bf..210a84dad2 100644 --- a/test/asynchronous/test_gridfs_bucket.py +++ b/test/asynchronous/test_gridfs_bucket.py @@ -433,7 +433,7 @@ async def test_grid_in_non_int_chunksize(self): async def test_unacknowledged(self): # w=0 is prohibited. with self.assertRaises(ConfigurationError): - gridfs.AsyncGridFSBucket((await self.async_rs_or_single_client(w=0)).pymongo_test) + gridfs.AsyncGridFSBucket((await self.async_rs_or_single_client(w=0)).db) async def test_rename(self): _id = await self.fs.upload_from_stream("first_name", b"testing") diff --git a/test/asynchronous/test_index_management.py b/test/asynchronous/test_index_management.py index 45a207885b..3a46162c15 100644 --- a/test/asynchronous/test_index_management.py +++ b/test/asynchronous/test_index_management.py @@ -47,7 +47,7 @@ class TestCreateSearchIndex(AsyncIntegrationTest): async def test_inputs(self): listener = AllowListEventListener("createSearchIndexes") client = self.simple_client(event_listeners=[listener]) - coll = client.test.test + coll = client.db.coll await coll.drop() definition = dict(mappings=dict(dynamic=True)) model_kwarg_list: list[Mapping[str, Any]] = [ diff --git a/test/asynchronous/test_json_util_integration.py b/test/asynchronous/test_json_util_integration.py index 32312cb9d3..818226f467 100644 --- a/test/asynchronous/test_json_util_integration.py +++ b/test/asynchronous/test_json_util_integration.py @@ -13,7 +13,7 @@ class TestJsonUtilRoundtrip(AsyncIntegrationTest): async def test_cursor(self): db = self.db - await db.drop_collection("test") + await db.drop_collection("coll") docs: List[MutableMapping[str, Any]] = [ {"foo": [1, 2]}, {"bar": {"hello": "world"}}, @@ -22,7 +22,7 @@ async def test_cursor(self): {"dbref": {"_ref": DBRef("simple", ObjectId("509b8db456c02c5ab7e63c34"))}}, ] - await db.test.insert_many(docs) - reloaded_docs = json_util.loads(json_util.dumps(await (db.test.find()).to_list())) + await db.coll.insert_many(docs) + reloaded_docs = json_util.loads(json_util.dumps(await (db.coll.find()).to_list())) for doc in docs: self.assertIn(doc, reloaded_docs) diff --git a/test/asynchronous/test_load_balancer.py b/test/asynchronous/test_load_balancer.py index 5b1cf63c1d..941f7bc792 100644 --- a/test/asynchronous/test_load_balancer.py +++ b/test/asynchronous/test_load_balancer.py @@ -52,12 +52,12 @@ class TestLB(AsyncIntegrationTest): async def test_connections_are_only_returned_once(self): pool = await async_get_pool(self.client) n_conns = len(pool.conns) - await self.db.test.find_one({}) + await self.db.coll.find_one({}) # On PyPy it can take a few rounds to collect the cursor. for _ in range(3): gc.collect() self.assertEqual(len(pool.conns), n_conns) - await (await self.db.test.aggregate([{"$limit": 1}])).to_list() + await (await self.db.coll.aggregate([{"$limit": 1}])).to_list() # On PyPy it can take a few rounds to collect the cursor. for _ in range(3): gc.collect() @@ -67,7 +67,7 @@ async def test_connections_are_only_returned_once(self): async def test_unpin_committed_transaction(self): client = await self.async_rs_client() pool = await async_get_pool(client) - coll = client[self.db.name].test + coll = client[self.db.name].coll async with client.start_session() as session: async with await session.start_transaction(): self.assertEqual(pool.active_sockets, 0) @@ -97,7 +97,7 @@ async def create_resource(coll): async def _test_no_gc_deadlock(self, create_resource): client = await self.async_rs_client() pool = await async_get_pool(client) - coll = client[self.db.name].test + coll = client[self.db.name].coll await coll.insert_many([{} for _ in range(10)]) self.assertEqual(pool.active_sockets, 0) # Cause the initial find attempt to fail to induce a reference cycle. @@ -137,7 +137,7 @@ async def test_session_gc(self): pool = await async_get_pool(client) session = client.start_session() await session.start_transaction() - await client.test_session_gc.test.find_one({}, session=session) + await client.test_session_gc.coll.find_one({}, session=session) # Cleanup the transaction left open on the server self.addAsyncCleanup(self.client.admin.command, "killSessions", [session.session_id]) if async_client_context.load_balancer: @@ -159,7 +159,7 @@ async def test_session_gc(self): await async_wait_until(lambda: pool.active_sockets == 0, "return socket") # Run another operation to ensure the socket still works. - await client[self.db.name].test.delete_many({}) + await client[self.db.name].coll.delete_many({}) class PoolLocker(ExceptionCatchingTask): diff --git a/test/asynchronous/test_logger.py b/test/asynchronous/test_logger.py index d024735fd8..c4b2fb8f8a 100644 --- a/test/asynchronous/test_logger.py +++ b/test/asynchronous/test_logger.py @@ -34,7 +34,7 @@ async def test_default_truncation_limit(self): with patch.dict("os.environ"): os.environ.pop("MONGOB_LOG_MAX_DOCUMENT_LENGTH", None) with self.assertLogs("pymongo.command", level="DEBUG") as cm: - await db.test.insert_many(docs) + await db.coll.insert_many(docs) cmd_started_log = json_util.loads(cm.records[0].getMessage()) self.assertEqual(len(cmd_started_log["command"]), _DEFAULT_DOCUMENT_LENGTH + 3) @@ -43,7 +43,7 @@ async def test_default_truncation_limit(self): self.assertLessEqual(len(cmd_succeeded_log["reply"]), _DEFAULT_DOCUMENT_LENGTH + 3) with self.assertLogs("pymongo.command", level="DEBUG") as cm: - await db.test.find({}).to_list() + await db.coll.find({}).to_list() cmd_succeeded_log = json_util.loads(cm.records[1].getMessage()) self.assertEqual(len(cmd_succeeded_log["reply"]), _DEFAULT_DOCUMENT_LENGTH + 3) @@ -76,7 +76,7 @@ async def test_truncation_multi_byte_codepoints(self): for length in document_lengths: with patch.dict("os.environ", {"MONGOB_LOG_MAX_DOCUMENT_LENGTH": length}): with self.assertLogs("pymongo.command", level="DEBUG") as cm: - await self.db.test.insert_one({"x": multi_byte_char_str}) + await self.db.coll.insert_one({"x": multi_byte_char_str}) cmd_started_log = json_util.loads(cm.records[0].getMessage())["command"] cmd_started_log = cmd_started_log[:-3] @@ -88,18 +88,18 @@ async def test_logging_without_listeners(self): c = await self.async_single_client() self.assertEqual(len(c._event_listeners.event_listeners()), 0) with self.assertLogs("pymongo.connection", level="DEBUG") as cm: - await c.db.test.insert_one({"x": "1"}) + await c.db.coll.insert_one({"x": "1"}) self.assertGreater(len(cm.records), 0) with self.assertLogs("pymongo.command", level="DEBUG") as cm: - await c.db.test.insert_one({"x": "1"}) + await c.db.coll.insert_one({"x": "1"}) self.assertGreater(len(cm.records), 0) with self.assertLogs("pymongo.serverSelection", level="DEBUG") as cm: - await c.db.test.insert_one({"x": "1"}) + await c.db.coll.insert_one({"x": "1"}) self.assertGreater(len(cm.records), 0) @async_client_context.require_failCommand_fail_point async def test_logging_retry_read_attempts(self): - await self.db.test.insert_one({"x": "1"}) + await self.db.coll.insert_one({"x": "1"}) async with self.fail_point( { @@ -112,7 +112,7 @@ async def test_logging_retry_read_attempts(self): } ): with self.assertLogs("pymongo.command", level="DEBUG") as cm: - await self.db.test.find_one({"x": "1"}) + await self.db.coll.find_one({"x": "1"}) retry_messages = [ r.getMessage() for r in cm.records if "Retrying read attempt" in r.getMessage() @@ -133,7 +133,7 @@ async def test_logging_retry_write_attempts(self): } ): with self.assertLogs("pymongo.command", level="DEBUG") as cm: - await self.db.test.insert_one({"x": "1"}) + await self.db.coll.insert_one({"x": "1"}) retry_messages = [ r.getMessage() for r in cm.records if "Retrying write attempt" in r.getMessage() diff --git a/test/asynchronous/test_max_staleness.py b/test/asynchronous/test_max_staleness.py index b6e15f9158..ef7c3ce1fd 100644 --- a/test/asynchronous/test_max_staleness.py +++ b/test/asynchronous/test_max_staleness.py @@ -124,7 +124,7 @@ async def test_max_staleness_zero(self): async def test_last_write_date(self): # From max-staleness-tests.rst, "Parse lastWriteDate". client = await self.async_rs_or_single_client(heartbeatFrequencyMS=500) - await client.pymongo_test.test.insert_one({}) + await client.db.coll.insert_one({}) # Wait for the server description to be updated. await asyncio.sleep(1) server = await client._topology.select_server(writable_server_selector, _Op.TEST) @@ -133,7 +133,7 @@ async def test_last_write_date(self): # The first last_write_date may correspond to a internal server write, # sleep so that the next write does not occur within the same second. await asyncio.sleep(1) - await client.pymongo_test.test.insert_one({}) + await client.db.coll.insert_one({}) # Wait for the server description to be updated. await asyncio.sleep(1) server = await client._topology.select_server(writable_server_selector, _Op.TEST) diff --git a/test/asynchronous/test_monitoring.py b/test/asynchronous/test_monitoring.py index 9b2a3691eb..1cbc302dcf 100644 --- a/test/asynchronous/test_monitoring.py +++ b/test/asynchronous/test_monitoring.py @@ -64,7 +64,7 @@ async def asyncSetUp(self) -> None: ) async def test_started_simple(self): - await self.client.pymongo_test.command("ping") + await self.client.db.command("ping") started = self.listener.started_events[0] succeeded = self.listener.succeeded_events[0] self.assertEqual(0, len(self.listener.failed_events)) @@ -73,11 +73,11 @@ async def test_started_simple(self): self.assertEqualCommand(SON([("ping", 1)]), started.command) self.assertEqual("ping", started.command_name) self.assertEqual(await self.client.address, started.connection_id) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertIsInstance(started.request_id, int) async def test_succeeded_simple(self): - await self.client.pymongo_test.command("ping") + await self.client.db.command("ping") started = self.listener.started_events[0] succeeded = self.listener.succeeded_events[0] self.assertEqual(0, len(self.listener.failed_events)) @@ -91,7 +91,7 @@ async def test_succeeded_simple(self): async def test_failed_simple(self): try: - await self.client.pymongo_test.command("oops!") + await self.client.db.command("oops!") except OperationFailure: pass started = self.listener.started_events[0] @@ -106,7 +106,7 @@ async def test_failed_simple(self): self.assertIsInstance(failed.duration_micros, int) async def test_find_one(self): - await self.client.pymongo_test.test.find_one() + await self.client.db.coll.find_one() started = self.listener.started_events[0] succeeded = self.listener.succeeded_events[0] self.assertEqual(0, len(self.listener.failed_events)) @@ -118,14 +118,14 @@ async def test_find_one(self): ) self.assertEqual("find", started.command_name) self.assertEqual(await self.client.address, started.connection_id) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertIsInstance(started.request_id, int) async def test_find_and_get_more(self): - await self.client.pymongo_test.test.drop() - await self.client.pymongo_test.test.insert_many([{} for _ in range(10)]) + await self.client.db.coll.drop() + await self.client.db.coll.insert_many([{} for _ in range(10)]) self.listener.reset() - cursor = self.client.pymongo_test.test.find(projection={"_id": False}, batch_size=4) + cursor = self.client.db.coll.find(projection={"_id": False}, batch_size=4) for _ in range(4): await anext(cursor) cursor_id = cursor.cursor_id @@ -141,7 +141,7 @@ async def test_find_and_get_more(self): ) self.assertEqual("find", started.command_name) self.assertEqual(await self.client.address, started.connection_id) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertIsInstance(started.request_id, int) self.assertIsInstance(succeeded, monitoring.CommandSucceededEvent) self.assertIsInstance(succeeded.duration_micros, int) @@ -150,7 +150,7 @@ async def test_find_and_get_more(self): self.assertEqual(cursor.address, succeeded.connection_id) csr = succeeded.reply["cursor"] self.assertEqual(csr["id"], cursor_id) - self.assertEqual(csr["ns"], "pymongo_test.test") + self.assertEqual(csr["ns"], "db.coll") self.assertEqual(csr["firstBatch"], [{} for _ in range(4)]) self.listener.reset() @@ -163,12 +163,12 @@ async def test_find_and_get_more(self): self.assertEqual(0, len(self.listener.failed_events)) self.assertIsInstance(started, monitoring.CommandStartedEvent) self.assertEqualCommand( - SON([("getMore", cursor_id), ("collection", "test"), ("batchSize", 4)]), + SON([("getMore", cursor_id), ("collection", "db.coll"), ("batchSize", 4)]), started.command, ) self.assertEqual("getMore", started.command_name) self.assertEqual(await self.client.address, started.connection_id) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertIsInstance(started.request_id, int) self.assertIsInstance(succeeded, monitoring.CommandSucceededEvent) self.assertIsInstance(succeeded.duration_micros, int) @@ -177,7 +177,7 @@ async def test_find_and_get_more(self): self.assertEqual(cursor.address, succeeded.connection_id) csr = succeeded.reply["cursor"] self.assertEqual(csr["id"], cursor_id) - self.assertEqual(csr["ns"], "pymongo_test.test") + self.assertEqual(csr["ns"], "db.coll") self.assertEqual(csr["nextBatch"], [{} for _ in range(4)]) finally: # Exhaust the cursor to avoid kill cursors. @@ -185,10 +185,10 @@ async def test_find_and_get_more(self): async def test_find_with_explain(self): cmd = SON([("explain", SON([("find", "test"), ("filter", {})]))]) - await self.client.pymongo_test.test.drop() - await self.client.pymongo_test.test.insert_one({}) + await self.client.db.coll.drop() + await self.client.db.coll.insert_one({}) self.listener.reset() - coll = self.client.pymongo_test.test + coll = self.client.db.coll # Test that we publish the unwrapped command. if await self.client.is_mongos: coll = coll.with_options(read_preference=ReadPreference.PRIMARY_PREFERRED) @@ -200,7 +200,7 @@ async def test_find_with_explain(self): self.assertEqualCommand(cmd, started.command) self.assertEqual("explain", started.command_name) self.assertEqual(await self.client.address, started.connection_id) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertIsInstance(started.request_id, int) self.assertIsInstance(succeeded, monitoring.CommandSucceededEvent) self.assertIsInstance(succeeded.duration_micros, int) @@ -210,7 +210,7 @@ async def test_find_with_explain(self): self.assertEqual(res, succeeded.reply) async def _test_find_options(self, query, expected_cmd): - coll = self.client.pymongo_test.test + coll = self.client.db.coll await coll.drop() await coll.create_index("x") await coll.insert_many([{"x": i} for i in range(5)]) @@ -231,7 +231,7 @@ async def _test_find_options(self, query, expected_cmd): self.assertEqualCommand(expected_cmd, started.command) self.assertEqual("find", started.command_name) self.assertEqual(await self.client.address, started.connection_id) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertIsInstance(started.request_id, int) self.assertIsInstance(succeeded, monitoring.CommandSucceededEvent) self.assertIsInstance(succeeded.duration_micros, int) @@ -294,10 +294,10 @@ async def test_find_snapshot(self): await self._test_find_options(query, cmd) async def test_command_and_get_more(self): - await self.client.pymongo_test.test.drop() - await self.client.pymongo_test.test.insert_many([{"x": 1} for _ in range(10)]) + await self.client.db.coll.drop() + await self.client.db.coll.insert_many([{"x": 1} for _ in range(10)]) self.listener.reset() - coll = self.client.pymongo_test.test + coll = self.client.db.coll # Test that we publish the unwrapped command. if await self.client.is_mongos: coll = coll.with_options(read_preference=ReadPreference.PRIMARY_PREFERRED) @@ -321,7 +321,7 @@ async def test_command_and_get_more(self): ) self.assertEqual("aggregate", started.command_name) self.assertEqual(await self.client.address, started.connection_id) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertIsInstance(started.request_id, int) self.assertIsInstance(succeeded, monitoring.CommandSucceededEvent) self.assertIsInstance(succeeded.duration_micros, int) @@ -330,7 +330,7 @@ async def test_command_and_get_more(self): self.assertEqual(cursor.address, succeeded.connection_id) expected_cursor = { "id": cursor_id, - "ns": "pymongo_test.test", + "ns": "db.coll", "firstBatch": [{"x": 1} for _ in range(4)], } self.assertEqualCommand(expected_cursor, succeeded.reply.get("cursor")) @@ -343,12 +343,12 @@ async def test_command_and_get_more(self): self.assertEqual(0, len(self.listener.failed_events)) self.assertIsInstance(started, monitoring.CommandStartedEvent) self.assertEqualCommand( - SON([("getMore", cursor_id), ("collection", "test"), ("batchSize", 4)]), + SON([("getMore", cursor_id), ("collection", "db.coll"), ("batchSize", 4)]), started.command, ) self.assertEqual("getMore", started.command_name) self.assertEqual(await self.client.address, started.connection_id) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertIsInstance(started.request_id, int) self.assertIsInstance(succeeded, monitoring.CommandSucceededEvent) self.assertIsInstance(succeeded.duration_micros, int) @@ -358,7 +358,7 @@ async def test_command_and_get_more(self): expected_result = { "cursor": { "id": cursor_id, - "ns": "pymongo_test.test", + "ns": "db.coll", "nextBatch": [{"x": 1} for _ in range(4)], }, "ok": 1.0, @@ -370,7 +370,7 @@ async def test_command_and_get_more(self): async def test_get_more_failure(self): address = await self.client.address - coll = self.client.pymongo_test.test + coll = self.client.db.coll cursor_id = Int64(12345) cursor_doc = {"id": cursor_id, "firstBatch": [], "ns": coll.full_name} cursor = AsyncCommandCursor(coll, cursor_doc, address) @@ -383,11 +383,11 @@ async def test_get_more_failure(self): failed = self.listener.failed_events[0] self.assertIsInstance(started, monitoring.CommandStartedEvent) self.assertEqualCommand( - SON([("getMore", cursor_id), ("collection", "test")]), started.command + SON([("getMore", cursor_id), ("collection", "db.coll")]), started.command ) self.assertEqual("getMore", started.command_name) self.assertEqual(await self.client.address, started.connection_id) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertIsInstance(started.request_id, int) self.assertIsInstance(failed, monitoring.CommandFailedEvent) self.assertIsInstance(failed.duration_micros, int) @@ -406,7 +406,7 @@ async def test_not_primary_error(self): self.listener.reset() error = None try: - await client.pymongo_test.test.find_one_and_delete({}) + await client.db.coll.find_one_and_delete({}) except NotPrimaryError as exc: error = exc.errors started = self.listener.started_events[0] @@ -423,10 +423,10 @@ async def test_not_primary_error(self): @async_client_context.require_no_mongos async def test_exhaust(self): - await self.client.pymongo_test.test.drop() - await self.client.pymongo_test.test.insert_many([{} for _ in range(11)]) + await self.client.db.coll.drop() + await self.client.db.coll.insert_many([{} for _ in range(11)]) self.listener.reset() - cursor = self.client.pymongo_test.test.find( + cursor = self.client.db.coll.find( projection={"_id": False}, batch_size=5, cursor_type=CursorType.EXHAUST ) await anext(cursor) @@ -443,7 +443,7 @@ async def test_exhaust(self): ) self.assertEqual("find", started.command_name) self.assertEqual(cursor.address, started.connection_id) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertIsInstance(started.request_id, int) self.assertIsInstance(succeeded, monitoring.CommandSucceededEvent) self.assertIsInstance(succeeded.duration_micros, int) @@ -453,7 +453,7 @@ async def test_exhaust(self): expected_result = { "cursor": { "id": cursor_id, - "ns": "pymongo_test.test", + "ns": "db.coll", "firstBatch": [{} for _ in range(5)], }, "ok": 1, @@ -466,12 +466,12 @@ async def test_exhaust(self): for event in self.listener.started_events: self.assertIsInstance(event, monitoring.CommandStartedEvent) self.assertEqualCommand( - SON([("getMore", cursor_id), ("collection", "test"), ("batchSize", 5)]), + SON([("getMore", cursor_id), ("collection", "db.coll"), ("batchSize", 5)]), event.command, ) self.assertEqual("getMore", event.command_name) self.assertEqual(cursor.address, event.connection_id) - self.assertEqual("pymongo_test", event.database_name) + self.assertEqual("db", event.database_name) self.assertIsInstance(event.request_id, int) for event in self.listener.succeeded_events: self.assertIsInstance(event, monitoring.CommandSucceededEvent) @@ -484,9 +484,9 @@ async def test_exhaust(self): async def test_kill_cursors(self): with client_knobs(kill_cursor_frequency=0.01): - await self.client.pymongo_test.test.drop() - await self.client.pymongo_test.test.insert_many([{} for _ in range(10)]) - cursor = self.client.pymongo_test.test.find().batch_size(5) + await self.client.db.coll.drop() + await self.client.db.coll.insert_many([{} for _ in range(10)]) + cursor = self.client.db.coll.find().batch_size(5) await anext(cursor) cursor_id = cursor.cursor_id self.listener.reset() @@ -502,7 +502,7 @@ async def test_kill_cursors(self): self.assertEqual("killCursors", started.command_name) self.assertIs(type(started.connection_id), tuple) self.assertEqual(cursor.address, started.connection_id) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertIsInstance(started.request_id, int) self.assertIsInstance(succeeded, monitoring.CommandSucceededEvent) self.assertIsInstance(succeeded.duration_micros, int) @@ -517,7 +517,7 @@ async def test_kill_cursors(self): ) async def test_non_bulk_writes(self): - coll = self.client.pymongo_test.test + coll = self.client.db.coll await coll.drop() self.listener.reset() @@ -535,7 +535,7 @@ async def test_non_bulk_writes(self): ] ) self.assertEqualCommand(expected, started.command) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertEqual("insert", started.command_name) self.assertIsInstance(started.request_id, int) self.assertEqual(await self.client.address, started.connection_id) @@ -565,7 +565,7 @@ async def test_non_bulk_writes(self): ] ) self.assertEqualCommand(expected, started.command) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertEqual("insert", started.command_name) self.assertIsInstance(started.request_id, int) self.assertEqual(await self.client.address, started.connection_id) @@ -593,7 +593,7 @@ async def test_non_bulk_writes(self): ] ) self.assertEqualCommand(expected, started.command) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertEqual("insert", started.command_name) self.assertIsInstance(started.request_id, int) self.assertEqual(await self.client.address, started.connection_id) @@ -622,7 +622,7 @@ async def test_non_bulk_writes(self): ] ) self.assertEqualCommand(expected, started.command) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertEqual("delete", started.command_name) self.assertIsInstance(started.request_id, int) self.assertEqual(await self.client.address, started.connection_id) @@ -664,7 +664,7 @@ async def test_non_bulk_writes(self): ] ) self.assertEqualCommand(expected, started.command) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertEqual("update", started.command_name) self.assertIsInstance(started.request_id, int) self.assertEqual(await self.client.address, started.connection_id) @@ -706,7 +706,7 @@ async def test_non_bulk_writes(self): ] ) self.assertEqualCommand(expected, started.command) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertEqual("update", started.command_name) self.assertIsInstance(started.request_id, int) self.assertEqual(await self.client.address, started.connection_id) @@ -747,7 +747,7 @@ async def test_non_bulk_writes(self): ] ) self.assertEqualCommand(expected, started.command) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertEqual("update", started.command_name) self.assertIsInstance(started.request_id, int) self.assertEqual(await self.client.address, started.connection_id) @@ -776,7 +776,7 @@ async def test_non_bulk_writes(self): ] ) self.assertEqualCommand(expected, started.command) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertEqual("delete", started.command_name) self.assertIsInstance(started.request_id, int) self.assertEqual(await self.client.address, started.connection_id) @@ -811,7 +811,7 @@ async def test_non_bulk_writes(self): ] ) self.assertEqualCommand(expected, started.command) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertEqual("insert", started.command_name) self.assertIsInstance(started.request_id, int) self.assertEqual(await self.client.address, started.connection_id) @@ -832,7 +832,7 @@ async def test_non_bulk_writes(self): async def test_insert_many(self): # This always uses the bulk API. - coll = self.client.pymongo_test.test + coll = self.client.db.coll await coll.drop() self.listener.reset() @@ -853,7 +853,7 @@ async def test_insert_many(self): self.assertEqual(coll.name, cmd["insert"]) self.assertIs(True, cmd["ordered"]) documents.extend(cmd["documents"]) - self.assertEqual("pymongo_test", start.database_name) + self.assertEqual("db", start.database_name) self.assertEqual("insert", start.command_name) self.assertIsInstance(start.request_id, int) self.assertEqual(await self.client.address, start.connection_id) @@ -871,7 +871,7 @@ async def test_insert_many(self): self.assertEqual(6, count) async def test_insert_many_unacknowledged(self): - coll = self.client.pymongo_test.test + coll = self.client.db.coll await coll.drop() unack_coll = coll.with_options(write_concern=WriteConcern(w=0)) self.listener.reset() @@ -894,7 +894,7 @@ async def test_insert_many_unacknowledged(self): self.assertEqual(coll.name, cmd["insert"]) self.assertIs(True, cmd["ordered"]) documents.extend(cmd["documents"]) - self.assertEqual("pymongo_test", start.database_name) + self.assertEqual("db", start.database_name) self.assertEqual("insert", start.command_name) self.assertIsInstance(start.request_id, int) self.assertEqual(await self.client.address, start.connection_id) @@ -914,7 +914,7 @@ async def check(): await async_wait_until(check, "insert documents with w=0") async def test_bulk_write(self): - coll = self.client.pymongo_test.test + coll = self.client.db.coll await coll.drop() self.listener.reset() @@ -933,7 +933,7 @@ async def test_bulk_write(self): self.assertEqual(3, len(pairs)) for start, succeed in pairs: self.assertIsInstance(start, monitoring.CommandStartedEvent) - self.assertEqual("pymongo_test", start.database_name) + self.assertEqual("db", start.database_name) self.assertIsInstance(start.request_id, int) self.assertEqual(await self.client.address, start.connection_id) self.assertIsInstance(succeed, monitoring.CommandSucceededEvent) @@ -977,7 +977,7 @@ async def test_bulk_write(self): @async_client_context.require_failCommand_fail_point async def test_bulk_write_command_network_error(self): - coll = self.client.pymongo_test.test + coll = self.client.db.coll self.listener.reset() insert_network_error = { @@ -1001,7 +1001,7 @@ async def test_bulk_write_command_network_error(self): @async_client_context.require_failCommand_fail_point async def test_bulk_write_command_error(self): - coll = self.client.pymongo_test.test + coll = self.client.db.coll self.listener.reset() insert_command_error = { @@ -1025,7 +1025,7 @@ async def test_bulk_write_command_error(self): self.assertTrue(event.failure["errmsg"]) async def test_write_errors(self): - coll = self.client.pymongo_test.test + coll = self.client.db.coll await coll.drop() self.listener.reset() @@ -1049,7 +1049,7 @@ async def test_write_errors(self): errors = [] for start, succeed in pairs: self.assertIsInstance(start, monitoring.CommandStartedEvent) - self.assertEqual("pymongo_test", start.database_name) + self.assertEqual("db", start.database_name) self.assertIsInstance(start.request_id, int) self.assertEqual(await self.client.address, start.connection_id) self.assertIsInstance(succeed, monitoring.CommandSucceededEvent) @@ -1071,14 +1071,14 @@ async def test_first_batch_helper(self): # Regardless of server version and use of helpers._first_batch # this test should still pass. self.listener.reset() - tuple(await (await self.client.pymongo_test.test.list_indexes()).to_list()) + tuple(await (await self.client.db.coll.list_indexes()).to_list()) started = self.listener.started_events[0] succeeded = self.listener.succeeded_events[0] self.assertEqual(0, len(self.listener.failed_events)) self.assertIsInstance(started, monitoring.CommandStartedEvent) expected = SON([("listIndexes", "test"), ("cursor", {})]) self.assertEqualCommand(expected, started.command) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertEqual("listIndexes", started.command_name) self.assertIsInstance(started.request_id, int) self.assertEqual(await self.client.address, started.connection_id) @@ -1100,7 +1100,7 @@ async def test_sensitive_commands(self): listener.reset() cmd = SON([("getnonce", 1)]) - listeners.publish_command_start(cmd, "pymongo_test", 12345, await client.address, None) # type: ignore[arg-type] + listeners.publish_command_start(cmd, "db", 12345, await client.address, None) # type: ignore[arg-type] delta = datetime.timedelta(milliseconds=100) listeners.publish_command_success( delta, @@ -1109,14 +1109,14 @@ async def test_sensitive_commands(self): 12345, await self.client.address, # type: ignore[arg-type] None, - database_name="pymongo_test", + database_name="db", ) started = listener.started_events[0] succeeded = listener.succeeded_events[0] self.assertEqual(0, len(listener.failed_events)) self.assertIsInstance(started, monitoring.CommandStartedEvent) self.assertEqual({}, started.command) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertEqual("getnonce", started.command_name) self.assertIsInstance(started.request_id, int) self.assertEqual(await client.address, started.connection_id) @@ -1145,14 +1145,14 @@ async def asyncSetUp(self): self.listener.reset() self.client = await self.async_single_client() # Get one (authenticated) socket in the pool. - await self.client.pymongo_test.command("ping") + await self.client.db.command("ping") @classmethod def tearDownClass(cls): monitoring._LISTENERS = cls.saved_listeners async def test_simple(self): - await self.client.pymongo_test.command("ping") + await self.client.db.command("ping") started = self.listener.started_events[0] succeeded = self.listener.succeeded_events[0] self.assertEqual(0, len(self.listener.failed_events)) @@ -1161,7 +1161,7 @@ async def test_simple(self): self.assertEqualCommand(SON([("ping", 1)]), started.command) self.assertEqual("ping", started.command_name) self.assertEqual(await self.client.address, started.connection_id) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertIsInstance(started.request_id, int) diff --git a/test/asynchronous/test_pooling.py b/test/asynchronous/test_pooling.py index 92a88a56c2..2e1a430ba1 100644 --- a/test/asynchronous/test_pooling.py +++ b/test/asynchronous/test_pooling.py @@ -160,9 +160,9 @@ async def asyncSetUp(self): self.c = await self.async_rs_or_single_client() db = self.c[DB] await db.unique.drop() - await db.test.drop() + await db.coll.drop() await db.unique.insert_one({"_id": "jesse"}) - await db.test.insert_many([{} for _ in range(10)]) + await db.coll.insert_many([{} for _ in range(10)]) async def create_pool(self, pair=None, *args, **kwargs): if pair is None: @@ -396,14 +396,14 @@ async def test_checkout_more_than_max_pool_size(self): async def test_maxConnecting(self): client = await self.async_rs_or_single_client() - await self.client.test.test.insert_one({}) - self.addAsyncCleanup(self.client.test.test.delete_many, {}) + await self.client.db.coll.insert_one({}) + self.addAsyncCleanup(self.client.db.coll.delete_many, {}) pool = await async_get_pool(client) docs = [] # Run 50 short running operations async def find_one(): - docs.append(await client.test.test.find_one({})) + docs.append(await client.db.coll.find_one({})) tasks = [ConcurrentRunner(target=find_one) for _ in range(50)] for task in tasks: @@ -444,12 +444,12 @@ async def test_csot_timeout_message(self): }, } - await client.db.t.insert_one({"x": 1}) + await client.db.coll.insert_one({"x": 1}) async with self.fail_point(mock_connection_timeout): with self.assertRaises(Exception) as error: with timeout(0.5): - await client.db.t.find_one({"$where": delay(2)}) + await client.db.coll.find_one({"$where": delay(2)}) self.assertIn("(configured timeouts: timeoutMS: 500.0ms", str(error.exception)) @@ -470,11 +470,11 @@ async def test_socket_timeout_message(self): }, } - await client.db.t.insert_one({"x": 1}) + await client.db.coll.insert_one({"x": 1}) async with self.fail_point(mock_connection_timeout): with self.assertRaises(Exception) as error: - await client.db.t.find_one({"$where": delay(2)}) + await client.db.coll.find_one({"$where": delay(2)}) self.assertIn( "(configured timeouts: socketTimeoutMS: 500.0ms, connectTimeoutMS: 20000.0ms)", @@ -516,7 +516,7 @@ async def test_connection_timeout_message(self): @async_client_context.require_failCommand_appName async def test_pool_backpressure_preserves_existing_connections(self): client = await self.async_rs_or_single_client() - coll = client.pymongo_test.t + coll = client.db.coll pool = await async_get_pool(client) await coll.insert_many([{"x": 1} for _ in range(10)]) t = SocketGetter(self.c, pool) @@ -555,7 +555,7 @@ class TestPoolMaxSize(_TestPoolingBase): async def test_max_pool_size(self): max_pool_size = 4 c = await self.async_rs_or_single_client(maxPoolSize=max_pool_size) - collection = c[DB].test + collection = c[DB].coll # Need one document. await collection.drop() @@ -594,7 +594,7 @@ async def f(): ) async def test_max_pool_size_none(self): c = await self.async_rs_or_single_client(maxPoolSize=None) - collection = c[DB].test + collection = c[DB].coll # Need one document. await collection.drop() diff --git a/test/asynchronous/test_raw_bson.py b/test/asynchronous/test_raw_bson.py index 70832ea668..ce9a2608d0 100644 --- a/test/asynchronous/test_raw_bson.py +++ b/test/asynchronous/test_raw_bson.py @@ -44,7 +44,7 @@ class TestRawBSONDocument(AsyncIntegrationTest): async def asyncTearDown(self): if async_client_context.connected: - await self.client.pymongo_test.test_raw.drop() + await self.db.coll.drop() def test_decode(self): self.assertEqual("Sherlock", self.document["name"]) @@ -73,17 +73,17 @@ def test_invalid_bson_eoo(self): @async_client_context.require_connection async def test_round_trip(self): db = self.client.get_database( - "pymongo_test", codec_options=CodecOptions(document_class=RawBSONDocument) + "db", codec_options=CodecOptions(document_class=RawBSONDocument) ) - await db.test_raw.insert_one(self.document) - result = await db.test_raw.find_one(self.document["_id"]) + await db.coll.insert_one(self.document) + result = await db.coll.find_one(self.document["_id"]) assert result is not None self.assertIsInstance(result, RawBSONDocument) self.assertEqual(dict(self.document.items()), dict(result.items())) @async_client_context.require_connection async def test_round_trip_raw_uuid(self): - coll = self.client.get_database("pymongo_test").test_raw + coll = self.client.get_database("db").test_raw uid = uuid.uuid4() doc = {"_id": 1, "bin4": Binary(uid.bytes, 4), "bin3": Binary(uid.bytes, 3)} raw = RawBSONDocument(encode(doc)) @@ -126,7 +126,7 @@ async def test_round_trip_codec_options(self): "date": datetime.datetime(2015, 6, 3, 18, 40, 50, 826000), "_id": uuid.UUID("026fab8f-975f-4965-9fbf-85ad874c60ff"), } - db = self.client.pymongo_test + db = self.client.db coll = db.get_collection( "test_raw", codec_options=CodecOptions(uuid_representation=JAVA_LEGACY) ) @@ -142,9 +142,9 @@ async def test_round_trip_codec_options(self): @async_client_context.require_connection async def test_raw_bson_document_embedded(self): doc = {"embedded": self.document} - db = self.client.pymongo_test - await db.test_raw.insert_one(doc) - result = await db.test_raw.find_one() + db = self.client.db + await db.coll.insert_one(doc) + result = await db.coll.find_one() assert result is not None self.assertEqual(decode(self.document.raw), result["embedded"]) @@ -167,8 +167,8 @@ async def test_raw_bson_document_embedded(self): ), ) - await db.test_raw.drop() - await db.test_raw.insert_one(rbd) + await db.coll.drop() + await db.coll.insert_one(rbd) result = await db.get_collection( "test_raw", codec_options=CodecOptions(uuid_representation=JAVA_LEGACY) ).find_one() @@ -178,7 +178,7 @@ async def test_raw_bson_document_embedded(self): @async_client_context.require_connection async def test_write_response_raw_bson(self): coll = self.client.get_database( - "pymongo_test", codec_options=CodecOptions(document_class=RawBSONDocument) + "db", codec_options=CodecOptions(document_class=RawBSONDocument) ).test_raw # No Exceptions raised while handling write response. @@ -207,11 +207,11 @@ def test_contains_code_with_scope(self): self.assertEqual(doc["value"].scope, RawBSONDocument(encode({}))) def test_contains_dbref(self): - doc = RawBSONDocument(encode({"value": DBRef("test", "id")})) - raw = {"$ref": "test", "$id": "id"} + doc = RawBSONDocument(encode({"value": DBRef("coll", "id")})) + raw = {"$ref": "coll", "$id": "id"} raw_encoded = encode(decode(encode(raw))) - self.assertEqual(decode(encode(doc)), {"value": DBRef("test", "id")}) + self.assertEqual(decode(encode(doc)), {"value": DBRef("coll", "id")}) self.assertEqual(doc["value"].raw, raw_encoded) diff --git a/test/asynchronous/test_read_concern.py b/test/asynchronous/test_read_concern.py index 8659bf80b2..51390445f6 100644 --- a/test/asynchronous/test_read_concern.py +++ b/test/asynchronous/test_read_concern.py @@ -38,11 +38,11 @@ async def asyncSetUp(self): await super().asyncSetUp() self.listener = OvertCommandListener() self.client = await self.async_rs_or_single_client(event_listeners=[self.listener]) - self.db = self.client.pymongo_test - await async_client_context.client.pymongo_test.create_collection("coll") + self.db = self.client.db + await async_client_context.client.db.create_collection("coll") async def asyncTearDown(self): - await async_client_context.client.pymongo_test.drop_collection("coll") + await async_client_context.client.db.drop_collection("coll") def test_read_concern(self): rc = ReadConcern() diff --git a/test/asynchronous/test_read_preferences.py b/test/asynchronous/test_read_preferences.py index 72dd809db0..14284a94e1 100644 --- a/test/asynchronous/test_read_preferences.py +++ b/test/asynchronous/test_read_preferences.py @@ -105,16 +105,16 @@ class TestReadPreferencesBase(AsyncIntegrationTest): async def asyncSetUp(self): await super().asyncSetUp() # Insert some data so we can use cursors in read_from_which_host - await self.client.pymongo_test.test.drop() + await self.client.db.coll.drop() await self.client.get_database( - "pymongo_test", write_concern=WriteConcern(w=async_client_context.w) - ).test.insert_many([{"_id": i} for i in range(10)]) + "db", write_concern=WriteConcern(w=async_client_context.w) + ).coll.insert_many([{"_id": i} for i in range(10)]) - self.addAsyncCleanup(self.client.pymongo_test.test.drop) + self.addAsyncCleanup(self.client.db.coll.drop) async def read_from_which_host(self, client): """Do a find() on the client and return which host was used""" - cursor = client.pymongo_test.test.find() + cursor = client.db.coll.find() await anext(cursor) return cursor.address @@ -157,8 +157,8 @@ async def test_reads_from_secondary(self): # See server-selection.rst#topology-type-single. self.assertEqual(client.read_preference, ReadPreference.PRIMARY) - db = client.pymongo_test - coll = db.test + db = client.db + coll = db.coll # Test find and find_one. self.assertIsNotNone(await coll.find_one()) @@ -166,7 +166,7 @@ async def test_reads_from_secondary(self): # Test some database helpers. self.assertIsNotNone(await db.list_collection_names()) - self.assertIsNotNone(await db.validate_collection("test")) + self.assertIsNotNone(await db.validate_collection("coll")) self.assertIsNotNone(await db.command("ping")) # Test some collection helpers. @@ -367,13 +367,13 @@ async def asyncSetUp(self): ) self.client_version = await Version.async_from_client(self.c) # mapReduce fails if the collection does not exist. - coll = self.c.pymongo_test.get_collection( - "test", write_concern=WriteConcern(w=async_client_context.w) + coll = self.c.db.get_collection( + "coll", write_concern=WriteConcern(w=async_client_context.w) ) await coll.insert_one({}) async def asyncTearDown(self): - await self.c.drop_database("pymongo_test") + await self.c.drop_database("db") await self.c.close() async def executed_on_which_server(self, client, fn, *args, **kwargs): @@ -429,7 +429,7 @@ async def test_command(self): for mode, server_type in _PREF_MAP: async def func(): - return await self.c.pymongo_test.command("dbStats", read_preference=mode()) + return await self.c.db.command("dbStats", read_preference=mode()) await self._test_fn(server_type, func) @@ -437,32 +437,30 @@ async def test_create_collection(self): # create_collection runs listCollections on the primary to check if # the collection already exists. async def func(): - return await self.c.pymongo_test.create_collection( + return await self.c.db.create_collection( "some_collection%s" % random.randint(0, sys.maxsize) ) await self._test_primary_helper(func) async def test_count_documents(self): - await self._test_coll_helper(True, self.c.pymongo_test.test, "count_documents", {}) + await self._test_coll_helper(True, self.c.db.coll, "count_documents", {}) async def test_estimated_document_count(self): - await self._test_coll_helper(True, self.c.pymongo_test.test, "estimated_document_count") + await self._test_coll_helper(True, self.c.db.coll, "estimated_document_count") async def test_distinct(self): - await self._test_coll_helper(True, self.c.pymongo_test.test, "distinct", "a") + await self._test_coll_helper(True, self.c.db.coll, "distinct", "a") async def test_aggregate(self): - await self._test_coll_helper( - True, self.c.pymongo_test.test, "aggregate", [{"$project": {"_id": 1}}] - ) + await self._test_coll_helper(True, self.c.db.coll, "aggregate", [{"$project": {"_id": 1}}]) async def test_aggregate_write(self): # 5.0 servers support $out on secondaries. secondary_ok = async_client_context.version.at_least(5, 0) await self._test_coll_helper( secondary_ok, - self.c.pymongo_test.test, + self.c.db.coll, "aggregate", [{"$project": {"_id": 1}}, {"$out": "agg_write_test"}], ) @@ -596,7 +594,7 @@ async def test_send_hedge(self): for _mode, cls in cases.items(): with _ignore_deprecations(): pref = cls(hedge={"enabled": True}) - coll = client.test.get_collection("test", read_preference=pref) + coll = client.coll.get_collection("coll", read_preference=pref) listener.reset() await coll.find_one() started = listener.started_events @@ -680,8 +678,8 @@ async def test_mongos(self): num_members = shard.count(",") + 1 if num_members == 1: raise SkipTest("Need a replica set shard to test.") - coll = async_client_context.client.pymongo_test.get_collection( - "test", write_concern=WriteConcern(w=num_members) + coll = async_client_context.client.db.get_collection( + "coll", write_concern=WriteConcern(w=num_members) ) await coll.drop() res = await coll.insert_many([{} for _ in range(5)]) @@ -702,14 +700,14 @@ async def test_mongos(self): @async_client_context.require_mongos async def test_mongos_max_staleness(self): # Sanity check that we're sending maxStalenessSeconds - coll = async_client_context.client.pymongo_test.get_collection( - "test", read_preference=SecondaryPreferred(max_staleness=120) + coll = async_client_context.client.db.get_collection( + "coll", read_preference=SecondaryPreferred(max_staleness=120) ) # No error await coll.find_one() - coll = async_client_context.client.pymongo_test.get_collection( - "test", read_preference=SecondaryPreferred(max_staleness=10) + coll = async_client_context.client.db.get_collection( + "coll", read_preference=SecondaryPreferred(max_staleness=10) ) try: await coll.find_one() @@ -722,7 +720,7 @@ async def test_mongos_max_staleness(self): await self.async_single_client( readPreference="secondaryPreferred", maxStalenessSeconds=120 ) - ).pymongo_test.test + ).db.coll # No error await coll.find_one() @@ -730,7 +728,7 @@ async def test_mongos_max_staleness(self): await self.async_single_client( readPreference="secondaryPreferred", maxStalenessSeconds=10 ) - ).pymongo_test.test + ).db.coll try: await coll.find_one() except OperationFailure as exc: diff --git a/test/asynchronous/test_read_write_concern_spec.py b/test/asynchronous/test_read_write_concern_spec.py index 2d08de7804..401f9a1376 100644 --- a/test/asynchronous/test_read_write_concern_spec.py +++ b/test/asynchronous/test_read_write_concern_spec.py @@ -50,36 +50,36 @@ async def test_omit_default_read_write_concern(self): listener = OvertCommandListener() # Client with default readConcern and writeConcern client = await self.async_rs_or_single_client(event_listeners=[listener]) - collection = client.pymongo_test.collection + coll = client.db.coll # Prepare for tests of find() and aggregate(). - await collection.insert_many([{} for _ in range(10)]) - self.addAsyncCleanup(collection.drop) - self.addAsyncCleanup(client.pymongo_test.collection2.drop) + await coll.insert_many([{} for _ in range(10)]) + self.addAsyncCleanup(coll.drop) + self.addAsyncCleanup(client.db.coll2.drop) # Commands MUST NOT send the default read/write concern to the server. async def rename_and_drop(): - # Ensure collection exists. - await collection.insert_one({}) - await collection.rename("collection2") - await client.pymongo_test.collection2.drop() + # Ensure coll exists. + await coll.insert_one({}) + await coll.rename("coll2") + await client.db.coll2.drop() async def insert_command_default_write_concern(): - await collection.database.command( - "insert", "collection", documents=[{}], write_concern=WriteConcern() + await coll.database.command( + "insert", "coll", documents=[{}], write_concern=WriteConcern() ) async def aggregate_op(): - await (await collection.aggregate([])).to_list() + await (await coll.aggregate([])).to_list() ops = [ ("aggregate", aggregate_op), - ("find", lambda: collection.find().to_list()), - ("insert_one", lambda: collection.insert_one({})), - ("update_one", lambda: collection.update_one({}, {"$set": {"x": 1}})), - ("update_many", lambda: collection.update_many({}, {"$set": {"x": 1}})), - ("delete_one", lambda: collection.delete_one({})), - ("delete_many", lambda: collection.delete_many({})), - ("bulk_write", lambda: collection.bulk_write([InsertOne({})])), + ("find", lambda: coll.find().to_list()), + ("insert_one", lambda: coll.insert_one({})), + ("update_one", lambda: coll.update_one({}, {"$set": {"x": 1}})), + ("update_many", lambda: coll.update_many({}, {"$set": {"x": 1}})), + ("delete_one", lambda: coll.delete_one({})), + ("delete_many", lambda: coll.delete_many({})), + ("bulk_write", lambda: coll.bulk_write([InsertOne({})])), ("rename_and_drop", rename_and_drop), ("command", insert_command_default_write_concern), ] @@ -107,8 +107,8 @@ async def assertWriteOpsRaise(self, write_concern, expected_exception): client = await self.async_rs_or_single_client( w=wc["w"], wTimeoutMS=wc["wtimeout"], socketTimeoutMS=30000 ) - db = client.get_database("pymongo_test") - coll = db.test + db = client.get_database("db") + coll = db.coll async def insert_command(): await coll.database.command( @@ -159,7 +159,7 @@ async def insert_command(): @async_client_context.require_replica_set async def test_raise_write_concern_error(self): - self.addAsyncCleanup(async_client_context.client.drop_database, "pymongo_test") + self.addAsyncCleanup(async_client_context.client.drop_database, "db") assert async_client_context.w is not None await self.assertWriteOpsRaise( WriteConcern(w=async_client_context.w + 1, wtimeout=1), WriteConcernError @@ -168,7 +168,7 @@ async def test_raise_write_concern_error(self): @async_client_context.require_secondaries_count(1) @async_client_context.require_test_commands async def test_raise_wtimeout(self): - self.addAsyncCleanup(async_client_context.client.drop_database, "pymongo_test") + self.addAsyncCleanup(async_client_context.client.drop_database, "db") self.addAsyncCleanup(self.enable_replication, async_client_context.client) # Disable replication to guarantee a wtimeout error. await self.disable_replication(async_client_context.client) @@ -194,12 +194,12 @@ async def test_error_includes_errInfo(self): async with self.fail_point(cause_wce): # Write concern error on insert includes errInfo. with self.assertRaises(WriteConcernError) as ctx: - await self.db.test.insert_one({}) + await self.db.coll.insert_one({}) self.assertEqual(ctx.exception.details, expected_wce) # Test bulk_write as well. with self.assertRaises(BulkWriteError) as ctx: - await self.db.test.bulk_write([InsertOne({})]) + await self.db.coll.bulk_write([InsertOne({})]) expected_details = { "writeErrors": [], "writeConcernErrors": [expected_wce], @@ -221,9 +221,9 @@ async def test_write_error_details_exposes_errinfo(self): db = client.errinfotest self.addAsyncCleanup(client.drop_database, "errinfotest") validator = {"x": {"$type": "string"}} - await db.create_collection("test", validator=validator) + await db.create_collection("coll", validator=validator) with self.assertRaises(WriteError) as ctx: - await db.test.insert_one({"x": 1}) + await db.coll.insert_one({"x": 1}) self.assertEqual(ctx.exception.code, 121) self.assertIsNotNone(ctx.exception.details) assert ctx.exception.details is not None diff --git a/test/asynchronous/test_retryable_reads.py b/test/asynchronous/test_retryable_reads.py index 2f0bb1f7d5..c77525c0e5 100644 --- a/test/asynchronous/test_retryable_reads.py +++ b/test/asynchronous/test_retryable_reads.py @@ -97,7 +97,7 @@ async def test_pool_paused_error_is_retryable(self): for _ in range(10): cmap_listener.reset() cmd_listener.reset() - threads = [FindThread(client.pymongo_test.test) for _ in range(2)] + threads = [FindThread(client.db.coll) for _ in range(2)] fail_command = { "mode": {"times": 1}, "data": { @@ -183,7 +183,7 @@ async def test_retryable_reads_are_retried_on_a_different_mongos_when_one_is_ava ) with self.assertRaises(OperationFailure): - await client.t.t.find_one({}) + await client.db.coll.find_one({}) # Disable failpoints on each mongos for client in mongos_clients: @@ -219,7 +219,7 @@ async def test_retryable_reads_are_retried_on_the_same_mongos_when_no_others_are retryReads=True, ) - await client.t.t.find_one({}) + await client.db.coll.find_one({}) # Disable failpoint. fail_command["mode"] = "off" @@ -241,17 +241,17 @@ async def test_retryable_reads_are_retried_on_the_same_implicit_session(self): retryReads=True, ) - await client.t.t.insert_one({"x": 1}) + await client.db.coll.insert_one({"x": 1}) commands = [ - ("aggregate", lambda: client.t.t.count_documents({})), - ("aggregate", lambda: client.t.t.aggregate([{"$match": {}}])), - ("count", lambda: client.t.t.estimated_document_count()), - ("distinct", lambda: client.t.t.distinct("x")), - ("find", lambda: client.t.t.find_one({})), + ("aggregate", lambda: client.db.coll.count_documents({})), + ("aggregate", lambda: client.db.coll.aggregate([{"$match": {}}])), + ("count", lambda: client.db.coll.estimated_document_count()), + ("distinct", lambda: client.db.coll.distinct("x")), + ("find", lambda: client.db.coll.find_one({})), ("listDatabases", lambda: client.list_databases()), - ("listCollections", lambda: client.t.list_collections()), - ("listIndexes", lambda: client.t.t.list_indexes()), + ("listCollections", lambda: client.db.list_collections()), + ("listIndexes", lambda: client.db.coll.list_indexes()), ] for command_name, operation in commands: @@ -311,7 +311,7 @@ async def test_03_01_retryable_reads_caused_by_overload_errors_are_retried_on_a_ listener.reset() # 4. Execute a `find` command with `client`. - await client.t.t.find_one({}) + await client.db.coll.find_one({}) # 5. Assert that one failed command event and one successful command event occurred. self.assertEqual(len(listener.failed_events), 1) @@ -353,7 +353,7 @@ async def test_03_02_retryable_reads_caused_by_non_overload_errors_are_retried_o listener.reset() # 4. Execute a `find` command with `client`. - await client.t.t.find_one({}) + await client.db.coll.find_one({}) # 5. Assert that one failed command event and one successful command event occurred. self.assertEqual(len(listener.failed_events), 1) @@ -397,7 +397,7 @@ async def test_03_03_retryable_reads_caused_by_overload_errors_are_retried_on_th listener.reset() # 4. Execute a `find` command with `client`. - await client.t.t.find_one({}) + await client.db.coll.find_one({}) # 5. Assert that one failed command event and one successful command event occurred. self.assertEqual(len(listener.failed_events), 1) @@ -447,13 +447,13 @@ def failed(event: CommandFailedEvent) -> None: listener.failed = failed client = await self.async_rs_client(event_listeners=[listener]) - await client.test.test.insert_one({}) + await client.db.coll.insert_one({}) self.configure_fail_point_sync(overload_fail_point) self.addCleanup(self.configure_fail_point_sync, {}, off=True) with self.assertRaises(PyMongoError): - await client.test.test.find_one() + await client.db.coll.find_one() started_finds = [e for e in listener.started_events if e.command_name == "find"] self.assertEqual(len(started_finds), MAX_ADAPTIVE_RETRIES + 1) @@ -504,7 +504,7 @@ def failed(event: CommandFailedEvent) -> None: listener.failed = failed client = await self.async_rs_client(event_listeners=[listener]) - await client.test.test.insert_one({}) + await client.db.coll.insert_one({}) self.configure_fail_point_sync(overload_fail_point) self.addCleanup(self.configure_fail_point_sync, {}, off=True) @@ -512,7 +512,7 @@ def failed(event: CommandFailedEvent) -> None: # Perform a findOne operation with coll. Expect the operation to fail. with mock.patch(mock_target, return_value=0) as mock_backoff: with self.assertRaises(PyMongoError): - await client.test.test.find_one() + await client.db.coll.find_one() # Assert that backoff was applied only once for the initial overload error and not for the subsequent non-overload retryable errors. self.assertEqual(mock_backoff.call_count, 1) diff --git a/test/asynchronous/test_retryable_writes.py b/test/asynchronous/test_retryable_writes.py index a63aa6783e..7e872d8af2 100644 --- a/test/asynchronous/test_retryable_writes.py +++ b/test/asynchronous/test_retryable_writes.py @@ -159,7 +159,7 @@ async def asyncSetUp(self) -> None: self.client = await self.async_rs_or_single_client( retryWrites=True, event_listeners=[self.listener] ) - self.db = self.client.pymongo_test + self.db = self.client.db if async_client_context.is_rs and async_client_context.test_commands_enabled: await self.client.admin.command( @@ -385,7 +385,7 @@ async def test_retryable_writes_in_sharded_cluster_multiple_available(self): ) with self.assertRaises(AutoReconnect): - await client.t.t.insert_one({"x": 1}) + await client.db.coll.insert_one({"x": 1}) # Disable failpoints on each mongos for client in mongos_clients: @@ -420,11 +420,11 @@ async def test_RetryableWriteError_error_label(self): client = await self.async_rs_or_single_client(retryWrites=True, event_listeners=[listener]) # Ensure collection exists. - await client.pymongo_test.testcoll.insert_one({}) + await client.db.coll.insert_one({}) async with self.fail_point(self.fail_insert): with self.assertRaises(WriteConcernError) as cm: - await client.pymongo_test.testcoll.insert_one({}) + await client.db.coll.insert_one({}) self.assertTrue(cm.exception.has_error_label("RetryableWriteError")) if async_client_context.version >= Version(4, 4): @@ -437,9 +437,9 @@ async def test_RetryableWriteError_error_label_RawBSONDocument(self): async with self.fail_point(self.fail_insert): async with self.client.start_session() as s: s._start_retryable_write() - result = await self.client.pymongo_test.command( + result = await self.client.db.command( "insert", - "testcoll", + "coll", documents=[{"_id": 1}], txnNumber=s._transaction_id, session=s, @@ -482,7 +482,7 @@ async def test_pool_paused_error_is_retryable(self): for _ in range(10): cmap_listener.reset() cmd_listener.reset() - threads = [InsertThread(client.pymongo_test.test) for _ in range(2)] + threads = [InsertThread(client.db.coll) for _ in range(2)] fail_command = { "mode": {"times": 1}, "data": { @@ -543,7 +543,7 @@ async def test_returns_original_error_code( client = await self.async_rs_or_single_client( retryWrites=True, event_listeners=[cmd_listener] ) - await client.test.test.drop() + await client.db.coll.drop() cmd_listener.reset() await client.admin.command( { @@ -559,7 +559,7 @@ async def test_returns_original_error_code( } ) with self.assertRaises(WriteConcernError) as exc: - await client.test.test.insert_one({"_id": 1}) + await client.db.coll.insert_one({"_id": 1}) self.assertEqual(exc.exception.code, 91) await client.admin.command( { @@ -673,7 +673,7 @@ def failed(event: CommandFailedEvent) -> None: # Attempt an insertOne operation on any record for any database and collection. # Expect the insertOne to fail with a server error. with self.assertRaises(NotPrimaryError) as exc: - await client.test.test.insert_one({}) + await client.db.coll.insert_one({}) # Assert that the error code of the server error is 10107. assert exc.exception.errors["code"] == 10107 # type:ignore[call-overload] @@ -726,7 +726,7 @@ def failed(event: CommandFailedEvent) -> None: # Attempt an insertOne operation on any record for any database and collection. # Expect the insertOne to fail with a server error. with self.assertRaises(NotPrimaryError) as exc: - await client.test.test.insert_one({}) + await client.db.coll.insert_one({}) # Assert that the error code of the server error is 91. assert exc.exception.errors["code"] == 91 # type:ignore[call-overload] @@ -780,7 +780,7 @@ def failed(event: CommandFailedEvent) -> None: # Attempt an insertOne operation on any record for any database and collection. # Expect the insertOne to fail with a server error. with self.assertRaises(PyMongoError) as exc: - await client.test.test.insert_one({}) + await client.db.coll.insert_one({}) # Assert that the error code of the server error is 91. assert exc.exception.errors["code"] == 91 @@ -831,7 +831,7 @@ def failed(event: CommandFailedEvent) -> None: self.addCleanup(self.configure_fail_point_sync, {}, off=True) with self.assertRaises(PyMongoError): - await client.test.test.insert_one({"x": 1}) + await client.db.coll.insert_one({"x": 1}) started_inserts = [e for e in listener.started_events if e.command_name == "insert"] self.assertEqual(len(started_inserts), MAX_ADAPTIVE_RETRIES + 1) @@ -887,7 +887,7 @@ def failed(event: CommandFailedEvent) -> None: # Perform a findOne operation with coll. Expect the operation to fail. with mock.patch(mock_target, return_value=0) as mock_backoff: with self.assertRaises(PyMongoError): - await client.test.test.insert_one({}) + await client.db.coll.insert_one({}) # Assert that backoff was applied only once for the initial overload error and not for the subsequent non-overload retryable errors. self.assertEqual(mock_backoff.call_count, 1) diff --git a/test/asynchronous/test_server_selection.py b/test/asynchronous/test_server_selection.py index b704fcea83..12e748e668 100644 --- a/test/asynchronous/test_server_selection.py +++ b/test/asynchronous/test_server_selection.py @@ -129,14 +129,14 @@ async def test_selector_called(self): # Client setup. mongo_client = await self.async_rs_or_single_client(server_selector=selector) - test_collection = mongo_client.testdb.test_collection - self.addAsyncCleanup(mongo_client.drop_database, "testdb") + coll = mongo_client.db.coll + self.addAsyncCleanup(mongo_client.drop_database, "db") # Do N operations and test selector is called at least N-1 times due to fast path. - await test_collection.insert_one({"age": 20, "name": "John"}) - await test_collection.insert_one({"age": 31, "name": "Jane"}) - await test_collection.update_one({"name": "Jane"}, {"$set": {"age": 21}}) - await test_collection.find_one({"name": "Roe"}) + await coll.insert_one({"age": 20, "name": "John"}) + await coll.insert_one({"age": 31, "name": "Jane"}) + await coll.update_one({"name": "Jane"}, {"$set": {"age": 21}}) + await coll.find_one({"name": "Roe"}) self.assertGreaterEqual(selector.call_count, 3) @async_client_context.require_replica_set @@ -216,7 +216,7 @@ async def test_server_selection_getMore_blocks(self): client = await self.async_rs_client( event_listeners=[hb_listener], heartbeatFrequencyMS=500, appName="heartbeatFailedClient" ) - coll = client.db.test + coll = client.db.coll await coll.drop() docs = [{"x": 1} for _ in range(5)] await coll.insert_many(docs) diff --git a/test/asynchronous/test_server_selection_in_window.py b/test/asynchronous/test_server_selection_in_window.py index 83e7ec7c7d..9e84655a7d 100644 --- a/test/asynchronous/test_server_selection_in_window.py +++ b/test/asynchronous/test_server_selection_in_window.py @@ -116,7 +116,7 @@ async def run(self): class TestProse(AsyncIntegrationTest): async def frequencies(self, client, listener, n_finds=10): - coll = client.test.test + coll = client.db.coll N_TASKS = 10 tasks = [FinderTask(coll, n_finds) for _ in range(N_TASKS)] for task in tasks: @@ -169,7 +169,7 @@ async def test_load_balancing(self): "appName": "loadBalancingTest", }, } - coll = client.test.test + coll = client.db.coll N_TASKS = 10 async with self.fail_point(delay_finds): nodes = async_client_context.client.nodes diff --git a/test/asynchronous/test_session.py b/test/asynchronous/test_session.py index 65476c8687..24a6fe42b6 100644 --- a/test/asynchronous/test_session.py +++ b/test/asynchronous/test_session.py @@ -98,12 +98,12 @@ async def asyncSetUp(self): self.client = await self.async_rs_or_single_client( event_listeners=[self.listener, self.session_checker_listener] ) - self.db = self.client.pymongo_test + self.db = self.client.db self.initial_lsids = {s["id"] for s in session_ids(self.client)} async def asyncTearDown(self): monitoring._SENSITIVE_COMMANDS.update(self.sensitive_commands) - await self.client.drop_database("pymongo_test") + await self.client.drop_database("db") used_lsids = self.initial_lsids.copy() for event in self.session_checker_listener.started_events: if "lsid" in event.command: @@ -242,17 +242,17 @@ async def test_implicit_sessions_checkout(self): # Retry up to 10 times because there is a known race condition that can cause multiple # sessions to be used: connection check in happens before session check in for _ in range(10): - cursor = client.db.test.find({}) + cursor = client.db.coll.find({}) ops: List[Tuple[Callable, List[Any]]] = [ - (client.db.test.find_one, [{"_id": 1}]), - (client.db.test.delete_one, [{}]), - (client.db.test.update_one, [{}, {"$set": {"x": 2}}]), - (client.db.test.bulk_write, [[UpdateOne({}, {"$set": {"x": 2}})]]), - (client.db.test.find_one_and_delete, [{}]), - (client.db.test.find_one_and_update, [{}, {"$set": {"x": 1}}]), - (client.db.test.find_one_and_replace, [{}, {}]), - (client.db.test.aggregate, [[{"$limit": 1}]]), - (client.db.test.find, []), + (client.db.coll.find_one, [{"_id": 1}]), + (client.db.coll.delete_one, [{}]), + (client.db.coll.update_one, [{}, {"$set": {"x": 2}}]), + (client.db.coll.bulk_write, [[UpdateOne({}, {"$set": {"x": 2}})]]), + (client.db.coll.find_one_and_delete, [{}]), + (client.db.coll.find_one_and_update, [{}, {"$set": {"x": 1}}]), + (client.db.coll.find_one_and_replace, [{}, {}]), + (client.db.coll.aggregate, [[{"$limit": 1}]]), + (client.db.coll.find, []), (client.server_info, []), (client.db.aggregate, [[{"$listLocalSessions": {}}, {"$limit": 1}]]), (cursor.distinct, ["_id"]), @@ -349,26 +349,26 @@ async def test_client(self): ops: list = [ (client.server_info, [], {}), (client.list_database_names, [], {}), - (client.drop_database, ["pymongo_test"], {}), + (client.drop_database, ["db"], {}), ] await self._test_ops(client, *ops) async def test_database(self): client = self.client - db = client.pymongo_test + db = client.db ops: list = [ (db.command, ["ping"], {}), - (db.create_collection, ["collection"], {}), + (db.create_coll, ["collection"], {}), (db.list_collection_names, [], {}), - (db.validate_collection, ["collection"], {}), - (db.drop_collection, ["collection"], {}), + (db.validate_collection, ["coll"], {}), + (db.drop_collection, ["coll"], {}), (db.dereference, [DBRef("collection", 1)], {}), ] await self._test_ops(client, *ops) @staticmethod - def collection_write_ops(coll): + def test_write_ops(coll): """Generate database write ops for tests.""" return [ (coll.drop, [], {}), @@ -383,9 +383,9 @@ def collection_write_ops(coll): (coll.find_one_and_replace, [{}, {}], {}), (coll.find_one_and_update, [{}, {"$set": {"a": 1}}], {}), (coll.find_one_and_delete, [{}, {}], {}), - (coll.rename, ["collection2"], {}), - # Drop collection2 between tests of "rename", above. - (coll.database.drop_collection, ["collection2"], {}), + (coll.rename, ["coll2"], {}), + # Drop coll2 between tests of "rename", above. + (coll.database.drop_collection, ["coll2"], {}), (coll.create_indexes, [[IndexModel("a")]], {}), (coll.create_index, ["a"], {}), (coll.drop_index, ["a_1"], {}), @@ -395,7 +395,7 @@ def collection_write_ops(coll): async def test_collection(self): client = self.client - coll = client.pymongo_test.collection + coll = client.db.coll # Test some collection methods - the rest are in test_cursor. ops = self.collection_write_ops(coll) @@ -414,7 +414,7 @@ async def test_collection(self): await self._test_ops(client, *ops) async def test_cursor_clone(self): - coll = self.client.pymongo_test.collection + coll = self.client.db.coll # Ensure some batches. await coll.insert_many({} for _ in range(10)) self.addAsyncCleanup(coll.drop) @@ -442,7 +442,7 @@ async def test_cursor_clone(self): async def test_cursor(self): listener = self.listener client = self.client - coll = client.pymongo_test.collection + coll = client.db.coll await coll.insert_many([{} for _ in range(1000)]) # Test all cursor methods. @@ -504,7 +504,7 @@ async def test_cursor(self): async def test_gridfs(self): client = self.client - fs = AsyncGridFS(client.pymongo_test) + fs = AsyncGridFS(client.db) async def new_file(session=None): grid_file = fs.new_file(_id=1, filename="f", session=session) @@ -546,7 +546,7 @@ async def find_list(session=None): async def test_gridfs_bucket(self): client = self.client - bucket = AsyncGridFSBucket(client.pymongo_test) + bucket = AsyncGridFSBucket(client.db) async def upload(session=None): stream = bucket.open_upload_stream("f", session=session) @@ -593,7 +593,7 @@ async def find(session=None): async def test_gridfsbucket_cursor(self): client = self.client - bucket = AsyncGridFSBucket(client.pymongo_test) + bucket = AsyncGridFSBucket(client.db) for file_id in 1, 2: stream = bucket.open_upload_stream_with_id(file_id, str(file_id)) @@ -644,7 +644,7 @@ async def test_gridfsbucket_cursor(self): async def test_aggregate(self): client = self.client - coll = client.pymongo_test.collection + coll = client.db.coll async def agg(session=None): await (await coll.aggregate([], batchSize=2, session=session)).to_list() @@ -659,7 +659,7 @@ async def agg(session=None): async def test_killcursors(self): client = self.client - coll = client.pymongo_test.collection + coll = client.db.coll await coll.insert_many([{} for _ in range(10)]) async def explicit_close(session=None): @@ -672,7 +672,7 @@ async def explicit_close(session=None): async def test_aggregate_error(self): listener = self.listener client = self.client - coll = client.pymongo_test.collection + coll = client.db.coll # 3.6.0 mongos only validates the aggregate pipeline when the # database exists. await coll.database.create_collection(coll.name) @@ -688,7 +688,7 @@ async def test_aggregate_error(self): self.assertIn(lsid, session_ids(client)) async def _test_cursor_helper(self, create_cursor, close_cursor): - coll = self.client.pymongo_test.collection + coll = self.client.db.coll await coll.insert_many([{} for _ in range(1000)]) cursor = await create_cursor(coll, None) @@ -827,14 +827,14 @@ async def _test_unacknowledged_ops(self, client, *ops): async def test_unacknowledged_writes(self): # Ensure the collection exists. - await self.client.pymongo_test.create_collection("test_unacked_writes") + await self.client.db.create_collection("test_unacked_writes") client = await self.async_rs_or_single_client(w=0, event_listeners=[self.listener]) - db = client.pymongo_test + db = client.db coll = db.test_unacked_writes ops: list = [ (client.drop_database, [db.name], {}), - (db.create_collection, ["collection"], {}), - (db.drop_collection, ["collection"], {}), + (db.create_collection, ["coll"], {}), + (db.drop_collection, ["coll"], {}), ] ops.extend(self.collection_write_ops(coll)) await self._test_unacknowledged_ops(client, *ops) @@ -869,7 +869,7 @@ async def test_session_not_copyable(self): self.assertRaises(TypeError, lambda: copy.copy(s)) async def test_nested_session_binding(self): - coll = self.client.pymongo_test.test + coll = self.client.db.coll await coll.insert_one({"x": 1}) session1 = self.client.start_session() @@ -920,7 +920,7 @@ async def test_nested_session_binding(self): await session2.end_session() async def test_session_binding_end_session(self): - coll = self.client.pymongo_test.test + coll = self.client.db.coll await coll.insert_one({"x": 1}) async with self.client.start_session().bind() as s1: @@ -938,7 +938,7 @@ async def test_session_binding_end_session(self): async def test_getmore_preserves_lsid_after_session_support_lost(self): listener = OvertCommandListener() client = await self.async_rs_or_single_client(event_listeners=[listener], maxPoolSize=1) - coll = client.pymongo_test.test + coll = client.db.coll await coll.drop() await coll.insert_many([{"x": i} for i in range(10)]) self.addAsyncCleanup(coll.drop) @@ -978,8 +978,8 @@ async def asyncSetUp(self): await super().asyncSetUp() self.listener = SessionTestListener() self.client = await self.async_rs_or_single_client(event_listeners=[self.listener]) - await self.client.pymongo_test.drop_collection("test") - await self.client.pymongo_test.create_collection("test") + await self.client.db.drop_collection("coll") + await self.client.db.create_collection("coll") @async_client_context.require_no_standalone async def test_core(self): @@ -987,7 +987,7 @@ async def test_core(self): self.assertIsNone(sess.cluster_time) self.assertIsNone(sess.operation_time) self.listener.reset() - await self.client.pymongo_test.test.find_one(session=sess) + await self.client.db.coll.find_one(session=sess) started = self.listener.started_events[0] cmd = started.command self.assertIsNone(cmd.get("readConcern")) @@ -998,11 +998,11 @@ async def test_core(self): self.assertEqual(op_time, reply.get("operationTime")) # No explicit session - await self.client.pymongo_test.test.insert_one({}) + await self.client.db.coll.insert_one({}) self.assertEqual(sess.operation_time, op_time) self.listener.reset() try: - await self.client.pymongo_test.command("doesntexist", session=sess) + await self.client.db.command("doesntexist", session=sess) except: pass failed = self.listener.failed_events[0] @@ -1030,7 +1030,7 @@ async def test_core(self): self.assertEqual(sess.operation_time, sess2.operation_time) async def _test_reads(self, op, exception=None): - coll = self.client.pymongo_test.test + coll = self.client.db.coll async with self.client.start_session() as sess: await coll.find_one({}, session=sess) operation_time = sess.operation_time @@ -1073,7 +1073,7 @@ async def find_raw(coll, session): ) async def _test_writes(self, op): - coll = self.client.pymongo_test.test + coll = self.client.db.coll async with self.client.start_session() as sess: await op(coll, sess) operation_time = sess.operation_time @@ -1126,7 +1126,7 @@ async def test_writes(self): await self._test_writes(lambda coll, session: coll.drop_indexes(session=session)) async def _test_no_read_concern(self, op): - coll = self.client.pymongo_test.test + coll = self.client.db.coll async with self.client.start_session() as sess: await coll.find_one({}, session=sess) operation_time = sess.operation_time @@ -1144,7 +1144,7 @@ async def test_explain_does_not_include_read_concern(self): @async_client_context.require_no_standalone async def test_get_more_does_not_include_read_concern(self): - coll = self.client.pymongo_test.test + coll = self.client.db.coll async with self.client.start_session() as sess: await coll.find_one({}, session=sess) operation_time = sess.operation_time @@ -1160,9 +1160,9 @@ async def test_get_more_does_not_include_read_concern(self): async def test_session_not_causal(self): async with self.client.start_session(causal_consistency=False) as s: - await self.client.pymongo_test.test.insert_one({}, session=s) + await self.client.db.coll.insert_one({}, session=s) self.listener.reset() - await self.client.pymongo_test.test.find_one({}, session=s) + await self.client.db.coll.find_one({}, session=s) act = ( self.listener.started_events[0] .command.get("readConcern", {}) @@ -1173,9 +1173,9 @@ async def test_session_not_causal(self): @async_client_context.require_standalone async def test_server_not_causal(self): async with self.client.start_session(causal_consistency=True) as s: - await self.client.pymongo_test.test.insert_one({}, session=s) + await self.client.db.coll.insert_one({}, session=s) self.listener.reset() - await self.client.pymongo_test.test.find_one({}, session=s) + await self.client.db.coll.find_one({}, session=s) act = ( self.listener.started_events[0] .command.get("readConcern", {}) @@ -1186,7 +1186,7 @@ async def test_server_not_causal(self): @async_client_context.require_no_standalone async def test_read_concern(self): async with self.client.start_session(causal_consistency=True) as s: - coll = self.client.pymongo_test.test + coll = self.client.db.coll await coll.insert_one({}, session=s) self.listener.reset() await coll.find_one({}, session=s) @@ -1206,14 +1206,14 @@ async def test_read_concern(self): @async_client_context.require_no_standalone async def test_cluster_time_with_server_support(self): self.listener.reset() - await self.client.pymongo_test.test.find_one({}) + await self.client.db.coll.find_one({}) after_cluster_time = self.listener.started_events[0].command.get("$clusterTime") self.assertIsNotNone(after_cluster_time) @async_client_context.require_standalone async def test_cluster_time_no_server_support(self): self.listener.reset() - await self.client.pymongo_test.test.find_one({}) + await self.client.db.coll.find_one({}) after_cluster_time = self.listener.started_events[0].command.get("$clusterTime") self.assertIsNone(after_cluster_time) @@ -1228,53 +1228,53 @@ async def asyncSetUp(self): async def test_cluster_time(self): listener = SessionTestListener() client = await self.async_rs_or_single_client(event_listeners=[listener]) - collection = client.pymongo_test.collection + coll = client.db.coll # Prepare for tests of find() and aggregate(). - await collection.insert_many([{} for _ in range(10)]) - self.addAsyncCleanup(collection.drop) - self.addAsyncCleanup(client.pymongo_test.collection2.drop) + await coll.insert_many([{} for _ in range(10)]) + self.addAsyncCleanup(coll.drop) + self.addAsyncCleanup(client.db.coll2.drop) async def rename_and_drop(): - # Ensure collection exists. - await collection.insert_one({}) - await collection.rename("collection2") - await client.pymongo_test.collection2.drop() + # Ensure coll exists. + await coll.insert_one({}) + await coll.rename("coll2") + await client.db.coll2.drop() async def insert_and_find(): - cursor = collection.find().batch_size(1) + cursor = coll.find().batch_size(1) for _ in range(10): # Advance the cluster time. - await collection.insert_one({}) + await coll.insert_one({}) await anext(cursor) await cursor.close() async def insert_and_aggregate(): - cursor = (await collection.aggregate([], batchSize=1)).batch_size(1) + cursor = (await coll.aggregate([], batchSize=1)).batch_size(1) for _ in range(5): # Advance the cluster time. - await collection.insert_one({}) + await coll.insert_one({}) await anext(cursor) await cursor.close() async def aggregate(): - await (await collection.aggregate([])).to_list() + await (await coll.aggregate([])).to_list() ops = [ # Tests from Driver Sessions Spec. ("ping", lambda: client.admin.command("ping")), ("aggregate", lambda: aggregate()), - ("find", lambda: collection.find().to_list()), - ("insert_one", lambda: collection.insert_one({})), + ("find", lambda: coll.find().to_list()), + ("insert_one", lambda: coll.insert_one({})), # Additional PyMongo tests. ("insert_and_find", insert_and_find), ("insert_and_aggregate", insert_and_aggregate), - ("update_one", lambda: collection.update_one({}, {"$set": {"x": 1}})), - ("update_many", lambda: collection.update_many({}, {"$set": {"x": 1}})), - ("delete_one", lambda: collection.delete_one({})), - ("delete_many", lambda: collection.delete_many({})), - ("bulk_write", lambda: collection.bulk_write([InsertOne({})])), + ("update_one", lambda: coll.update_one({}, {"$set": {"x": 1}})), + ("update_many", lambda: coll.update_many({}, {"$set": {"x": 1}})), + ("delete_one", lambda: coll.delete_one({})), + ("delete_many", lambda: coll.delete_many({})), + ("bulk_write", lambda: coll.bulk_write([InsertOne({})])), ("rename_and_drop", rename_and_drop), ] @@ -1283,7 +1283,7 @@ async def aggregate(): # Call f() twice, insert to advance clusterTime, call f() again. await f() await f() - await collection.insert_one({}) + await coll.insert_one({}) await f() self.assertGreaterEqual(len(listener.started_events), 1) @@ -1320,7 +1320,7 @@ async def test_cluster_time_not_used_by_sdam(self): self.assertEqual(c1._topology.max_cluster_time(), cluster_time) # Advance the server's $clusterTime by performing an insert via another client. - await self.db.test.insert_one({"advance": "$clusterTime"}) + await self.db.coll.insert_one({"advance": "$clusterTime"}) # Wait until the client C1 processes the next pair of SDAM heartbeat started + succeeded events. heartbeat_listener.reset() diff --git a/test/asynchronous/test_ssl.py b/test/asynchronous/test_ssl.py index 7fe57e8503..5d89c068b3 100644 --- a/test/asynchronous/test_ssl.py +++ b/test/asynchronous/test_ssl.py @@ -133,9 +133,7 @@ class TestSSL(AsyncIntegrationTest): saved_port: int async def assertClientWorks(self, client): - coll = client.pymongo_test.ssl_test.with_options( - write_concern=WriteConcern(w=async_client_context.w) - ) + coll = client.db.ssl_test.with_options(write_concern=WriteConcern(w=async_client_context.w)) await coll.drop() await coll.insert_one({"ssl": True}) self.assertTrue((await coll.find_one())["ssl"]) @@ -559,7 +557,7 @@ async def test_mongodb_x509_auth(self): ) with self.assertRaises(OperationFailure): - await noauth.pymongo_test.test.find_one() + await noauth.db.coll.find_one() listener = EventListener() auth = self.simple_client( @@ -572,7 +570,7 @@ async def test_mongodb_x509_auth(self): ) # No error - await auth.pymongo_test.test.find_one() + await auth.db.coll.find_one() names = listener.started_command_names() if async_client_context.version.at_least(4, 4, -1): # Speculative auth skips the authenticate command. @@ -589,14 +587,14 @@ async def test_mongodb_x509_auth(self): uri, ssl=True, tlsAllowInvalidCertificates=True, tlsCertificateKeyFile=CLIENT_PEM ) # No error - await client.pymongo_test.test.find_one() + await client.db.coll.find_one() uri = "mongodb://%s:%d/?authMechanism=MONGODB-X509" % (host, port) client = self.simple_client( uri, ssl=True, tlsAllowInvalidCertificates=True, tlsCertificateKeyFile=CLIENT_PEM ) # No error - await client.pymongo_test.test.find_one() + await client.db.coll.find_one() # Auth should fail if username and certificate do not match uri = "mongodb://%s@%s:%d/?authMechanism=MONGODB-X509" % ( quote_plus("not the username"), @@ -609,7 +607,7 @@ async def test_mongodb_x509_auth(self): ) with self.assertRaises(OperationFailure): - await bad_client.pymongo_test.test.find_one() + await bad_client.db.coll.find_one() bad_client = self.simple_client( await async_client_context.pair, @@ -621,7 +619,7 @@ async def test_mongodb_x509_auth(self): ) with self.assertRaises(OperationFailure): - await bad_client.pymongo_test.test.find_one() + await bad_client.db.coll.find_one() # Invalid certificate (using CA certificate as client certificate) uri = "mongodb://%s@%s:%d/?authMechanism=MONGODB-X509" % ( diff --git a/test/asynchronous/test_transactions.py b/test/asynchronous/test_transactions.py index 0c73c62ebf..7d8920679a 100644 --- a/test/asynchronous/test_transactions.py +++ b/test/asynchronous/test_transactions.py @@ -105,8 +105,8 @@ def test_transaction_options_validation(self): async def test_transaction_write_concern_override(self): """Test txn overrides Client/Database/Collection write_concern.""" client = await self.async_rs_client(w=0) - db = client.test - coll = db.test + db = client.db + coll = db.coll await coll.insert_one({}) async with client.start_session() as s: async with await s.start_transaction(write_concern=WriteConcern(w=1)): @@ -165,7 +165,7 @@ async def test_unpin_for_next_transaction(self): async_client_context.mongos_seeds(), localThresholdMS=1000 ) await async_wait_until(lambda: len(client.nodes) > 1, "discover both mongoses") - coll = client.test.test + coll = client.db.coll # Create the collection. await coll.insert_one({}) async with client.start_session() as s: @@ -194,7 +194,7 @@ async def test_unpin_for_non_transaction_operation(self): async_client_context.mongos_seeds(), localThresholdMS=1000 ) await async_wait_until(lambda: len(client.nodes) > 1, "discover both mongoses") - coll = client.test.test + coll = client.db.coll # Create the collection. await coll.insert_one({}) async with client.start_session() as s: @@ -217,8 +217,8 @@ async def test_unpin_for_non_transaction_operation(self): @async_client_context.require_version_min(4, 3, 4) async def test_create_collection(self): client = async_client_context.client - db = client.pymongo_test - coll = db.test_create_collection + db = client.db + coll = db.coll self.addAsyncCleanup(coll.drop) # Use with_transaction to avoid StaleConfig errors on sharded clusters. @@ -244,7 +244,7 @@ async def create_and_insert(session): @async_client_context.require_transactions async def test_gridfs_does_not_support_transactions(self): client = async_client_context.client - db = client.pymongo_test + db = client.db gfs = AsyncGridFS(db) bucket = AsyncGridFSBucket(db) @@ -329,7 +329,7 @@ async def test_transaction_starts_with_batched_write(self): # split. listener = OvertCommandListener() client = await self.async_rs_client(event_listeners=[listener]) - coll = client[self.db.name].test + coll = client[self.db.name].coll await coll.delete_many({}) listener.reset() self.addAsyncCleanup(coll.drop) @@ -357,7 +357,7 @@ async def test_transaction_starts_with_batched_write(self): @async_client_context.require_transactions async def test_transaction_direct_connection(self): client = await self.async_single_client() - coll = client.pymongo_test.test + coll = client.db.coll # Make sure the collection exists. await coll.insert_one({}) @@ -403,7 +403,7 @@ async def test_transaction_pool_cleared_error_labelled_transient(self): with self.assertRaises(AutoReconnect) as context: async with c.start_session() as session: async with await session.start_transaction(): - server = await c._select_server(writable_server_selector, session, "test") + server = await c._select_server(writable_server_selector, session, "coll") # Pause the server's pool, causing it to fail connection checkout. server.pool.state = PoolState.PAUSED async with c._checkout(server, session): @@ -461,10 +461,10 @@ async def callback(_): async with self.client.start_session() as s: self.assertEqual(await s.with_transaction(callback), "Foo") - await self.db.test.insert_one({}) + await self.db.list_collection_names.insert_one({}) async def callback2(session): - await self.db.test.insert_one({}, session=session) + await self.db.coll.insert_one({}, session=session) return "Foo" async with self.client.start_session() as s: @@ -485,7 +485,7 @@ def callback(_): async def test_3_1_callback_not_retried_after_timeout(self): listener = OvertCommandListener() client = await self.async_rs_client(event_listeners=[listener]) - coll = client[self.db.name].test + coll = client[self.db.name].coll async def callback(session): await coll.insert_one({}, session=session) @@ -515,7 +515,7 @@ async def callback(session): async def test_3_2_callback_not_retried_after_commit_timeout(self): listener = OvertCommandListener() client = await self.async_rs_client(event_listeners=[listener]) - coll = client[self.db.name].test + coll = client[self.db.name].coll async def callback(session): await coll.insert_one({}, session=session) @@ -551,7 +551,7 @@ async def callback(session): async def test_3_3_commit_not_retried_after_timeout(self): listener = OvertCommandListener() client = await self.async_rs_client(event_listeners=[listener]) - coll = client[self.db.name].test + coll = client[self.db.name].coll async def callback(session): await coll.insert_one({}, session=session) @@ -591,7 +591,7 @@ async def callback(session): async def test_callback_not_retried_after_csot_timeout(self): listener = OvertCommandListener() client = await self.async_rs_client(event_listeners=[listener]) - coll = client[self.db.name].test + coll = client[self.db.name].coll async def callback(session): await coll.insert_one({}, session=session) @@ -623,7 +623,7 @@ async def callback(session): @async_client_context.require_transactions async def test_in_transaction_property(self): client = async_client_context.client - coll = client.test.testcollection + coll = client.db.collcollection await coll.insert_one({}) self.addAsyncCleanup(coll.drop) @@ -660,7 +660,7 @@ async def callback(session): @async_client_context.require_transactions async def test_4_retry_backoff_is_enforced(self): client = async_client_context.client - coll = client[self.db.name].test + coll = client[self.db.name].coll end = start = no_backoff_time = 0 # Make random.random always return 0 (no backoff) @@ -721,7 +721,7 @@ async def test_case_1(self): # Write concern not inherited from collection object inside transaction # Create a MongoClient running against a configured sharded/replica set/load balanced cluster. client = async_client_context.client - coll = client[self.db.name].test + coll = client[self.db.name].coll await coll.delete_many({}) # Start a new session on the client. async with client.start_session() as s: diff --git a/test/asynchronous/test_unified_format.py b/test/asynchronous/test_unified_format.py index 8136641236..09b495be88 100644 --- a/test/asynchronous/test_unified_format.py +++ b/test/asynchronous/test_unified_format.py @@ -82,13 +82,13 @@ def test_type(self): self.match_evaluator.match_result( { "operationType": "insert", - "ns": {"db": "change-stream-tests", "coll": "test"}, + "ns": {"db": "change-stream-tests", "coll": "coll"}, "fullDocument": {"_id": {"$$type": "objectId"}, "x": 1}, }, { "operationType": "insert", "fullDocument": {"_id": ObjectId("5fc93511ac93941052098f0c"), "x": 1}, - "ns": {"db": "change-stream-tests", "coll": "test"}, + "ns": {"db": "change-stream-tests", "coll": "coll"}, }, ) diff --git a/test/asynchronous/test_versioned_api_integration.py b/test/asynchronous/test_versioned_api_integration.py index 7228b945ab..d5be0b2e16 100644 --- a/test/asynchronous/test_versioned_api_integration.py +++ b/test/asynchronous/test_versioned_api_integration.py @@ -48,7 +48,7 @@ async def test_command_options(self): client = await self.async_rs_or_single_client( server_api=ServerApi("1"), event_listeners=[listener] ) - coll = client.test.test + coll = client.db.coll await coll.insert_many([{} for _ in range(100)]) self.addAsyncCleanup(coll.delete_many, {}) await coll.find(batch_size=25).to_list() @@ -62,7 +62,7 @@ async def test_command_options_txn(self): client = await self.async_rs_or_single_client( server_api=ServerApi("1"), event_listeners=[listener] ) - coll = client.test.test + coll = client.db.coll await coll.insert_many([{} for _ in range(100)]) self.addAsyncCleanup(coll.delete_many, {}) @@ -70,7 +70,7 @@ async def test_command_options_txn(self): async with client.start_session() as s, await s.start_transaction(): await coll.insert_many([{} for _ in range(100)], session=s) await coll.find(batch_size=25, session=s).to_list() - await client.test.command("find", "test", session=s) + await client.db.command("find", "db", session=s) self.assertServerApiInAllCommands(listener.started_events) diff --git a/test/atlas/test_connection.py b/test/atlas/test_connection.py index ac217ab40d..3f84a514f0 100644 --- a/test/atlas/test_connection.py +++ b/test/atlas/test_connection.py @@ -54,7 +54,7 @@ def connect(self, uri): # No TLS error client.admin.command("ping") # No auth error - client.test.test.count_documents({}) + client.db.coll.count_documents({}) @unittest.skipUnless(_has_sni(True), "Free tier requires SNI support") def test_free_tier(self): diff --git a/test/auth/unified/mongodb-oidc-no-retry.json b/test/auth/unified/mongodb-oidc-no-retry.json index b32ada172a..82e05a4790 100644 --- a/test/auth/unified/mongodb-oidc-no-retry.json +++ b/test/auth/unified/mongodb-oidc-no-retry.json @@ -39,7 +39,7 @@ "database": { "id": "database0", "client": "client0", - "databaseName": "test" + "databaseName": "db" } }, { @@ -53,7 +53,7 @@ "initialData": [ { "collectionName": "collName", - "databaseName": "test", + "databaseName": "db", "documents": [] } ], diff --git a/test/auth_aws/test_auth_aws.py b/test/auth_aws/test_auth_aws.py index 9738694d85..6c3d11c066 100644 --- a/test/auth_aws/test_auth_aws.py +++ b/test/auth_aws/test_auth_aws.py @@ -52,7 +52,7 @@ def test_should_fail_without_credentials(self): self.assertTrue(hosts) with MongoClient(hosts) as client: with self.assertRaises(OperationFailure): - client.aws.test.find_one() + client.aws.coll.find_one() def test_should_fail_incorrect_credentials(self): with MongoClient( diff --git a/test/causal_consistency/causal-consistency-clientBulkWrite.json b/test/causal_consistency/causal-consistency-clientBulkWrite.json index c2a04422dd..18cd3697d0 100644 --- a/test/causal_consistency/causal-consistency-clientBulkWrite.json +++ b/test/causal_consistency/causal-consistency-clientBulkWrite.json @@ -35,7 +35,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -50,7 +50,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "causal-consistency-tests", "documents": [ { diff --git a/test/causal_consistency/causal-consistency-write-commands.json b/test/causal_consistency/causal-consistency-write-commands.json index a8140c2b3f..673b1c82b3 100644 --- a/test/causal_consistency/causal-consistency-write-commands.json +++ b/test/causal_consistency/causal-consistency-write-commands.json @@ -34,7 +34,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -49,7 +49,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "causal-consistency-tests", "documents": [ { diff --git a/test/change_streams/unified/change-streams-pre_and_post_images.json b/test/change_streams/unified/change-streams-pre_and_post_images.json index e62fc03459..216205c804 100644 --- a/test/change_streams/unified/change-streams-pre_and_post_images.json +++ b/test/change_streams/unified/change-streams-pre_and_post_images.json @@ -39,13 +39,13 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } } ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "change-stream-tests", "documents": [ { @@ -64,7 +64,7 @@ "arguments": { "commandName": "collMod", "command": { - "collMod": "test", + "collMod": "coll", "changeStreamPreAndPostImages": { "enabled": true } @@ -101,7 +101,7 @@ "operationType": "update", "ns": { "db": "change-stream-tests", - "coll": "test" + "coll": "coll" }, "updateDescription": { "$$type": "object" @@ -144,7 +144,7 @@ "arguments": { "commandName": "collMod", "command": { - "collMod": "test", + "collMod": "coll", "changeStreamPreAndPostImages": { "enabled": false } @@ -181,7 +181,7 @@ "operationType": "update", "ns": { "db": "change-stream-tests", - "coll": "test" + "coll": "coll" }, "updateDescription": { "$$type": "object" @@ -221,7 +221,7 @@ "arguments": { "commandName": "collMod", "command": { - "collMod": "test", + "collMod": "coll", "changeStreamPreAndPostImages": { "enabled": true } @@ -258,7 +258,7 @@ "operationType": "update", "ns": { "db": "change-stream-tests", - "coll": "test" + "coll": "coll" }, "updateDescription": { "$$type": "object" @@ -301,7 +301,7 @@ "arguments": { "commandName": "collMod", "command": { - "collMod": "test", + "collMod": "coll", "changeStreamPreAndPostImages": { "enabled": false } @@ -370,7 +370,7 @@ "arguments": { "commandName": "collMod", "command": { - "collMod": "test", + "collMod": "coll", "changeStreamPreAndPostImages": { "enabled": true } @@ -407,7 +407,7 @@ "operationType": "update", "ns": { "db": "change-stream-tests", - "coll": "test" + "coll": "coll" }, "updateDescription": { "$$type": "object" @@ -449,7 +449,7 @@ "arguments": { "commandName": "collMod", "command": { - "collMod": "test", + "collMod": "coll", "changeStreamPreAndPostImages": { "enabled": false } @@ -486,7 +486,7 @@ "operationType": "update", "ns": { "db": "change-stream-tests", - "coll": "test" + "coll": "coll" }, "updateDescription": { "$$type": "object" @@ -526,7 +526,7 @@ "arguments": { "commandName": "collMod", "command": { - "collMod": "test", + "collMod": "coll", "changeStreamPreAndPostImages": { "enabled": true } @@ -563,7 +563,7 @@ "operationType": "update", "ns": { "db": "change-stream-tests", - "coll": "test" + "coll": "coll" }, "updateDescription": { "$$type": "object" @@ -605,7 +605,7 @@ "arguments": { "commandName": "collMod", "command": { - "collMod": "test", + "collMod": "coll", "changeStreamPreAndPostImages": { "enabled": false } @@ -674,7 +674,7 @@ "arguments": { "commandName": "collMod", "command": { - "collMod": "test", + "collMod": "coll", "changeStreamPreAndPostImages": { "enabled": true } @@ -711,7 +711,7 @@ "operationType": "update", "ns": { "db": "change-stream-tests", - "coll": "test" + "coll": "coll" }, "updateDescription": { "$$type": "object" @@ -753,7 +753,7 @@ "arguments": { "commandName": "collMod", "command": { - "collMod": "test", + "collMod": "coll", "changeStreamPreAndPostImages": { "enabled": false } @@ -790,7 +790,7 @@ "operationType": "update", "ns": { "db": "change-stream-tests", - "coll": "test" + "coll": "coll" }, "updateDescription": { "$$type": "object" diff --git a/test/collection_management/clustered-indexes.json b/test/collection_management/clustered-indexes.json index 9db5ff06d7..5e87aad0f1 100644 --- a/test/collection_management/clustered-indexes.json +++ b/test/collection_management/clustered-indexes.json @@ -27,13 +27,13 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } } ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "ci-tests", "documents": [] } @@ -46,14 +46,14 @@ "name": "dropCollection", "object": "database0", "arguments": { - "collection": "test" + "collection": "coll" } }, { "name": "createCollection", "object": "database0", "arguments": { - "collection": "test", + "collection": "coll", "clusteredIndex": { "key": { "_id": 1 @@ -68,7 +68,7 @@ "object": "testRunner", "arguments": { "databaseName": "ci-tests", - "collectionName": "test" + "collectionName": "coll" } } ], @@ -110,14 +110,14 @@ "name": "dropCollection", "object": "database0", "arguments": { - "collection": "test" + "collection": "coll" } }, { "name": "createCollection", "object": "database0", "arguments": { - "collection": "test", + "collection": "coll", "clusteredIndex": { "key": { "_id": 1 @@ -210,14 +210,14 @@ "name": "dropCollection", "object": "database0", "arguments": { - "collection": "test" + "collection": "coll" } }, { "name": "createCollection", "object": "database0", "arguments": { - "collection": "test", + "collection": "coll", "clusteredIndex": { "key": { "_id": 1 diff --git a/test/collection_management/createCollection-pre_and_post_images.json b/test/collection_management/createCollection-pre_and_post_images.json index f488deacd8..e6d2734ea7 100644 --- a/test/collection_management/createCollection-pre_and_post_images.json +++ b/test/collection_management/createCollection-pre_and_post_images.json @@ -27,7 +27,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } } ], @@ -39,14 +39,14 @@ "name": "dropCollection", "object": "database0", "arguments": { - "collection": "test" + "collection": "coll" } }, { "name": "createCollection", "object": "database0", "arguments": { - "collection": "test", + "collection": "coll", "changeStreamPreAndPostImages": { "enabled": true } @@ -57,7 +57,7 @@ "object": "testRunner", "arguments": { "databaseName": "papi-tests", - "collectionName": "test" + "collectionName": "coll" } } ], diff --git a/test/collection_management/timeseries-collection.json b/test/collection_management/timeseries-collection.json index 2ee52eac41..0e6aac8df2 100644 --- a/test/collection_management/timeseries-collection.json +++ b/test/collection_management/timeseries-collection.json @@ -26,13 +26,13 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } } ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "ts-tests", "documents": [] } @@ -45,14 +45,14 @@ "name": "dropCollection", "object": "database0", "arguments": { - "collection": "test" + "collection": "coll" } }, { "name": "createCollection", "object": "database0", "arguments": { - "collection": "test", + "collection": "coll", "expireAfterSeconds": 604800, "timeseries": { "timeField": "time", @@ -66,7 +66,7 @@ "object": "testRunner", "arguments": { "databaseName": "ts-tests", - "collectionName": "test" + "collectionName": "coll" } } ], @@ -107,14 +107,14 @@ "name": "dropCollection", "object": "database0", "arguments": { - "collection": "test" + "collection": "coll" } }, { "name": "createCollection", "object": "database0", "arguments": { - "collection": "test", + "collection": "coll", "expireAfterSeconds": 604800, "timeseries": { "timeField": "time", @@ -128,7 +128,7 @@ "object": "testRunner", "arguments": { "databaseName": "ts-tests", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -263,14 +263,14 @@ "name": "dropCollection", "object": "database0", "arguments": { - "collection": "test" + "collection": "coll" } }, { "name": "createCollection", "object": "database0", "arguments": { - "collection": "test", + "collection": "coll", "timeseries": { "timeField": "time", "bucketMaxSpanSeconds": 3600, @@ -283,7 +283,7 @@ "object": "testRunner", "arguments": { "databaseName": "ts-tests", - "collectionName": "test" + "collectionName": "coll" } } ], diff --git a/test/command_monitoring/bulkWrite.json b/test/command_monitoring/bulkWrite.json index 49c728442e..f7563bcc99 100644 --- a/test/command_monitoring/bulkWrite.json +++ b/test/command_monitoring/bulkWrite.json @@ -23,13 +23,13 @@ "collection": { "id": "collection", "database": "database", - "collectionName": "test" + "collectionName": "coll" } } ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "command-monitoring-tests", "documents": [ { diff --git a/test/command_monitoring/command.json b/test/command_monitoring/command.json index c28af95fed..6624a41654 100644 --- a/test/command_monitoring/command.json +++ b/test/command_monitoring/command.json @@ -23,13 +23,13 @@ "collection": { "id": "collection", "database": "database", - "collectionName": "test" + "collectionName": "coll" } } ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "command-monitoring-tests", "documents": [ { diff --git a/test/command_monitoring/deleteMany.json b/test/command_monitoring/deleteMany.json index 78ebad1f98..7cebe04c62 100644 --- a/test/command_monitoring/deleteMany.json +++ b/test/command_monitoring/deleteMany.json @@ -23,13 +23,13 @@ "collection": { "id": "collection", "database": "database", - "collectionName": "test" + "collectionName": "coll" } } ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "command-monitoring-tests", "documents": [ { diff --git a/test/command_monitoring/deleteOne.json b/test/command_monitoring/deleteOne.json index 2420794fe5..463e91f4fb 100644 --- a/test/command_monitoring/deleteOne.json +++ b/test/command_monitoring/deleteOne.json @@ -23,13 +23,13 @@ "collection": { "id": "collection", "database": "database", - "collectionName": "test" + "collectionName": "coll" } } ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "command-monitoring-tests", "documents": [ { diff --git a/test/command_monitoring/find.json b/test/command_monitoring/find.json index bc9668499b..272b8e17da 100644 --- a/test/command_monitoring/find.json +++ b/test/command_monitoring/find.json @@ -23,7 +23,7 @@ "collection": { "id": "collection", "database": "database", - "collectionName": "test" + "collectionName": "coll" } } ], @@ -32,7 +32,7 @@ }, "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "command-monitoring-tests", "documents": [ { @@ -354,7 +354,7 @@ "long" ] }, - "collection": "test", + "collection": "coll", "batchSize": 3 }, "commandName": "getMore", @@ -482,7 +482,7 @@ "long" ] }, - "collection": "test", + "collection": "coll", "batchSize": 1 }, "commandName": "getMore", diff --git a/test/command_monitoring/insertMany.json b/test/command_monitoring/insertMany.json index a80a218c67..2a9ef788bb 100644 --- a/test/command_monitoring/insertMany.json +++ b/test/command_monitoring/insertMany.json @@ -23,13 +23,13 @@ "collection": { "id": "collection", "database": "database", - "collectionName": "test" + "collectionName": "coll" } } ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "command-monitoring-tests", "documents": [ { diff --git a/test/command_monitoring/insertOne.json b/test/command_monitoring/insertOne.json index 6ff732e41b..cb6131cc42 100644 --- a/test/command_monitoring/insertOne.json +++ b/test/command_monitoring/insertOne.json @@ -23,13 +23,13 @@ "collection": { "id": "collection", "database": "database", - "collectionName": "test" + "collectionName": "coll" } } ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "command-monitoring-tests", "documents": [ { diff --git a/test/command_monitoring/unacknowledged-client-bulkWrite.json b/test/command_monitoring/unacknowledged-client-bulkWrite.json index 14740cea34..7c8c4cef97 100644 --- a/test/command_monitoring/unacknowledged-client-bulkWrite.json +++ b/test/command_monitoring/unacknowledged-client-bulkWrite.json @@ -33,13 +33,13 @@ "collection": { "id": "collection", "database": "database", - "collectionName": "test" + "collectionName": "coll" } } ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "command-monitoring-tests", "documents": [ { diff --git a/test/command_monitoring/unacknowledgedBulkWrite.json b/test/command_monitoring/unacknowledgedBulkWrite.json index 78ddde767f..7936e56550 100644 --- a/test/command_monitoring/unacknowledgedBulkWrite.json +++ b/test/command_monitoring/unacknowledgedBulkWrite.json @@ -24,7 +24,7 @@ "collection": { "id": "collection", "database": "database", - "collectionName": "test", + "collectionName": "coll", "collectionOptions": { "writeConcern": { "w": 0 @@ -35,7 +35,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "command-monitoring-tests", "documents": [ { diff --git a/test/command_monitoring/updateMany.json b/test/command_monitoring/updateMany.json index b15434226c..37f1ad615b 100644 --- a/test/command_monitoring/updateMany.json +++ b/test/command_monitoring/updateMany.json @@ -23,13 +23,13 @@ "collection": { "id": "collection", "database": "database", - "collectionName": "test" + "collectionName": "coll" } } ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "command-monitoring-tests", "documents": [ { diff --git a/test/command_monitoring/updateOne.json b/test/command_monitoring/updateOne.json index a0ae99e88d..22905bf16e 100644 --- a/test/command_monitoring/updateOne.json +++ b/test/command_monitoring/updateOne.json @@ -23,13 +23,13 @@ "collection": { "id": "collection", "database": "database", - "collectionName": "test" + "collectionName": "coll" } } ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "command-monitoring-tests", "documents": [ { diff --git a/test/command_monitoring/writeConcernError.json b/test/command_monitoring/writeConcernError.json index 455e5422b7..32aa60a606 100644 --- a/test/command_monitoring/writeConcernError.json +++ b/test/command_monitoring/writeConcernError.json @@ -32,13 +32,13 @@ "collection": { "id": "collection", "database": "database", - "collectionName": "test" + "collectionName": "coll" } } ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "command-monitoring-tests", "documents": [ { diff --git a/test/connection_string/test/valid-auth.json b/test/connection_string/test/valid-auth.json index 60f63f4e3f..803ff1a23b 100644 --- a/test/connection_string/test/valid-auth.json +++ b/test/connection_string/test/valid-auth.json @@ -34,7 +34,7 @@ "auth": { "username": "alice", "password": "foo", - "db": "test" + "db": "db" }, "options": null }, diff --git a/test/crud/unified/aggregate-merge-errorResponse.json b/test/crud/unified/aggregate-merge-errorResponse.json index 6c7305fd91..5cb794dab6 100644 --- a/test/crud/unified/aggregate-merge-errorResponse.json +++ b/test/crud/unified/aggregate-merge-errorResponse.json @@ -18,13 +18,13 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } } ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "crud-tests", "documents": [ { diff --git a/test/crud/unified/bulkWrite-arrayFilters.json b/test/crud/unified/bulkWrite-arrayFilters.json index bc4e7b9fcb..407b1e8fa0 100644 --- a/test/crud/unified/bulkWrite-arrayFilters.json +++ b/test/crud/unified/bulkWrite-arrayFilters.json @@ -26,13 +26,13 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } } ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "crud-tests", "documents": [ { @@ -140,7 +140,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "crud-tests", "documents": [ { @@ -246,7 +246,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "crud-tests", "documents": [ { @@ -331,7 +331,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "crud-tests", "documents": [ { diff --git a/test/crud/unified/bulkWrite-errorResponse.json b/test/crud/unified/bulkWrite-errorResponse.json index 157637c713..51481fa650 100644 --- a/test/crud/unified/bulkWrite-errorResponse.json +++ b/test/crud/unified/bulkWrite-errorResponse.json @@ -19,7 +19,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } } ], diff --git a/test/crud/unified/bulkWrite-updateMany-pipeline.json b/test/crud/unified/bulkWrite-updateMany-pipeline.json index e938ea7535..ea58708d20 100644 --- a/test/crud/unified/bulkWrite-updateMany-pipeline.json +++ b/test/crud/unified/bulkWrite-updateMany-pipeline.json @@ -26,13 +26,13 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } } ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "crud-tests", "documents": [ { @@ -127,7 +127,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "crud-tests", "documents": [ { diff --git a/test/crud/unified/bulkWrite-updateOne-pipeline.json b/test/crud/unified/bulkWrite-updateOne-pipeline.json index 769bd106f8..2de9dc3861 100644 --- a/test/crud/unified/bulkWrite-updateOne-pipeline.json +++ b/test/crud/unified/bulkWrite-updateOne-pipeline.json @@ -26,13 +26,13 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } } ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "crud-tests", "documents": [ { @@ -133,7 +133,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "crud-tests", "documents": [ { diff --git a/test/crud/unified/deleteOne-errorResponse.json b/test/crud/unified/deleteOne-errorResponse.json index 1f3a266f1e..7a514e843a 100644 --- a/test/crud/unified/deleteOne-errorResponse.json +++ b/test/crud/unified/deleteOne-errorResponse.json @@ -19,7 +19,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } } ], diff --git a/test/crud/unified/findOneAndUpdate-errorResponse.json b/test/crud/unified/findOneAndUpdate-errorResponse.json index 5023a450f3..4d4603ad5a 100644 --- a/test/crud/unified/findOneAndUpdate-errorResponse.json +++ b/test/crud/unified/findOneAndUpdate-errorResponse.json @@ -18,13 +18,13 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } } ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "crud-tests", "documents": [ { @@ -93,7 +93,7 @@ "name": "modifyCollection", "object": "database0", "arguments": { - "collection": "test", + "collection": "coll", "validator": { "x": { "$type": "string" diff --git a/test/crud/unified/findOneAndUpdate-pipeline.json b/test/crud/unified/findOneAndUpdate-pipeline.json index 81dba9ae93..98c561d46e 100644 --- a/test/crud/unified/findOneAndUpdate-pipeline.json +++ b/test/crud/unified/findOneAndUpdate-pipeline.json @@ -26,13 +26,13 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } } ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "crud-tests", "documents": [ { @@ -109,7 +109,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "crud-tests", "documents": [ { diff --git a/test/crud/unified/insertOne-errorResponse.json b/test/crud/unified/insertOne-errorResponse.json index 04ea6a7451..460728f4ab 100644 --- a/test/crud/unified/insertOne-errorResponse.json +++ b/test/crud/unified/insertOne-errorResponse.json @@ -19,7 +19,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } } ], diff --git a/test/crud/unified/updateMany-pipeline.json b/test/crud/unified/updateMany-pipeline.json index e0f6d9d4a4..5349b54710 100644 --- a/test/crud/unified/updateMany-pipeline.json +++ b/test/crud/unified/updateMany-pipeline.json @@ -26,13 +26,13 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } } ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "crud-tests", "documents": [ { @@ -121,7 +121,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "crud-tests", "documents": [ { diff --git a/test/crud/unified/updateOne-errorResponse.json b/test/crud/unified/updateOne-errorResponse.json index 0ceddbc4fc..ef10ce846b 100644 --- a/test/crud/unified/updateOne-errorResponse.json +++ b/test/crud/unified/updateOne-errorResponse.json @@ -19,7 +19,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } } ], diff --git a/test/crud/unified/updateOne-pipeline.json b/test/crud/unified/updateOne-pipeline.json index 1348c6b53b..af1a9fff77 100644 --- a/test/crud/unified/updateOne-pipeline.json +++ b/test/crud/unified/updateOne-pipeline.json @@ -26,13 +26,13 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } } ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "crud-tests", "documents": [ { @@ -127,7 +127,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "crud-tests", "documents": [ { diff --git a/test/csot/bulkWrite.json b/test/csot/bulkWrite.json index 9a05809f77..e10909b5f7 100644 --- a/test/csot/bulkWrite.json +++ b/test/csot/bulkWrite.json @@ -29,7 +29,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -43,7 +43,7 @@ "initialData": [ { "collectionName": "coll", - "databaseName": "test", + "databaseName": "db", "documents": [] } ], @@ -116,7 +116,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll" } @@ -125,7 +125,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll", "maxTimeMS": { @@ -140,7 +140,7 @@ { "commandStartedEvent": { "commandName": "update", - "databaseName": "test", + "databaseName": "db", "command": { "update": "coll", "maxTimeMS": { diff --git a/test/csot/change-streams.json b/test/csot/change-streams.json index 8cffb08e26..386aeab84c 100644 --- a/test/csot/change-streams.json +++ b/test/csot/change-streams.json @@ -33,7 +33,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -47,7 +47,7 @@ "initialData": [ { "collectionName": "coll", - "databaseName": "test", + "databaseName": "db", "documents": [] } ], @@ -128,7 +128,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll", "maxTimeMS": { @@ -189,7 +189,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll", "maxTimeMS": { @@ -204,7 +204,7 @@ { "commandStartedEvent": { "commandName": "getMore", - "databaseName": "test", + "databaseName": "db", "command": { "getMore": { "$$type": [ @@ -270,7 +270,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll", "maxTimeMS": { @@ -285,7 +285,7 @@ { "commandStartedEvent": { "commandName": "getMore", - "databaseName": "test", + "databaseName": "db", "command": { "getMore": { "$$type": [ @@ -354,7 +354,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll", "maxTimeMS": { @@ -369,7 +369,7 @@ { "commandStartedEvent": { "commandName": "getMore", - "databaseName": "test", + "databaseName": "db", "command": { "getMore": { "$$type": [ @@ -387,7 +387,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll", "maxTimeMS": { @@ -455,7 +455,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll", "maxTimeMS": { @@ -470,7 +470,7 @@ { "commandStartedEvent": { "commandName": "getMore", - "databaseName": "test", + "databaseName": "db", "command": { "getMore": { "$$type": [ @@ -485,7 +485,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll", "maxTimeMS": { @@ -500,7 +500,7 @@ { "commandStartedEvent": { "commandName": "getMore", - "databaseName": "test", + "databaseName": "db", "command": { "getMore": { "$$type": [ @@ -563,7 +563,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll", "maxTimeMS": { @@ -578,7 +578,7 @@ { "commandStartedEvent": { "commandName": "getMore", - "databaseName": "test", + "databaseName": "db", "command": { "getMore": { "$$type": [ diff --git a/test/csot/close-cursors.json b/test/csot/close-cursors.json index 79b0de7b6a..b1ca4cf5c1 100644 --- a/test/csot/close-cursors.json +++ b/test/csot/close-cursors.json @@ -28,7 +28,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -42,7 +42,7 @@ "initialData": [ { "collectionName": "coll", - "databaseName": "test", + "databaseName": "db", "documents": [ { "_id": 0 diff --git a/test/csot/command-execution.json b/test/csot/command-execution.json index 212cd41089..a5863d4ddf 100644 --- a/test/csot/command-execution.json +++ b/test/csot/command-execution.json @@ -23,12 +23,12 @@ "initialData": [ { "collectionName": "coll", - "databaseName": "test", + "databaseName": "db", "documents": [] }, { "collectionName": "timeoutColl", - "databaseName": "test", + "databaseName": "db", "documents": [] } ], @@ -82,7 +82,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -129,7 +129,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "timeoutColl" } @@ -138,7 +138,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "timeoutColl", "maxTimeMS": { @@ -200,7 +200,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -274,7 +274,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "timeoutColl" } @@ -333,7 +333,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -373,7 +373,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "timeoutColl" } @@ -382,7 +382,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "timeoutColl", "maxTimeMS": { diff --git a/test/csot/convenient-transactions.json b/test/csot/convenient-transactions.json index 3400b82ba9..5ef5828dd2 100644 --- a/test/csot/convenient-transactions.json +++ b/test/csot/convenient-transactions.json @@ -36,7 +36,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -56,7 +56,7 @@ "initialData": [ { "collectionName": "coll", - "databaseName": "test", + "databaseName": "db", "documents": [] } ], @@ -162,7 +162,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll", "maxTimeMS": { @@ -177,7 +177,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll", "maxTimeMS": { diff --git a/test/csot/cursors.json b/test/csot/cursors.json index 36949d7509..4046211ef3 100644 --- a/test/csot/cursors.json +++ b/test/csot/cursors.json @@ -11,7 +11,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -25,7 +25,7 @@ "initialData": [ { "collectionName": "coll", - "databaseName": "test", + "databaseName": "db", "documents": [] } ], diff --git a/test/csot/deprecated-options.json b/test/csot/deprecated-options.json index 647e1bf792..d91f4dd9cf 100644 --- a/test/csot/deprecated-options.json +++ b/test/csot/deprecated-options.json @@ -21,7 +21,7 @@ "initialData": [ { "collectionName": "coll", - "databaseName": "test", + "databaseName": "db", "documents": [] } ], @@ -53,7 +53,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -164,7 +164,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -253,7 +253,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -344,7 +344,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -455,7 +455,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -544,7 +544,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -608,7 +608,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll", "maxTimeMS": { @@ -665,7 +665,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -709,7 +709,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll", "writeConcern": { @@ -767,7 +767,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -816,7 +816,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll", "writeConcern": { @@ -868,7 +868,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -949,7 +949,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -1030,7 +1030,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -1110,7 +1110,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -1190,7 +1190,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -1271,7 +1271,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -1352,7 +1352,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -1440,7 +1440,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -1488,7 +1488,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": 1, "writeConcern": { @@ -1531,7 +1531,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -1580,7 +1580,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": 1, "maxTimeMS": { @@ -1614,7 +1614,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -1695,7 +1695,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -1736,7 +1736,7 @@ { "commandStartedEvent": { "commandName": "listCollections", - "databaseName": "test", + "databaseName": "db", "command": { "listCollections": 1, "writeConcern": { @@ -1776,7 +1776,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -1857,7 +1857,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -1898,7 +1898,7 @@ { "commandStartedEvent": { "commandName": "listCollections", - "databaseName": "test", + "databaseName": "db", "command": { "listCollections": 1, "writeConcern": { @@ -1938,7 +1938,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -2022,7 +2022,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -2066,7 +2066,7 @@ { "commandStartedEvent": { "commandName": "ping", - "databaseName": "test", + "databaseName": "db", "command": { "ping": 1, "writeConcern": { @@ -2106,7 +2106,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -2187,7 +2187,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -2228,7 +2228,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": 1, "writeConcern": { @@ -2268,7 +2268,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -2349,7 +2349,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -2390,7 +2390,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll", "writeConcern": { @@ -2433,7 +2433,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -2475,7 +2475,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll", "maxTimeMS": { @@ -2509,7 +2509,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -2590,7 +2590,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -2631,7 +2631,7 @@ { "commandStartedEvent": { "commandName": "count", - "databaseName": "test", + "databaseName": "db", "command": { "count": "coll", "writeConcern": { @@ -2674,7 +2674,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -2716,7 +2716,7 @@ { "commandStartedEvent": { "commandName": "count", - "databaseName": "test", + "databaseName": "db", "command": { "count": "coll", "maxTimeMS": { @@ -2750,7 +2750,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -2831,7 +2831,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -2872,7 +2872,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll", "writeConcern": { @@ -2912,7 +2912,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -2992,7 +2992,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -3032,7 +3032,7 @@ { "commandStartedEvent": { "commandName": "count", - "databaseName": "test", + "databaseName": "db", "command": { "count": "coll", "writeConcern": { @@ -3075,7 +3075,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -3116,7 +3116,7 @@ { "commandStartedEvent": { "commandName": "count", - "databaseName": "test", + "databaseName": "db", "command": { "count": "coll", "maxTimeMS": { @@ -3150,7 +3150,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -3232,7 +3232,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -3274,7 +3274,7 @@ { "commandStartedEvent": { "commandName": "distinct", - "databaseName": "test", + "databaseName": "db", "command": { "distinct": "coll", "writeConcern": { @@ -3317,7 +3317,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -3360,7 +3360,7 @@ { "commandStartedEvent": { "commandName": "distinct", - "databaseName": "test", + "databaseName": "db", "command": { "distinct": "coll", "maxTimeMS": { @@ -3394,7 +3394,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -3475,7 +3475,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -3516,7 +3516,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "coll", "writeConcern": { @@ -3559,7 +3559,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -3601,7 +3601,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "coll", "maxTimeMS": { @@ -3635,7 +3635,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -3716,7 +3716,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -3757,7 +3757,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "coll", "writeConcern": { @@ -3800,7 +3800,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -3842,7 +3842,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "coll", "maxTimeMS": { @@ -3876,7 +3876,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -3956,7 +3956,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -3996,7 +3996,7 @@ { "commandStartedEvent": { "commandName": "listIndexes", - "databaseName": "test", + "databaseName": "db", "command": { "listIndexes": "coll", "writeConcern": { @@ -4036,7 +4036,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -4116,7 +4116,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -4156,7 +4156,7 @@ { "commandStartedEvent": { "commandName": "listIndexes", - "databaseName": "test", + "databaseName": "db", "command": { "listIndexes": "coll", "writeConcern": { @@ -4196,7 +4196,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -4277,7 +4277,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -4318,7 +4318,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll", "writeConcern": { @@ -4358,7 +4358,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -4441,7 +4441,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -4484,7 +4484,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll", "writeConcern": { @@ -4524,7 +4524,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -4609,7 +4609,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -4654,7 +4654,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll", "writeConcern": { @@ -4694,7 +4694,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -4775,7 +4775,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -4816,7 +4816,7 @@ { "commandStartedEvent": { "commandName": "delete", - "databaseName": "test", + "databaseName": "db", "command": { "delete": "coll", "writeConcern": { @@ -4856,7 +4856,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -4937,7 +4937,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -4978,7 +4978,7 @@ { "commandStartedEvent": { "commandName": "delete", - "databaseName": "test", + "databaseName": "db", "command": { "delete": "coll", "writeConcern": { @@ -5018,7 +5018,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -5102,7 +5102,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -5146,7 +5146,7 @@ { "commandStartedEvent": { "commandName": "update", - "databaseName": "test", + "databaseName": "db", "command": { "update": "coll", "writeConcern": { @@ -5186,7 +5186,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -5272,7 +5272,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -5318,7 +5318,7 @@ { "commandStartedEvent": { "commandName": "update", - "databaseName": "test", + "databaseName": "db", "command": { "update": "coll", "writeConcern": { @@ -5358,7 +5358,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -5444,7 +5444,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -5490,7 +5490,7 @@ { "commandStartedEvent": { "commandName": "update", - "databaseName": "test", + "databaseName": "db", "command": { "update": "coll", "writeConcern": { @@ -5530,7 +5530,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -5611,7 +5611,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -5652,7 +5652,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll", "writeConcern": { @@ -5695,7 +5695,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -5737,7 +5737,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll", "maxTimeMS": { @@ -5771,7 +5771,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -5855,7 +5855,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -5899,7 +5899,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll", "writeConcern": { @@ -5942,7 +5942,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -5987,7 +5987,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll", "maxTimeMS": { @@ -6021,7 +6021,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -6107,7 +6107,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -6153,7 +6153,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll", "writeConcern": { @@ -6196,7 +6196,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -6243,7 +6243,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll", "maxTimeMS": { @@ -6277,7 +6277,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -6366,7 +6366,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -6415,7 +6415,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll", "writeConcern": { @@ -6455,7 +6455,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -6539,7 +6539,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -6583,7 +6583,7 @@ { "commandStartedEvent": { "commandName": "createIndexes", - "databaseName": "test", + "databaseName": "db", "command": { "createIndexes": "coll", "writeConcern": { @@ -6626,7 +6626,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -6671,7 +6671,7 @@ { "commandStartedEvent": { "commandName": "createIndexes", - "databaseName": "test", + "databaseName": "db", "command": { "createIndexes": "coll", "maxTimeMS": { @@ -6705,7 +6705,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -6797,7 +6797,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -6849,13 +6849,13 @@ { "commandStartedEvent": { "commandName": "createIndexes", - "databaseName": "test" + "databaseName": "db" } }, { "commandStartedEvent": { "commandName": "dropIndexes", - "databaseName": "test", + "databaseName": "db", "command": { "dropIndexes": "coll", "writeConcern": { @@ -6898,7 +6898,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -6950,13 +6950,13 @@ { "commandStartedEvent": { "commandName": "createIndexes", - "databaseName": "test" + "databaseName": "db" } }, { "commandStartedEvent": { "commandName": "dropIndexes", - "databaseName": "test", + "databaseName": "db", "command": { "dropIndexes": "coll", "maxTimeMS": { @@ -6990,7 +6990,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -7081,7 +7081,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -7121,7 +7121,7 @@ { "commandStartedEvent": { "commandName": "dropIndexes", - "databaseName": "test", + "databaseName": "db", "command": { "dropIndexes": "coll", "writeConcern": { @@ -7164,7 +7164,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -7205,7 +7205,7 @@ { "commandStartedEvent": { "commandName": "dropIndexes", - "databaseName": "test", + "databaseName": "db", "command": { "dropIndexes": "coll", "maxTimeMS": { diff --git a/test/csot/error-transformations.json b/test/csot/error-transformations.json index 89be49f0a4..9bcde1cdc1 100644 --- a/test/csot/error-transformations.json +++ b/test/csot/error-transformations.json @@ -40,7 +40,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -54,7 +54,7 @@ "initialData": [ { "collectionName": "coll", - "databaseName": "test", + "databaseName": "db", "documents": [] } ], @@ -101,7 +101,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll", "maxTimeMS": { @@ -162,7 +162,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll", "maxTimeMS": { diff --git a/test/csot/global-timeoutMS.json b/test/csot/global-timeoutMS.json index 9d8046d1bf..6a50d794ee 100644 --- a/test/csot/global-timeoutMS.json +++ b/test/csot/global-timeoutMS.json @@ -21,7 +21,7 @@ "initialData": [ { "collectionName": "coll", - "databaseName": "test", + "databaseName": "db", "documents": [] } ], @@ -52,7 +52,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -146,7 +146,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -233,7 +233,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -324,7 +324,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -408,7 +408,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -502,7 +502,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -589,7 +589,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -647,7 +647,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": 1, "maxTimeMS": { @@ -690,7 +690,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -745,7 +745,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": 1, "maxTimeMS": { @@ -784,7 +784,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -835,7 +835,7 @@ { "commandStartedEvent": { "commandName": "listCollections", - "databaseName": "test", + "databaseName": "db", "command": { "listCollections": 1, "maxTimeMS": { @@ -878,7 +878,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -926,7 +926,7 @@ { "commandStartedEvent": { "commandName": "listCollections", - "databaseName": "test", + "databaseName": "db", "command": { "listCollections": 1, "maxTimeMS": { @@ -965,7 +965,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -1016,7 +1016,7 @@ { "commandStartedEvent": { "commandName": "listCollections", - "databaseName": "test", + "databaseName": "db", "command": { "listCollections": 1, "maxTimeMS": { @@ -1059,7 +1059,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -1107,7 +1107,7 @@ { "commandStartedEvent": { "commandName": "listCollections", - "databaseName": "test", + "databaseName": "db", "command": { "listCollections": 1, "maxTimeMS": { @@ -1146,7 +1146,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -1200,7 +1200,7 @@ { "commandStartedEvent": { "commandName": "ping", - "databaseName": "test", + "databaseName": "db", "command": { "ping": 1, "maxTimeMS": { @@ -1243,7 +1243,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -1294,7 +1294,7 @@ { "commandStartedEvent": { "commandName": "ping", - "databaseName": "test", + "databaseName": "db", "command": { "ping": 1, "maxTimeMS": { @@ -1333,7 +1333,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -1384,7 +1384,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": 1, "maxTimeMS": { @@ -1427,7 +1427,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -1475,7 +1475,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": 1, "maxTimeMS": { @@ -1514,7 +1514,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -1565,7 +1565,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll", "maxTimeMS": { @@ -1608,7 +1608,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -1656,7 +1656,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll", "maxTimeMS": { @@ -1695,7 +1695,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -1746,7 +1746,7 @@ { "commandStartedEvent": { "commandName": "count", - "databaseName": "test", + "databaseName": "db", "command": { "count": "coll", "maxTimeMS": { @@ -1789,7 +1789,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -1837,7 +1837,7 @@ { "commandStartedEvent": { "commandName": "count", - "databaseName": "test", + "databaseName": "db", "command": { "count": "coll", "maxTimeMS": { @@ -1876,7 +1876,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -1927,7 +1927,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll", "maxTimeMS": { @@ -1970,7 +1970,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -2018,7 +2018,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll", "maxTimeMS": { @@ -2057,7 +2057,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -2105,7 +2105,7 @@ { "commandStartedEvent": { "commandName": "count", - "databaseName": "test", + "databaseName": "db", "command": { "count": "coll", "maxTimeMS": { @@ -2148,7 +2148,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -2193,7 +2193,7 @@ { "commandStartedEvent": { "commandName": "count", - "databaseName": "test", + "databaseName": "db", "command": { "count": "coll", "maxTimeMS": { @@ -2232,7 +2232,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -2284,7 +2284,7 @@ { "commandStartedEvent": { "commandName": "distinct", - "databaseName": "test", + "databaseName": "db", "command": { "distinct": "coll", "maxTimeMS": { @@ -2327,7 +2327,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -2376,7 +2376,7 @@ { "commandStartedEvent": { "commandName": "distinct", - "databaseName": "test", + "databaseName": "db", "command": { "distinct": "coll", "maxTimeMS": { @@ -2415,7 +2415,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -2466,7 +2466,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "coll", "maxTimeMS": { @@ -2509,7 +2509,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -2557,7 +2557,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "coll", "maxTimeMS": { @@ -2596,7 +2596,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -2647,7 +2647,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "coll", "maxTimeMS": { @@ -2690,7 +2690,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -2738,7 +2738,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "coll", "maxTimeMS": { @@ -2777,7 +2777,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -2825,7 +2825,7 @@ { "commandStartedEvent": { "commandName": "listIndexes", - "databaseName": "test", + "databaseName": "db", "command": { "listIndexes": "coll", "maxTimeMS": { @@ -2868,7 +2868,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -2913,7 +2913,7 @@ { "commandStartedEvent": { "commandName": "listIndexes", - "databaseName": "test", + "databaseName": "db", "command": { "listIndexes": "coll", "maxTimeMS": { @@ -2952,7 +2952,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -3000,7 +3000,7 @@ { "commandStartedEvent": { "commandName": "listIndexes", - "databaseName": "test", + "databaseName": "db", "command": { "listIndexes": "coll", "maxTimeMS": { @@ -3043,7 +3043,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -3088,7 +3088,7 @@ { "commandStartedEvent": { "commandName": "listIndexes", - "databaseName": "test", + "databaseName": "db", "command": { "listIndexes": "coll", "maxTimeMS": { @@ -3127,7 +3127,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -3178,7 +3178,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll", "maxTimeMS": { @@ -3221,7 +3221,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -3269,7 +3269,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll", "maxTimeMS": { @@ -3308,7 +3308,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -3361,7 +3361,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll", "maxTimeMS": { @@ -3404,7 +3404,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -3454,7 +3454,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll", "maxTimeMS": { @@ -3493,7 +3493,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -3548,7 +3548,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll", "maxTimeMS": { @@ -3591,7 +3591,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -3643,7 +3643,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll", "maxTimeMS": { @@ -3682,7 +3682,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -3733,7 +3733,7 @@ { "commandStartedEvent": { "commandName": "delete", - "databaseName": "test", + "databaseName": "db", "command": { "delete": "coll", "maxTimeMS": { @@ -3776,7 +3776,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -3824,7 +3824,7 @@ { "commandStartedEvent": { "commandName": "delete", - "databaseName": "test", + "databaseName": "db", "command": { "delete": "coll", "maxTimeMS": { @@ -3863,7 +3863,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -3914,7 +3914,7 @@ { "commandStartedEvent": { "commandName": "delete", - "databaseName": "test", + "databaseName": "db", "command": { "delete": "coll", "maxTimeMS": { @@ -3957,7 +3957,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -4005,7 +4005,7 @@ { "commandStartedEvent": { "commandName": "delete", - "databaseName": "test", + "databaseName": "db", "command": { "delete": "coll", "maxTimeMS": { @@ -4044,7 +4044,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -4098,7 +4098,7 @@ { "commandStartedEvent": { "commandName": "update", - "databaseName": "test", + "databaseName": "db", "command": { "update": "coll", "maxTimeMS": { @@ -4141,7 +4141,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -4192,7 +4192,7 @@ { "commandStartedEvent": { "commandName": "update", - "databaseName": "test", + "databaseName": "db", "command": { "update": "coll", "maxTimeMS": { @@ -4231,7 +4231,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -4287,7 +4287,7 @@ { "commandStartedEvent": { "commandName": "update", - "databaseName": "test", + "databaseName": "db", "command": { "update": "coll", "maxTimeMS": { @@ -4330,7 +4330,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -4383,7 +4383,7 @@ { "commandStartedEvent": { "commandName": "update", - "databaseName": "test", + "databaseName": "db", "command": { "update": "coll", "maxTimeMS": { @@ -4422,7 +4422,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -4478,7 +4478,7 @@ { "commandStartedEvent": { "commandName": "update", - "databaseName": "test", + "databaseName": "db", "command": { "update": "coll", "maxTimeMS": { @@ -4521,7 +4521,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -4574,7 +4574,7 @@ { "commandStartedEvent": { "commandName": "update", - "databaseName": "test", + "databaseName": "db", "command": { "update": "coll", "maxTimeMS": { @@ -4613,7 +4613,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -4664,7 +4664,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll", "maxTimeMS": { @@ -4707,7 +4707,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -4755,7 +4755,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll", "maxTimeMS": { @@ -4794,7 +4794,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -4848,7 +4848,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll", "maxTimeMS": { @@ -4891,7 +4891,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -4942,7 +4942,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll", "maxTimeMS": { @@ -4981,7 +4981,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -5037,7 +5037,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll", "maxTimeMS": { @@ -5080,7 +5080,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -5133,7 +5133,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll", "maxTimeMS": { @@ -5172,7 +5172,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -5231,7 +5231,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll", "maxTimeMS": { @@ -5274,7 +5274,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -5330,7 +5330,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll", "maxTimeMS": { @@ -5369,7 +5369,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -5423,7 +5423,7 @@ { "commandStartedEvent": { "commandName": "createIndexes", - "databaseName": "test", + "databaseName": "db", "command": { "createIndexes": "coll", "maxTimeMS": { @@ -5466,7 +5466,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -5517,7 +5517,7 @@ { "commandStartedEvent": { "commandName": "createIndexes", - "databaseName": "test", + "databaseName": "db", "command": { "createIndexes": "coll", "maxTimeMS": { @@ -5556,7 +5556,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -5607,7 +5607,7 @@ { "commandStartedEvent": { "commandName": "dropIndexes", - "databaseName": "test", + "databaseName": "db", "command": { "dropIndexes": "coll", "maxTimeMS": { @@ -5650,7 +5650,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -5708,13 +5708,13 @@ { "commandStartedEvent": { "commandName": "createIndexes", - "databaseName": "test" + "databaseName": "db" } }, { "commandStartedEvent": { "commandName": "dropIndexes", - "databaseName": "test", + "databaseName": "db", "command": { "dropIndexes": "coll", "maxTimeMS": { @@ -5753,7 +5753,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -5801,7 +5801,7 @@ { "commandStartedEvent": { "commandName": "dropIndexes", - "databaseName": "test", + "databaseName": "db", "command": { "dropIndexes": "coll", "maxTimeMS": { @@ -5844,7 +5844,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -5889,7 +5889,7 @@ { "commandStartedEvent": { "commandName": "dropIndexes", - "databaseName": "test", + "databaseName": "db", "command": { "dropIndexes": "coll", "maxTimeMS": { diff --git a/test/csot/gridfs-advanced.json b/test/csot/gridfs-advanced.json index c6c0944d2f..4815d5c431 100644 --- a/test/csot/gridfs-advanced.json +++ b/test/csot/gridfs-advanced.json @@ -30,7 +30,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -57,7 +57,7 @@ "initialData": [ { "collectionName": "fs.files", - "databaseName": "test", + "databaseName": "db", "documents": [ { "_id": { @@ -77,7 +77,7 @@ }, { "collectionName": "fs.chunks", - "databaseName": "test", + "databaseName": "db", "documents": [ { "_id": { @@ -155,7 +155,7 @@ { "commandStartedEvent": { "commandName": "update", - "databaseName": "test", + "databaseName": "db", "command": { "update": "fs.files", "maxTimeMS": { @@ -215,7 +215,7 @@ { "commandStartedEvent": { "commandName": "update", - "databaseName": "test", + "databaseName": "db", "command": { "update": "fs.files", "maxTimeMS": { @@ -301,7 +301,7 @@ { "commandStartedEvent": { "commandName": "drop", - "databaseName": "test", + "databaseName": "db", "command": { "drop": "fs.files", "maxTimeMS": { diff --git a/test/csot/gridfs-delete.json b/test/csot/gridfs-delete.json index 9f4980114b..982e1156ec 100644 --- a/test/csot/gridfs-delete.json +++ b/test/csot/gridfs-delete.json @@ -30,7 +30,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -57,7 +57,7 @@ "initialData": [ { "collectionName": "fs.files", - "databaseName": "test", + "databaseName": "db", "documents": [ { "_id": { @@ -77,7 +77,7 @@ }, { "collectionName": "fs.chunks", - "databaseName": "test", + "databaseName": "db", "documents": [ { "_id": { @@ -191,7 +191,7 @@ { "commandStartedEvent": { "commandName": "delete", - "databaseName": "test", + "databaseName": "db", "command": { "delete": "fs.files", "maxTimeMS": { diff --git a/test/csot/gridfs-download.json b/test/csot/gridfs-download.json index 8542f69e89..b00e5f802f 100644 --- a/test/csot/gridfs-download.json +++ b/test/csot/gridfs-download.json @@ -30,7 +30,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -57,7 +57,7 @@ "initialData": [ { "collectionName": "fs.files", - "databaseName": "test", + "databaseName": "db", "documents": [ { "_id": { @@ -77,7 +77,7 @@ }, { "collectionName": "fs.chunks", - "databaseName": "test", + "databaseName": "db", "documents": [ { "_id": { @@ -191,7 +191,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "fs.files", "maxTimeMS": { @@ -250,7 +250,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "fs.files", "maxTimeMS": { @@ -265,7 +265,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "fs.chunks", "maxTimeMS": { @@ -324,7 +324,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "fs.files", "maxTimeMS": { @@ -339,7 +339,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "fs.chunks", "maxTimeMS": { diff --git a/test/csot/gridfs-find.json b/test/csot/gridfs-find.json index 7409036284..17a12e1fdd 100644 --- a/test/csot/gridfs-find.json +++ b/test/csot/gridfs-find.json @@ -30,7 +30,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -57,12 +57,12 @@ "initialData": [ { "collectionName": "fs.files", - "databaseName": "test", + "databaseName": "db", "documents": [] }, { "collectionName": "fs.chunks", - "databaseName": "test", + "databaseName": "db", "documents": [] } ], @@ -106,7 +106,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "fs.files", "maxTimeMS": { @@ -163,7 +163,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "fs.files", "maxTimeMS": { diff --git a/test/csot/gridfs-upload.json b/test/csot/gridfs-upload.json index b3f174973d..171d0aad8c 100644 --- a/test/csot/gridfs-upload.json +++ b/test/csot/gridfs-upload.json @@ -27,7 +27,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -54,12 +54,12 @@ "initialData": [ { "collectionName": "fs.files", - "databaseName": "test", + "databaseName": "db", "documents": [] }, { "collectionName": "fs.chunks", - "databaseName": "test", + "databaseName": "db", "documents": [] } ], diff --git a/test/csot/legacy-timeouts.json b/test/csot/legacy-timeouts.json index 535425c934..ab41e2a870 100644 --- a/test/csot/legacy-timeouts.json +++ b/test/csot/legacy-timeouts.json @@ -9,7 +9,7 @@ "initialData": [ { "collectionName": "coll", - "databaseName": "test", + "databaseName": "db", "documents": [] } ], @@ -37,7 +37,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -67,7 +67,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll", "maxTimeMS": { @@ -103,7 +103,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -133,7 +133,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll", "maxTimeMS": { @@ -169,7 +169,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -199,7 +199,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll", "maxTimeMS": { @@ -235,7 +235,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -263,7 +263,7 @@ { "commandStartedEvent": { "commandName": "count", - "databaseName": "test", + "databaseName": "db", "command": { "count": "coll", "maxTimeMS": 50000 @@ -302,7 +302,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -352,7 +352,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll", "maxTimeMS": { diff --git a/test/csot/non-tailable-cursors.json b/test/csot/non-tailable-cursors.json index 58c59cb32d..61ba6f5354 100644 --- a/test/csot/non-tailable-cursors.json +++ b/test/csot/non-tailable-cursors.json @@ -34,7 +34,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -48,7 +48,7 @@ "initialData": [ { "collectionName": "coll", - "databaseName": "test", + "databaseName": "db", "documents": [ { "_id": 0 @@ -63,7 +63,7 @@ }, { "collectionName": "aggregateOutputColl", - "databaseName": "test", + "databaseName": "db", "documents": [] } ], @@ -110,7 +110,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "coll", "maxTimeMS": { @@ -170,7 +170,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "coll", "maxTimeMS": { @@ -185,7 +185,7 @@ { "commandStartedEvent": { "commandName": "getMore", - "databaseName": "test", + "databaseName": "db", "command": { "getMore": { "$$type": [ @@ -249,7 +249,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "coll", "maxTimeMS": { @@ -264,7 +264,7 @@ { "commandStartedEvent": { "commandName": "getMore", - "databaseName": "test", + "databaseName": "db", "command": { "getMore": { "$$type": [ @@ -325,7 +325,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "coll", "maxTimeMS": { @@ -380,7 +380,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "coll", "maxTimeMS": { @@ -392,7 +392,7 @@ { "commandStartedEvent": { "commandName": "getMore", - "databaseName": "test", + "databaseName": "db", "command": { "getMore": { "$$type": [ @@ -454,7 +454,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "coll", "maxTimeMS": { @@ -466,7 +466,7 @@ { "commandStartedEvent": { "commandName": "getMore", - "databaseName": "test", + "databaseName": "db", "command": { "getMore": { "$$type": [ diff --git a/test/csot/override-operation-timeoutMS.json b/test/csot/override-operation-timeoutMS.json index f33f876137..80506acf88 100644 --- a/test/csot/override-operation-timeoutMS.json +++ b/test/csot/override-operation-timeoutMS.json @@ -36,7 +36,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -50,7 +50,7 @@ "initialData": [ { "collectionName": "coll", - "databaseName": "test", + "databaseName": "db", "documents": [] } ], @@ -420,7 +420,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": 1, "maxTimeMS": { @@ -482,7 +482,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": 1, "maxTimeMS": { @@ -534,7 +534,7 @@ { "commandStartedEvent": { "commandName": "listCollections", - "databaseName": "test", + "databaseName": "db", "command": { "listCollections": 1, "maxTimeMS": { @@ -589,7 +589,7 @@ { "commandStartedEvent": { "commandName": "listCollections", - "databaseName": "test", + "databaseName": "db", "command": { "listCollections": 1, "maxTimeMS": { @@ -641,7 +641,7 @@ { "commandStartedEvent": { "commandName": "listCollections", - "databaseName": "test", + "databaseName": "db", "command": { "listCollections": 1, "maxTimeMS": { @@ -696,7 +696,7 @@ { "commandStartedEvent": { "commandName": "listCollections", - "databaseName": "test", + "databaseName": "db", "command": { "listCollections": 1, "maxTimeMS": { @@ -751,7 +751,7 @@ { "commandStartedEvent": { "commandName": "ping", - "databaseName": "test", + "databaseName": "db", "command": { "ping": 1, "maxTimeMS": { @@ -809,7 +809,7 @@ { "commandStartedEvent": { "commandName": "ping", - "databaseName": "test", + "databaseName": "db", "command": { "ping": 1, "maxTimeMS": { @@ -861,7 +861,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": 1, "maxTimeMS": { @@ -916,7 +916,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": 1, "maxTimeMS": { @@ -968,7 +968,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll", "maxTimeMS": { @@ -1023,7 +1023,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll", "maxTimeMS": { @@ -1075,7 +1075,7 @@ { "commandStartedEvent": { "commandName": "count", - "databaseName": "test", + "databaseName": "db", "command": { "count": "coll", "maxTimeMS": { @@ -1130,7 +1130,7 @@ { "commandStartedEvent": { "commandName": "count", - "databaseName": "test", + "databaseName": "db", "command": { "count": "coll", "maxTimeMS": { @@ -1182,7 +1182,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll", "maxTimeMS": { @@ -1237,7 +1237,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll", "maxTimeMS": { @@ -1288,7 +1288,7 @@ { "commandStartedEvent": { "commandName": "count", - "databaseName": "test", + "databaseName": "db", "command": { "count": "coll", "maxTimeMS": { @@ -1342,7 +1342,7 @@ { "commandStartedEvent": { "commandName": "count", - "databaseName": "test", + "databaseName": "db", "command": { "count": "coll", "maxTimeMS": { @@ -1395,7 +1395,7 @@ { "commandStartedEvent": { "commandName": "distinct", - "databaseName": "test", + "databaseName": "db", "command": { "distinct": "coll", "maxTimeMS": { @@ -1451,7 +1451,7 @@ { "commandStartedEvent": { "commandName": "distinct", - "databaseName": "test", + "databaseName": "db", "command": { "distinct": "coll", "maxTimeMS": { @@ -1503,7 +1503,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "coll", "maxTimeMS": { @@ -1558,7 +1558,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "coll", "maxTimeMS": { @@ -1610,7 +1610,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "coll", "maxTimeMS": { @@ -1665,7 +1665,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "coll", "maxTimeMS": { @@ -1716,7 +1716,7 @@ { "commandStartedEvent": { "commandName": "listIndexes", - "databaseName": "test", + "databaseName": "db", "command": { "listIndexes": "coll", "maxTimeMS": { @@ -1770,7 +1770,7 @@ { "commandStartedEvent": { "commandName": "listIndexes", - "databaseName": "test", + "databaseName": "db", "command": { "listIndexes": "coll", "maxTimeMS": { @@ -1821,7 +1821,7 @@ { "commandStartedEvent": { "commandName": "listIndexes", - "databaseName": "test", + "databaseName": "db", "command": { "listIndexes": "coll", "maxTimeMS": { @@ -1875,7 +1875,7 @@ { "commandStartedEvent": { "commandName": "listIndexes", - "databaseName": "test", + "databaseName": "db", "command": { "listIndexes": "coll", "maxTimeMS": { @@ -1927,7 +1927,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll", "maxTimeMS": { @@ -1982,7 +1982,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll", "maxTimeMS": { @@ -2036,7 +2036,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll", "maxTimeMS": { @@ -2093,7 +2093,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll", "maxTimeMS": { @@ -2149,7 +2149,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll", "maxTimeMS": { @@ -2208,7 +2208,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll", "maxTimeMS": { @@ -2260,7 +2260,7 @@ { "commandStartedEvent": { "commandName": "delete", - "databaseName": "test", + "databaseName": "db", "command": { "delete": "coll", "maxTimeMS": { @@ -2315,7 +2315,7 @@ { "commandStartedEvent": { "commandName": "delete", - "databaseName": "test", + "databaseName": "db", "command": { "delete": "coll", "maxTimeMS": { @@ -2367,7 +2367,7 @@ { "commandStartedEvent": { "commandName": "delete", - "databaseName": "test", + "databaseName": "db", "command": { "delete": "coll", "maxTimeMS": { @@ -2422,7 +2422,7 @@ { "commandStartedEvent": { "commandName": "delete", - "databaseName": "test", + "databaseName": "db", "command": { "delete": "coll", "maxTimeMS": { @@ -2477,7 +2477,7 @@ { "commandStartedEvent": { "commandName": "update", - "databaseName": "test", + "databaseName": "db", "command": { "update": "coll", "maxTimeMS": { @@ -2535,7 +2535,7 @@ { "commandStartedEvent": { "commandName": "update", - "databaseName": "test", + "databaseName": "db", "command": { "update": "coll", "maxTimeMS": { @@ -2592,7 +2592,7 @@ { "commandStartedEvent": { "commandName": "update", - "databaseName": "test", + "databaseName": "db", "command": { "update": "coll", "maxTimeMS": { @@ -2652,7 +2652,7 @@ { "commandStartedEvent": { "commandName": "update", - "databaseName": "test", + "databaseName": "db", "command": { "update": "coll", "maxTimeMS": { @@ -2709,7 +2709,7 @@ { "commandStartedEvent": { "commandName": "update", - "databaseName": "test", + "databaseName": "db", "command": { "update": "coll", "maxTimeMS": { @@ -2769,7 +2769,7 @@ { "commandStartedEvent": { "commandName": "update", - "databaseName": "test", + "databaseName": "db", "command": { "update": "coll", "maxTimeMS": { @@ -2821,7 +2821,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll", "maxTimeMS": { @@ -2876,7 +2876,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll", "maxTimeMS": { @@ -2931,7 +2931,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll", "maxTimeMS": { @@ -2989,7 +2989,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll", "maxTimeMS": { @@ -3046,7 +3046,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll", "maxTimeMS": { @@ -3106,7 +3106,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll", "maxTimeMS": { @@ -3166,7 +3166,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll", "maxTimeMS": { @@ -3229,7 +3229,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll", "maxTimeMS": { @@ -3284,7 +3284,7 @@ { "commandStartedEvent": { "commandName": "createIndexes", - "databaseName": "test", + "databaseName": "db", "command": { "createIndexes": "coll", "maxTimeMS": { @@ -3342,7 +3342,7 @@ { "commandStartedEvent": { "commandName": "createIndexes", - "databaseName": "test", + "databaseName": "db", "command": { "createIndexes": "coll", "maxTimeMS": { @@ -3405,13 +3405,13 @@ { "commandStartedEvent": { "commandName": "createIndexes", - "databaseName": "test" + "databaseName": "db" } }, { "commandStartedEvent": { "commandName": "dropIndexes", - "databaseName": "test", + "databaseName": "db", "command": { "dropIndexes": "coll", "maxTimeMS": { @@ -3477,13 +3477,13 @@ { "commandStartedEvent": { "commandName": "createIndexes", - "databaseName": "test" + "databaseName": "db" } }, { "commandStartedEvent": { "commandName": "dropIndexes", - "databaseName": "test", + "databaseName": "db", "command": { "dropIndexes": "coll", "maxTimeMS": { @@ -3534,7 +3534,7 @@ { "commandStartedEvent": { "commandName": "dropIndexes", - "databaseName": "test", + "databaseName": "db", "command": { "dropIndexes": "coll", "maxTimeMS": { @@ -3588,7 +3588,7 @@ { "commandStartedEvent": { "commandName": "dropIndexes", - "databaseName": "test", + "databaseName": "db", "command": { "dropIndexes": "coll", "maxTimeMS": { diff --git a/test/csot/retryability-legacy-timeouts.json b/test/csot/retryability-legacy-timeouts.json index aded781aee..bd1da0fa45 100644 --- a/test/csot/retryability-legacy-timeouts.json +++ b/test/csot/retryability-legacy-timeouts.json @@ -36,7 +36,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -50,7 +50,7 @@ "initialData": [ { "collectionName": "coll", - "databaseName": "test", + "databaseName": "db", "documents": [] } ], @@ -95,7 +95,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll" } @@ -104,7 +104,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll" } @@ -157,7 +157,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll" } @@ -166,7 +166,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll" } @@ -218,7 +218,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll" } @@ -227,7 +227,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll" } @@ -282,7 +282,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll" } @@ -291,7 +291,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll" } @@ -339,7 +339,7 @@ { "commandStartedEvent": { "commandName": "delete", - "databaseName": "test", + "databaseName": "db", "command": { "delete": "coll" } @@ -348,7 +348,7 @@ { "commandStartedEvent": { "commandName": "delete", - "databaseName": "test", + "databaseName": "db", "command": { "delete": "coll" } @@ -399,7 +399,7 @@ { "commandStartedEvent": { "commandName": "delete", - "databaseName": "test", + "databaseName": "db", "command": { "delete": "coll" } @@ -408,7 +408,7 @@ { "commandStartedEvent": { "commandName": "delete", - "databaseName": "test", + "databaseName": "db", "command": { "delete": "coll" } @@ -459,7 +459,7 @@ { "commandStartedEvent": { "commandName": "update", - "databaseName": "test", + "databaseName": "db", "command": { "update": "coll" } @@ -468,7 +468,7 @@ { "commandStartedEvent": { "commandName": "update", - "databaseName": "test", + "databaseName": "db", "command": { "update": "coll" } @@ -522,7 +522,7 @@ { "commandStartedEvent": { "commandName": "update", - "databaseName": "test", + "databaseName": "db", "command": { "update": "coll" } @@ -531,7 +531,7 @@ { "commandStartedEvent": { "commandName": "update", - "databaseName": "test", + "databaseName": "db", "command": { "update": "coll" } @@ -584,7 +584,7 @@ { "commandStartedEvent": { "commandName": "update", - "databaseName": "test", + "databaseName": "db", "command": { "update": "coll" } @@ -593,7 +593,7 @@ { "commandStartedEvent": { "commandName": "update", - "databaseName": "test", + "databaseName": "db", "command": { "update": "coll" } @@ -649,7 +649,7 @@ { "commandStartedEvent": { "commandName": "update", - "databaseName": "test", + "databaseName": "db", "command": { "update": "coll" } @@ -658,7 +658,7 @@ { "commandStartedEvent": { "commandName": "update", - "databaseName": "test", + "databaseName": "db", "command": { "update": "coll" } @@ -706,7 +706,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll" } @@ -715,7 +715,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll" } @@ -766,7 +766,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll" } @@ -775,7 +775,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll" } @@ -826,7 +826,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll" } @@ -835,7 +835,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll" } @@ -889,7 +889,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll" } @@ -898,7 +898,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll" } @@ -951,7 +951,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll" } @@ -960,7 +960,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll" } @@ -1016,7 +1016,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll" } @@ -1025,7 +1025,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll" } @@ -1081,7 +1081,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll" } @@ -1090,7 +1090,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll" } @@ -1149,7 +1149,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll" } @@ -1158,7 +1158,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll" } @@ -1558,7 +1558,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": 1 } @@ -1567,7 +1567,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": 1 } @@ -1625,7 +1625,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": 1 } @@ -1634,7 +1634,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": 1 } @@ -1682,7 +1682,7 @@ { "commandStartedEvent": { "commandName": "listCollections", - "databaseName": "test", + "databaseName": "db", "command": { "listCollections": 1 } @@ -1691,7 +1691,7 @@ { "commandStartedEvent": { "commandName": "listCollections", - "databaseName": "test", + "databaseName": "db", "command": { "listCollections": 1 } @@ -1742,7 +1742,7 @@ { "commandStartedEvent": { "commandName": "listCollections", - "databaseName": "test", + "databaseName": "db", "command": { "listCollections": 1 } @@ -1751,7 +1751,7 @@ { "commandStartedEvent": { "commandName": "listCollections", - "databaseName": "test", + "databaseName": "db", "command": { "listCollections": 1 } @@ -1799,7 +1799,7 @@ { "commandStartedEvent": { "commandName": "listCollections", - "databaseName": "test", + "databaseName": "db", "command": { "listCollections": 1 } @@ -1808,7 +1808,7 @@ { "commandStartedEvent": { "commandName": "listCollections", - "databaseName": "test", + "databaseName": "db", "command": { "listCollections": 1 } @@ -1859,7 +1859,7 @@ { "commandStartedEvent": { "commandName": "listCollections", - "databaseName": "test", + "databaseName": "db", "command": { "listCollections": 1 } @@ -1868,7 +1868,7 @@ { "commandStartedEvent": { "commandName": "listCollections", - "databaseName": "test", + "databaseName": "db", "command": { "listCollections": 1 } @@ -1916,7 +1916,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": 1 } @@ -1925,7 +1925,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": 1 } @@ -1976,7 +1976,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": 1 } @@ -1985,7 +1985,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": 1 } @@ -2033,7 +2033,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll" } @@ -2042,7 +2042,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll" } @@ -2093,7 +2093,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll" } @@ -2102,7 +2102,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll" } @@ -2150,7 +2150,7 @@ { "commandStartedEvent": { "commandName": "count", - "databaseName": "test", + "databaseName": "db", "command": { "count": "coll" } @@ -2159,7 +2159,7 @@ { "commandStartedEvent": { "commandName": "count", - "databaseName": "test", + "databaseName": "db", "command": { "count": "coll" } @@ -2210,7 +2210,7 @@ { "commandStartedEvent": { "commandName": "count", - "databaseName": "test", + "databaseName": "db", "command": { "count": "coll" } @@ -2219,7 +2219,7 @@ { "commandStartedEvent": { "commandName": "count", - "databaseName": "test", + "databaseName": "db", "command": { "count": "coll" } @@ -2267,7 +2267,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll" } @@ -2276,7 +2276,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll" } @@ -2327,7 +2327,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll" } @@ -2336,7 +2336,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll" } @@ -2381,7 +2381,7 @@ { "commandStartedEvent": { "commandName": "count", - "databaseName": "test", + "databaseName": "db", "command": { "count": "coll" } @@ -2390,7 +2390,7 @@ { "commandStartedEvent": { "commandName": "count", - "databaseName": "test", + "databaseName": "db", "command": { "count": "coll" } @@ -2438,7 +2438,7 @@ { "commandStartedEvent": { "commandName": "count", - "databaseName": "test", + "databaseName": "db", "command": { "count": "coll" } @@ -2447,7 +2447,7 @@ { "commandStartedEvent": { "commandName": "count", - "databaseName": "test", + "databaseName": "db", "command": { "count": "coll" } @@ -2496,7 +2496,7 @@ { "commandStartedEvent": { "commandName": "distinct", - "databaseName": "test", + "databaseName": "db", "command": { "distinct": "coll" } @@ -2505,7 +2505,7 @@ { "commandStartedEvent": { "commandName": "distinct", - "databaseName": "test", + "databaseName": "db", "command": { "distinct": "coll" } @@ -2557,7 +2557,7 @@ { "commandStartedEvent": { "commandName": "distinct", - "databaseName": "test", + "databaseName": "db", "command": { "distinct": "coll" } @@ -2566,7 +2566,7 @@ { "commandStartedEvent": { "commandName": "distinct", - "databaseName": "test", + "databaseName": "db", "command": { "distinct": "coll" } @@ -2614,7 +2614,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "coll" } @@ -2623,7 +2623,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "coll" } @@ -2674,7 +2674,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "coll" } @@ -2683,7 +2683,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "coll" } @@ -2731,7 +2731,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "coll" } @@ -2740,7 +2740,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "coll" } @@ -2791,7 +2791,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "coll" } @@ -2800,7 +2800,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "coll" } @@ -2845,7 +2845,7 @@ { "commandStartedEvent": { "commandName": "listIndexes", - "databaseName": "test", + "databaseName": "db", "command": { "listIndexes": "coll" } @@ -2854,7 +2854,7 @@ { "commandStartedEvent": { "commandName": "listIndexes", - "databaseName": "test", + "databaseName": "db", "command": { "listIndexes": "coll" } @@ -2902,7 +2902,7 @@ { "commandStartedEvent": { "commandName": "listIndexes", - "databaseName": "test", + "databaseName": "db", "command": { "listIndexes": "coll" } @@ -2911,7 +2911,7 @@ { "commandStartedEvent": { "commandName": "listIndexes", - "databaseName": "test", + "databaseName": "db", "command": { "listIndexes": "coll" } @@ -2959,7 +2959,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll" } @@ -2968,7 +2968,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll" } @@ -3019,7 +3019,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll" } @@ -3028,7 +3028,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll" } diff --git a/test/csot/retryability-timeoutMS.json b/test/csot/retryability-timeoutMS.json index 5a0c9f3605..8dd4ecb2fa 100644 --- a/test/csot/retryability-timeoutMS.json +++ b/test/csot/retryability-timeoutMS.json @@ -43,7 +43,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -57,7 +57,7 @@ "initialData": [ { "collectionName": "coll", - "databaseName": "test", + "databaseName": "db", "documents": [] } ], @@ -157,7 +157,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll", "maxTimeMS": { @@ -172,7 +172,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll", "maxTimeMS": { @@ -187,7 +187,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll", "maxTimeMS": { @@ -252,7 +252,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll", "maxTimeMS": { @@ -264,7 +264,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll", "maxTimeMS": { @@ -276,7 +276,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll", "maxTimeMS": { @@ -388,7 +388,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll", "maxTimeMS": { @@ -403,7 +403,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll", "maxTimeMS": { @@ -418,7 +418,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll", "maxTimeMS": { @@ -485,7 +485,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll", "maxTimeMS": { @@ -497,7 +497,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll", "maxTimeMS": { @@ -509,7 +509,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll", "maxTimeMS": { @@ -613,7 +613,7 @@ { "commandStartedEvent": { "commandName": "delete", - "databaseName": "test", + "databaseName": "db", "command": { "delete": "coll", "maxTimeMS": { @@ -628,7 +628,7 @@ { "commandStartedEvent": { "commandName": "delete", - "databaseName": "test", + "databaseName": "db", "command": { "delete": "coll", "maxTimeMS": { @@ -643,7 +643,7 @@ { "commandStartedEvent": { "commandName": "delete", - "databaseName": "test", + "databaseName": "db", "command": { "delete": "coll", "maxTimeMS": { @@ -706,7 +706,7 @@ { "commandStartedEvent": { "commandName": "delete", - "databaseName": "test", + "databaseName": "db", "command": { "delete": "coll", "maxTimeMS": { @@ -718,7 +718,7 @@ { "commandStartedEvent": { "commandName": "delete", - "databaseName": "test", + "databaseName": "db", "command": { "delete": "coll", "maxTimeMS": { @@ -730,7 +730,7 @@ { "commandStartedEvent": { "commandName": "delete", - "databaseName": "test", + "databaseName": "db", "command": { "delete": "coll", "maxTimeMS": { @@ -840,7 +840,7 @@ { "commandStartedEvent": { "commandName": "update", - "databaseName": "test", + "databaseName": "db", "command": { "update": "coll", "maxTimeMS": { @@ -855,7 +855,7 @@ { "commandStartedEvent": { "commandName": "update", - "databaseName": "test", + "databaseName": "db", "command": { "update": "coll", "maxTimeMS": { @@ -870,7 +870,7 @@ { "commandStartedEvent": { "commandName": "update", - "databaseName": "test", + "databaseName": "db", "command": { "update": "coll", "maxTimeMS": { @@ -936,7 +936,7 @@ { "commandStartedEvent": { "commandName": "update", - "databaseName": "test", + "databaseName": "db", "command": { "update": "coll", "maxTimeMS": { @@ -948,7 +948,7 @@ { "commandStartedEvent": { "commandName": "update", - "databaseName": "test", + "databaseName": "db", "command": { "update": "coll", "maxTimeMS": { @@ -960,7 +960,7 @@ { "commandStartedEvent": { "commandName": "update", - "databaseName": "test", + "databaseName": "db", "command": { "update": "coll", "maxTimeMS": { @@ -1074,7 +1074,7 @@ { "commandStartedEvent": { "commandName": "update", - "databaseName": "test", + "databaseName": "db", "command": { "update": "coll", "maxTimeMS": { @@ -1089,7 +1089,7 @@ { "commandStartedEvent": { "commandName": "update", - "databaseName": "test", + "databaseName": "db", "command": { "update": "coll", "maxTimeMS": { @@ -1104,7 +1104,7 @@ { "commandStartedEvent": { "commandName": "update", - "databaseName": "test", + "databaseName": "db", "command": { "update": "coll", "maxTimeMS": { @@ -1172,7 +1172,7 @@ { "commandStartedEvent": { "commandName": "update", - "databaseName": "test", + "databaseName": "db", "command": { "update": "coll", "maxTimeMS": { @@ -1184,7 +1184,7 @@ { "commandStartedEvent": { "commandName": "update", - "databaseName": "test", + "databaseName": "db", "command": { "update": "coll", "maxTimeMS": { @@ -1196,7 +1196,7 @@ { "commandStartedEvent": { "commandName": "update", - "databaseName": "test", + "databaseName": "db", "command": { "update": "coll", "maxTimeMS": { @@ -1300,7 +1300,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll", "maxTimeMS": { @@ -1315,7 +1315,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll", "maxTimeMS": { @@ -1330,7 +1330,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll", "maxTimeMS": { @@ -1393,7 +1393,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll", "maxTimeMS": { @@ -1405,7 +1405,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll", "maxTimeMS": { @@ -1417,7 +1417,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll", "maxTimeMS": { @@ -1527,7 +1527,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll", "maxTimeMS": { @@ -1542,7 +1542,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll", "maxTimeMS": { @@ -1557,7 +1557,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll", "maxTimeMS": { @@ -1623,7 +1623,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll", "maxTimeMS": { @@ -1635,7 +1635,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll", "maxTimeMS": { @@ -1647,7 +1647,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll", "maxTimeMS": { @@ -1761,7 +1761,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll", "maxTimeMS": { @@ -1776,7 +1776,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll", "maxTimeMS": { @@ -1791,7 +1791,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll", "maxTimeMS": { @@ -1859,7 +1859,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll", "maxTimeMS": { @@ -1871,7 +1871,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll", "maxTimeMS": { @@ -1883,7 +1883,7 @@ { "commandStartedEvent": { "commandName": "findAndModify", - "databaseName": "test", + "databaseName": "db", "command": { "findAndModify": "coll", "maxTimeMS": { @@ -2003,7 +2003,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll", "maxTimeMS": { @@ -2018,7 +2018,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll", "maxTimeMS": { @@ -2033,7 +2033,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll", "maxTimeMS": { @@ -2104,7 +2104,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll", "maxTimeMS": { @@ -2116,7 +2116,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll", "maxTimeMS": { @@ -2128,7 +2128,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll", "maxTimeMS": { @@ -2904,7 +2904,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": 1, "maxTimeMS": { @@ -2919,7 +2919,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": 1, "maxTimeMS": { @@ -2934,7 +2934,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": 1, "maxTimeMS": { @@ -3004,7 +3004,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": 1, "maxTimeMS": { @@ -3016,7 +3016,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": 1, "maxTimeMS": { @@ -3028,7 +3028,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": 1, "maxTimeMS": { @@ -3132,7 +3132,7 @@ { "commandStartedEvent": { "commandName": "listCollections", - "databaseName": "test", + "databaseName": "db", "command": { "listCollections": 1, "maxTimeMS": { @@ -3147,7 +3147,7 @@ { "commandStartedEvent": { "commandName": "listCollections", - "databaseName": "test", + "databaseName": "db", "command": { "listCollections": 1, "maxTimeMS": { @@ -3162,7 +3162,7 @@ { "commandStartedEvent": { "commandName": "listCollections", - "databaseName": "test", + "databaseName": "db", "command": { "listCollections": 1, "maxTimeMS": { @@ -3225,7 +3225,7 @@ { "commandStartedEvent": { "commandName": "listCollections", - "databaseName": "test", + "databaseName": "db", "command": { "listCollections": 1, "maxTimeMS": { @@ -3237,7 +3237,7 @@ { "commandStartedEvent": { "commandName": "listCollections", - "databaseName": "test", + "databaseName": "db", "command": { "listCollections": 1, "maxTimeMS": { @@ -3249,7 +3249,7 @@ { "commandStartedEvent": { "commandName": "listCollections", - "databaseName": "test", + "databaseName": "db", "command": { "listCollections": 1, "maxTimeMS": { @@ -3353,7 +3353,7 @@ { "commandStartedEvent": { "commandName": "listCollections", - "databaseName": "test", + "databaseName": "db", "command": { "listCollections": 1, "maxTimeMS": { @@ -3368,7 +3368,7 @@ { "commandStartedEvent": { "commandName": "listCollections", - "databaseName": "test", + "databaseName": "db", "command": { "listCollections": 1, "maxTimeMS": { @@ -3383,7 +3383,7 @@ { "commandStartedEvent": { "commandName": "listCollections", - "databaseName": "test", + "databaseName": "db", "command": { "listCollections": 1, "maxTimeMS": { @@ -3446,7 +3446,7 @@ { "commandStartedEvent": { "commandName": "listCollections", - "databaseName": "test", + "databaseName": "db", "command": { "listCollections": 1, "maxTimeMS": { @@ -3458,7 +3458,7 @@ { "commandStartedEvent": { "commandName": "listCollections", - "databaseName": "test", + "databaseName": "db", "command": { "listCollections": 1, "maxTimeMS": { @@ -3470,7 +3470,7 @@ { "commandStartedEvent": { "commandName": "listCollections", - "databaseName": "test", + "databaseName": "db", "command": { "listCollections": 1, "maxTimeMS": { @@ -3574,7 +3574,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": 1, "maxTimeMS": { @@ -3589,7 +3589,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": 1, "maxTimeMS": { @@ -3604,7 +3604,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": 1, "maxTimeMS": { @@ -3667,7 +3667,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": 1, "maxTimeMS": { @@ -3679,7 +3679,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": 1, "maxTimeMS": { @@ -3691,7 +3691,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": 1, "maxTimeMS": { @@ -3795,7 +3795,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll", "maxTimeMS": { @@ -3810,7 +3810,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll", "maxTimeMS": { @@ -3825,7 +3825,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll", "maxTimeMS": { @@ -3888,7 +3888,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll", "maxTimeMS": { @@ -3900,7 +3900,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll", "maxTimeMS": { @@ -3912,7 +3912,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll", "maxTimeMS": { @@ -4016,7 +4016,7 @@ { "commandStartedEvent": { "commandName": "count", - "databaseName": "test", + "databaseName": "db", "command": { "count": "coll", "maxTimeMS": { @@ -4031,7 +4031,7 @@ { "commandStartedEvent": { "commandName": "count", - "databaseName": "test", + "databaseName": "db", "command": { "count": "coll", "maxTimeMS": { @@ -4046,7 +4046,7 @@ { "commandStartedEvent": { "commandName": "count", - "databaseName": "test", + "databaseName": "db", "command": { "count": "coll", "maxTimeMS": { @@ -4109,7 +4109,7 @@ { "commandStartedEvent": { "commandName": "count", - "databaseName": "test", + "databaseName": "db", "command": { "count": "coll", "maxTimeMS": { @@ -4121,7 +4121,7 @@ { "commandStartedEvent": { "commandName": "count", - "databaseName": "test", + "databaseName": "db", "command": { "count": "coll", "maxTimeMS": { @@ -4133,7 +4133,7 @@ { "commandStartedEvent": { "commandName": "count", - "databaseName": "test", + "databaseName": "db", "command": { "count": "coll", "maxTimeMS": { @@ -4237,7 +4237,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll", "maxTimeMS": { @@ -4252,7 +4252,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll", "maxTimeMS": { @@ -4267,7 +4267,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll", "maxTimeMS": { @@ -4330,7 +4330,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll", "maxTimeMS": { @@ -4342,7 +4342,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll", "maxTimeMS": { @@ -4354,7 +4354,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll", "maxTimeMS": { @@ -4454,7 +4454,7 @@ { "commandStartedEvent": { "commandName": "count", - "databaseName": "test", + "databaseName": "db", "command": { "count": "coll", "maxTimeMS": { @@ -4469,7 +4469,7 @@ { "commandStartedEvent": { "commandName": "count", - "databaseName": "test", + "databaseName": "db", "command": { "count": "coll", "maxTimeMS": { @@ -4484,7 +4484,7 @@ { "commandStartedEvent": { "commandName": "count", - "databaseName": "test", + "databaseName": "db", "command": { "count": "coll", "maxTimeMS": { @@ -4546,7 +4546,7 @@ { "commandStartedEvent": { "commandName": "count", - "databaseName": "test", + "databaseName": "db", "command": { "count": "coll", "maxTimeMS": { @@ -4558,7 +4558,7 @@ { "commandStartedEvent": { "commandName": "count", - "databaseName": "test", + "databaseName": "db", "command": { "count": "coll", "maxTimeMS": { @@ -4570,7 +4570,7 @@ { "commandStartedEvent": { "commandName": "count", - "databaseName": "test", + "databaseName": "db", "command": { "count": "coll", "maxTimeMS": { @@ -4676,7 +4676,7 @@ { "commandStartedEvent": { "commandName": "distinct", - "databaseName": "test", + "databaseName": "db", "command": { "distinct": "coll", "maxTimeMS": { @@ -4691,7 +4691,7 @@ { "commandStartedEvent": { "commandName": "distinct", - "databaseName": "test", + "databaseName": "db", "command": { "distinct": "coll", "maxTimeMS": { @@ -4706,7 +4706,7 @@ { "commandStartedEvent": { "commandName": "distinct", - "databaseName": "test", + "databaseName": "db", "command": { "distinct": "coll", "maxTimeMS": { @@ -4770,7 +4770,7 @@ { "commandStartedEvent": { "commandName": "distinct", - "databaseName": "test", + "databaseName": "db", "command": { "distinct": "coll", "maxTimeMS": { @@ -4782,7 +4782,7 @@ { "commandStartedEvent": { "commandName": "distinct", - "databaseName": "test", + "databaseName": "db", "command": { "distinct": "coll", "maxTimeMS": { @@ -4794,7 +4794,7 @@ { "commandStartedEvent": { "commandName": "distinct", - "databaseName": "test", + "databaseName": "db", "command": { "distinct": "coll", "maxTimeMS": { @@ -4898,7 +4898,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "coll", "maxTimeMS": { @@ -4913,7 +4913,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "coll", "maxTimeMS": { @@ -4928,7 +4928,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "coll", "maxTimeMS": { @@ -4991,7 +4991,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "coll", "maxTimeMS": { @@ -5003,7 +5003,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "coll", "maxTimeMS": { @@ -5015,7 +5015,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "coll", "maxTimeMS": { @@ -5119,7 +5119,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "coll", "maxTimeMS": { @@ -5134,7 +5134,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "coll", "maxTimeMS": { @@ -5149,7 +5149,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "coll", "maxTimeMS": { @@ -5212,7 +5212,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "coll", "maxTimeMS": { @@ -5224,7 +5224,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "coll", "maxTimeMS": { @@ -5236,7 +5236,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "coll", "maxTimeMS": { @@ -5336,7 +5336,7 @@ { "commandStartedEvent": { "commandName": "listIndexes", - "databaseName": "test", + "databaseName": "db", "command": { "listIndexes": "coll", "maxTimeMS": { @@ -5351,7 +5351,7 @@ { "commandStartedEvent": { "commandName": "listIndexes", - "databaseName": "test", + "databaseName": "db", "command": { "listIndexes": "coll", "maxTimeMS": { @@ -5366,7 +5366,7 @@ { "commandStartedEvent": { "commandName": "listIndexes", - "databaseName": "test", + "databaseName": "db", "command": { "listIndexes": "coll", "maxTimeMS": { @@ -5428,7 +5428,7 @@ { "commandStartedEvent": { "commandName": "listIndexes", - "databaseName": "test", + "databaseName": "db", "command": { "listIndexes": "coll", "maxTimeMS": { @@ -5440,7 +5440,7 @@ { "commandStartedEvent": { "commandName": "listIndexes", - "databaseName": "test", + "databaseName": "db", "command": { "listIndexes": "coll", "maxTimeMS": { @@ -5452,7 +5452,7 @@ { "commandStartedEvent": { "commandName": "listIndexes", - "databaseName": "test", + "databaseName": "db", "command": { "listIndexes": "coll", "maxTimeMS": { @@ -5556,7 +5556,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll", "maxTimeMS": { @@ -5571,7 +5571,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll", "maxTimeMS": { @@ -5586,7 +5586,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll", "maxTimeMS": { @@ -5649,7 +5649,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll", "maxTimeMS": { @@ -5661,7 +5661,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll", "maxTimeMS": { @@ -5673,7 +5673,7 @@ { "commandStartedEvent": { "commandName": "aggregate", - "databaseName": "test", + "databaseName": "db", "command": { "aggregate": "coll", "maxTimeMS": { diff --git a/test/csot/sessions-inherit-timeoutMS.json b/test/csot/sessions-inherit-timeoutMS.json index 50feabf609..61f889a147 100644 --- a/test/csot/sessions-inherit-timeoutMS.json +++ b/test/csot/sessions-inherit-timeoutMS.json @@ -37,7 +37,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -57,7 +57,7 @@ "initialData": [ { "collectionName": "coll", - "databaseName": "test", + "databaseName": "db", "documents": [] } ], @@ -114,7 +114,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll" } @@ -198,7 +198,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll" } @@ -289,7 +289,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll", "maxTimeMS": { diff --git a/test/csot/sessions-override-operation-timeoutMS.json b/test/csot/sessions-override-operation-timeoutMS.json index 78e873f948..fe66284c2d 100644 --- a/test/csot/sessions-override-operation-timeoutMS.json +++ b/test/csot/sessions-override-operation-timeoutMS.json @@ -32,7 +32,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -52,7 +52,7 @@ "initialData": [ { "collectionName": "coll", - "databaseName": "test", + "databaseName": "db", "documents": [] } ], @@ -112,7 +112,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll" } @@ -199,7 +199,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll" } @@ -291,7 +291,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll", "maxTimeMS": { diff --git a/test/csot/sessions-override-timeoutMS.json b/test/csot/sessions-override-timeoutMS.json index c4a446c531..57748c966c 100644 --- a/test/csot/sessions-override-timeoutMS.json +++ b/test/csot/sessions-override-timeoutMS.json @@ -32,7 +32,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -55,7 +55,7 @@ "initialData": [ { "collectionName": "coll", - "databaseName": "test", + "databaseName": "db", "documents": [] } ], @@ -112,7 +112,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll" } @@ -196,7 +196,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll" } @@ -287,7 +287,7 @@ { "commandStartedEvent": { "commandName": "insert", - "databaseName": "test", + "databaseName": "db", "command": { "insert": "coll", "maxTimeMS": { diff --git a/test/csot/tailable-awaitData.json b/test/csot/tailable-awaitData.json index 80e95ca906..d33a491a85 100644 --- a/test/csot/tailable-awaitData.json +++ b/test/csot/tailable-awaitData.json @@ -30,7 +30,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -44,7 +44,7 @@ "initialData": [ { "collectionName": "coll", - "databaseName": "test", + "databaseName": "db", "createOptions": { "capped": true, "size": 500 @@ -229,7 +229,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "coll", "tailable": true, @@ -295,7 +295,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "coll", "tailable": true, @@ -309,7 +309,7 @@ { "commandStartedEvent": { "commandName": "getMore", - "databaseName": "test", + "databaseName": "db", "command": { "getMore": { "$$type": [ @@ -380,7 +380,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "coll", "tailable": true, @@ -394,7 +394,7 @@ { "commandStartedEvent": { "commandName": "getMore", - "databaseName": "test", + "databaseName": "db", "command": { "getMore": { "$$type": [ @@ -463,7 +463,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "coll", "tailable": true, @@ -477,7 +477,7 @@ { "commandStartedEvent": { "commandName": "getMore", - "databaseName": "test", + "databaseName": "db", "command": { "getMore": { "$$type": [ @@ -550,13 +550,13 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test" + "databaseName": "db" } }, { "commandStartedEvent": { "commandName": "getMore", - "databaseName": "test", + "databaseName": "db", "command": { "maxTimeMS": { "$$lte": 100 @@ -567,7 +567,7 @@ { "commandStartedEvent": { "commandName": "getMore", - "databaseName": "test", + "databaseName": "db", "command": { "maxTimeMS": { "$$lte": 70 @@ -610,13 +610,13 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test" + "databaseName": "db" } }, { "commandStartedEvent": { "commandName": "getMore", - "databaseName": "test", + "databaseName": "db", "command": { "maxTimeMS": { "$$lte": 100 diff --git a/test/csot/tailable-non-awaitData.json b/test/csot/tailable-non-awaitData.json index e88230e4f7..2f9784f839 100644 --- a/test/csot/tailable-non-awaitData.json +++ b/test/csot/tailable-non-awaitData.json @@ -29,7 +29,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } }, { @@ -43,7 +43,7 @@ "initialData": [ { "collectionName": "coll", - "databaseName": "test", + "databaseName": "db", "createOptions": { "capped": true, "size": 500 @@ -118,7 +118,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "coll", "tailable": true, @@ -186,7 +186,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "coll", "tailable": true, @@ -202,7 +202,7 @@ { "commandStartedEvent": { "commandName": "getMore", - "databaseName": "test", + "databaseName": "db", "command": { "getMore": { "$$type": [ @@ -273,7 +273,7 @@ { "commandStartedEvent": { "commandName": "find", - "databaseName": "test", + "databaseName": "db", "command": { "find": "coll", "tailable": true, @@ -289,7 +289,7 @@ { "commandStartedEvent": { "commandName": "getMore", - "databaseName": "test", + "databaseName": "db", "command": { "getMore": { "$$type": [ diff --git a/test/csot/waitQueueTimeout.json b/test/csot/waitQueueTimeout.json index 138d5cc161..30363a9c71 100644 --- a/test/csot/waitQueueTimeout.json +++ b/test/csot/waitQueueTimeout.json @@ -36,7 +36,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } } ], @@ -148,7 +148,7 @@ { "commandStartedEvent": { "commandName": "ping", - "databaseName": "test", + "databaseName": "db", "command": { "ping": 1 } @@ -157,7 +157,7 @@ { "commandStartedEvent": { "commandName": "hello", - "databaseName": "test", + "databaseName": "db", "command": { "hello": 1 } diff --git a/test/data_lake/unified/aggregate.json b/test/data_lake/unified/aggregate.json index 68a3467c71..68ea77a0c0 100644 --- a/test/data_lake/unified/aggregate.json +++ b/test/data_lake/unified/aggregate.json @@ -14,7 +14,7 @@ "database": { "id": "database0", "client": "client0", - "databaseName": "test" + "databaseName": "db" } }, { @@ -73,7 +73,7 @@ "aggregate": "driverdata" }, "commandName": "aggregate", - "databaseName": "test" + "databaseName": "db" } } ] diff --git a/test/data_lake/unified/estimatedDocumentCount.json b/test/data_lake/unified/estimatedDocumentCount.json index b7515a4418..c7c240ebde 100644 --- a/test/data_lake/unified/estimatedDocumentCount.json +++ b/test/data_lake/unified/estimatedDocumentCount.json @@ -14,7 +14,7 @@ "database": { "id": "database0", "client": "client0", - "databaseName": "test" + "databaseName": "db" } }, { @@ -45,7 +45,7 @@ "count": "driverdata" }, "commandName": "count", - "databaseName": "test" + "databaseName": "db" } } ] diff --git a/test/data_lake/unified/find.json b/test/data_lake/unified/find.json index d0652dc720..204fa30434 100644 --- a/test/data_lake/unified/find.json +++ b/test/data_lake/unified/find.json @@ -14,7 +14,7 @@ "database": { "id": "database0", "client": "client0", - "databaseName": "test" + "databaseName": "db" } }, { @@ -85,7 +85,7 @@ "find": "driverdata" }, "commandName": "find", - "databaseName": "test" + "databaseName": "db" } } ] diff --git a/test/data_lake/unified/getMore.json b/test/data_lake/unified/getMore.json index 109b6d3d8e..71898c2c75 100644 --- a/test/data_lake/unified/getMore.json +++ b/test/data_lake/unified/getMore.json @@ -14,7 +14,7 @@ "database": { "id": "database0", "client": "client0", - "databaseName": "test" + "databaseName": "db" } }, { @@ -66,7 +66,7 @@ "limit": 4 }, "commandName": "find", - "databaseName": "test" + "databaseName": "db" } }, { diff --git a/test/data_lake/unified/listCollections.json b/test/data_lake/unified/listCollections.json index 642e7ed328..dda20e0040 100644 --- a/test/data_lake/unified/listCollections.json +++ b/test/data_lake/unified/listCollections.json @@ -14,7 +14,7 @@ "database": { "id": "database0", "client": "client0", - "databaseName": "test" + "databaseName": "db" } } ], @@ -37,7 +37,7 @@ "listCollections": 1 }, "commandName": "listCollections", - "databaseName": "test" + "databaseName": "db" } } ] diff --git a/test/data_lake/unified/runCommand.json b/test/data_lake/unified/runCommand.json index 325b6b3f30..d9cc95a5c9 100644 --- a/test/data_lake/unified/runCommand.json +++ b/test/data_lake/unified/runCommand.json @@ -14,7 +14,7 @@ "database": { "id": "database0", "client": "client0", - "databaseName": "test" + "databaseName": "db" } } ], @@ -43,7 +43,7 @@ "ping": 1 }, "commandName": "ping", - "databaseName": "test" + "databaseName": "db" } } ] diff --git a/test/handshake/unified/metadata-not-propagated.json b/test/handshake/unified/metadata-not-propagated.json index 7f70dd1488..0970ff0fdc 100644 --- a/test/handshake/unified/metadata-not-propagated.json +++ b/test/handshake/unified/metadata-not-propagated.json @@ -23,7 +23,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } } ], diff --git a/test/handshake/unified/op_msg-not-supported.json b/test/handshake/unified/op_msg-not-supported.json index b0fb30f245..fe4d44d405 100644 --- a/test/handshake/unified/op_msg-not-supported.json +++ b/test/handshake/unified/op_msg-not-supported.json @@ -27,7 +27,7 @@ "database": { "id": "database", "client": "client", - "databaseName": "test" + "databaseName": "db" } } ], diff --git a/test/lambda/mongodb/app.py b/test/lambda/mongodb/app.py index 274990d3bc..110382db60 100644 --- a/test/lambda/mongodb/app.py +++ b/test/lambda/mongodb/app.py @@ -154,7 +154,7 @@ def lambda_handler(event, context): """ print("initializing") db = client.lambdaTest - collection = db.test + collection = db.coll result = collection.insert_one({"n": 1}) collection.delete_one({"_id": result.inserted_id}) # Create the response and then reset the numbers. diff --git a/test/mockupdb/operations.py b/test/mockupdb/operations.py index c10c84bdcd..40fa591e5d 100644 --- a/test/mockupdb/operations.py +++ b/test/mockupdb/operations.py @@ -62,35 +62,35 @@ operations = [ Operation( "find_one", - lambda client: client.db.collection.find_one(), + lambda client: client.db.coll.find_one(), reply={"cursor": {"id": 0, "firstBatch": []}}, op_type="may-use-secondary", not_master=not_master_reply, ), Operation( "count_documents", - lambda client: client.db.collection.count_documents({}), + lambda client: client.db.coll.count_documents({}), reply={"n": 1}, op_type="may-use-secondary", not_master=not_master_reply, ), Operation( "estimated_document_count", - lambda client: client.db.collection.estimated_document_count(), + lambda client: client.db.coll.estimated_document_count(), reply={"n": 1}, op_type="may-use-secondary", not_master=not_master_reply, ), Operation( "aggregate", - lambda client: client.db.collection.aggregate([]), + lambda client: client.db.coll.aggregate([]), reply={"cursor": {"id": 0, "firstBatch": []}}, op_type="may-use-secondary", not_master=not_master_reply, ), Operation( "options", - lambda client: client.db.collection.options(), + lambda client: client.db.coll.options(), reply={"cursor": {"id": 0, "firstBatch": []}}, op_type="must-use-primary", not_master=not_master_reply, @@ -111,7 +111,7 @@ ), Operation( "listIndexes", - lambda client: client.db.collection.index_information(), + lambda client: client.db.coll.index_information(), reply={"cursor": {"id": 0, "firstBatch": []}}, op_type="must-use-primary", not_master=not_master_reply, diff --git a/test/mockupdb/test_cluster_time.py b/test/mockupdb/test_cluster_time.py index 42ca916971..fa6be3c364 100644 --- a/test/mockupdb/test_cluster_time.py +++ b/test/mockupdb/test_cluster_time.py @@ -76,7 +76,7 @@ def callback(client): def test_bulk(self): def callback(client: MongoClient[dict]) -> None: - client.db.collection.bulk_write( + client.db.coll.bulk_write( [InsertOne({}), InsertOne({}), UpdateOne({}, {"$inc": {"x": 1}}), DeleteMany({})] ) @@ -93,19 +93,19 @@ def callback(client: MongoClient[dict]) -> None: def test_cursor(self): def callback(client): - list(client.db.collection.find()) + list(client.db.coll.find()) self.cluster_time_conversation(callback, self.batches) def test_aggregate(self): def callback(client): - list(client.db.collection.aggregate([])) + list(client.db.coll.aggregate([])) self.cluster_time_conversation(callback, self.batches) def test_explain(self): def callback(client): - client.db.collection.find().explain() + client.db.coll.find().explain() self.cluster_time_conversation(callback, [{"ok": 1}]) @@ -133,7 +133,7 @@ def test_monitor(self): def test_collection_bulk_error(self): def callback(client: MongoClient[dict]) -> None: with self.assertRaises(OperationFailure): - client.db.collection.bulk_write([InsertOne({}), InsertOne({})]) + client.db.coll.bulk_write([InsertOne({}), InsertOne({})]) self.cluster_time_conversation( callback, @@ -145,8 +145,8 @@ def callback(client: MongoClient[dict]) -> None: with self.assertRaises(OperationFailure): client.bulk_write( [ - InsertOne({}, namespace="db.collection"), - InsertOne({}, namespace="db.collection"), + InsertOne({}, namespace="db.coll"), + InsertOne({}, namespace="db.coll"), ] ) diff --git a/test/mockupdb/test_cursor.py b/test/mockupdb/test_cursor.py index e61f220d5b..610e487d3a 100644 --- a/test/mockupdb/test_cursor.py +++ b/test/mockupdb/test_cursor.py @@ -79,8 +79,8 @@ def _test_fail_on_operation_failure_with_code(self, code): client = self.simple_client(server.uri) - with going(lambda: server.receives(OpMsg({"find": "collection"})).command_err(code=code)): - cursor = client.db.collection.find() + with going(lambda: server.receives(OpMsg({"find": "coll"})).command_err(code=code)): + cursor = client.db.coll.find() with self.assertRaises(OperationFailure) as ctx: cursor.next() self.assertEqual(ctx.exception.code, code) diff --git a/test/mockupdb/test_cursor_namespace.py b/test/mockupdb/test_cursor_namespace.py index 7538540bda..1840a8e4f9 100644 --- a/test/mockupdb/test_cursor_namespace.py +++ b/test/mockupdb/test_cursor_namespace.py @@ -51,7 +51,7 @@ def tearDownClass(cls): def _test_cursor_namespace(self, cursor_op, command): with going(cursor_op) as docs: - request = self.server.receives(**{command: "collection", "namespace": "test"}) + request = self.server.receives(**{command: "coll", "namespace": "db"}) # Respond with a different namespace. request.reply( { @@ -73,19 +73,19 @@ def _test_cursor_namespace(self, cursor_op, command): def test_aggregate_cursor(self): def op(): - return list(self.client.test.collection.aggregate([])) + return list(self.client.db.coll.aggregate([])) self._test_cursor_namespace(op, "aggregate") def test_find_cursor(self): def op(): - return list(self.client.test.collection.find()) + return list(self.client.db.coll.find()) self._test_cursor_namespace(op, "find") def test_list_indexes(self): def op(): - return list(self.client.test.collection.list_indexes()) + return list(self.client.db.coll.list_indexes()) self._test_cursor_namespace(op, "listIndexes") @@ -107,7 +107,7 @@ def tearDownClass(cls): def _test_killCursors_namespace(self, cursor_op, command): with going(cursor_op): - request = self.server.receives(**{command: "collection", "namespace": "test"}) + request = self.server.receives(**{command: "coll", "namespace": "db"}) # Respond with a different namespace. request.reply( { @@ -134,7 +134,7 @@ def _test_killCursors_namespace(self, cursor_op, command): def test_aggregate_killCursor(self): def op(): - cursor = self.client.test.collection.aggregate([], batchSize=1) + cursor = self.client.db.coll.aggregate([], batchSize=1) next(cursor) cursor.close() @@ -142,7 +142,7 @@ def op(): def test_find_killCursor(self): def op(): - cursor = self.client.test.collection.find(batch_size=1) + cursor = self.client.db.coll.find(batch_size=1) next(cursor) cursor.close() diff --git a/test/mockupdb/test_getmore_sharded.py b/test/mockupdb/test_getmore_sharded.py index d24c8aa10a..376168d299 100644 --- a/test/mockupdb/test_getmore_sharded.py +++ b/test/mockupdb/test_getmore_sharded.py @@ -56,7 +56,7 @@ def test_getmore_sharded(self): "mongodb://%s:%d,%s:%d" % (servers[0].host, servers[0].port, servers[1].host, servers[1].port) ) - collection = client.db.collection + collection = client.db.coll cursor = collection.find() with going(next, cursor): query = q.get(timeout=1) diff --git a/test/mockupdb/test_handshake.py b/test/mockupdb/test_handshake.py index 2772e6f77a..0c7426dfd5 100644 --- a/test/mockupdb/test_handshake.py +++ b/test/mockupdb/test_handshake.py @@ -293,7 +293,7 @@ def responder(request): password="password", ) self.addCleanup(client.close) - self.assertRaises(OperationFailure, client.db.collection.find_one, {"a": 1}) + self.assertRaises(OperationFailure, client.db.coll.find_one, {"a": 1}) self.assertTrue( self.found_auth_msg, "Could not find authentication command with correct protocol" ) diff --git a/test/mockupdb/test_list_indexes.py b/test/mockupdb/test_list_indexes.py index 71cad43aa2..c4bf9c2333 100644 --- a/test/mockupdb/test_list_indexes.py +++ b/test/mockupdb/test_list_indexes.py @@ -40,12 +40,12 @@ def test_list_indexes_command(self): server.run() self.addCleanup(server.stop) client = self.simple_client(server.uri) - with going(client.test.collection.list_indexes) as cursor: - request = server.receives(listIndexes="collection", namespace="test") + with going(client.db.coll.list_indexes) as cursor: + request = server.receives(listIndexes="coll", namespace="db") request.reply({"cursor": {"firstBatch": [{"name": "index_0"}], "id": 123}}) with going(list, cursor()) as indexes: - request = server.receives(getMore=123, namespace="test", collection="collection") + request = server.receives(getMore=123, namespace="db", collection="coll") request.reply({"cursor": {"nextBatch": [{"name": "index_1"}], "id": 0}}) diff --git a/test/mockupdb/test_mongos_command_read_mode.py b/test/mockupdb/test_mongos_command_read_mode.py index 61744e184d..d46cf54a68 100644 --- a/test/mockupdb/test_mongos_command_read_mode.py +++ b/test/mockupdb/test_mongos_command_read_mode.py @@ -53,9 +53,9 @@ def test_aggregate(self): client = MongoClient(server.uri) self.addCleanup(client.close) - collection = client.test.collection + collection = client.db.coll with going(collection.aggregate, []): - command = server.receives(aggregate="collection", pipeline=[]) + command = server.receives(aggregate="coll", pipeline=[]) self.assertFalse(command.slave_ok, "SlaveOkay set") command.ok(result=[{}]) diff --git a/test/mockupdb/test_query_read_pref_sharded.py b/test/mockupdb/test_query_read_pref_sharded.py index 2fae46be76..4d06a849c2 100644 --- a/test/mockupdb/test_query_read_pref_sharded.py +++ b/test/mockupdb/test_query_read_pref_sharded.py @@ -71,7 +71,7 @@ def test_query_and_read_mode_sharded_op_msg(self): {"$query": {"a": 1}}, ): for pref in read_prefs: - collection = client.db.get_collection("test", read_preference=pref) + collection = client.db.get_collection("coll", read_preference=pref) cursor = collection.find(query.copy()) with going(next, cursor): request = server.receives() diff --git a/test/mockupdb/test_standalone_shard.py b/test/mockupdb/test_standalone_shard.py index 28a582071c..3d31d6072f 100644 --- a/test/mockupdb/test_standalone_shard.py +++ b/test/mockupdb/test_standalone_shard.py @@ -45,7 +45,7 @@ def test_bulk_txn_error_message(self): with self.assertRaisesRegex( OperationFailure, "This MongoDB deployment does not support retryable writes" ): - with going(client.db.collection.insert_many, [{}, {}]): + with going(client.db.coll.insert_many, [{}, {}]): request = server.receives() request.reply( { diff --git a/test/mypy_fails/insert_many_dict.py b/test/mypy_fails/insert_many_dict.py index 5f9a2d45a9..0a18b0a936 100644 --- a/test/mypy_fails/insert_many_dict.py +++ b/test/mypy_fails/insert_many_dict.py @@ -3,6 +3,6 @@ from pymongo import MongoClient client: MongoClient = MongoClient() -client.test.test.insert_many( +client.db.coll.insert_many( {"a": 1} ) # error: Dict entry 0 has incompatible type "str": "int"; expected "Mapping[str, Any]": "int" diff --git a/test/mypy_fails/insert_one_list.py b/test/mypy_fails/insert_one_list.py index 7c27d5cac9..ffb543ce1c 100644 --- a/test/mypy_fails/insert_one_list.py +++ b/test/mypy_fails/insert_one_list.py @@ -3,6 +3,6 @@ from pymongo import MongoClient client: MongoClient = MongoClient() -client.test.test.insert_one( +client.db.coll.insert_one( [{}] ) # error: Argument 1 to "insert_one" of "Collection" has incompatible type "List[Dict[, ]]"; expected "Mapping[str, Any]" diff --git a/test/mypy_fails/raw_bson_document.py b/test/mypy_fails/raw_bson_document.py index 49f3659e90..9e4c960d5e 100644 --- a/test/mypy_fails/raw_bson_document.py +++ b/test/mypy_fails/raw_bson_document.py @@ -4,7 +4,7 @@ from pymongo import MongoClient client = MongoClient(document_class=RawBSONDocument) -coll = client.test.test +coll = client.db.coll doc = {"my": "doc"} coll.insert_one(doc) retrieved = coll.find_one({"_id": doc["_id"]}) diff --git a/test/mypy_fails/typedict_client.py b/test/mypy_fails/typedict_client.py index 37c3f0bfcc..dccb27dd5d 100644 --- a/test/mypy_fails/typedict_client.py +++ b/test/mypy_fails/typedict_client.py @@ -11,7 +11,7 @@ class Movie(TypedDict): client: MongoClient[Movie] = MongoClient() -coll = client.test.test +coll = client.db.coll retrieved = coll.find_one({"_id": "foo"}) assert retrieved is not None assert retrieved["year"] == 1 diff --git a/test/sessions/driver-sessions-dirty-session-errors.json b/test/sessions/driver-sessions-dirty-session-errors.json index d7a1c6aba7..5fbe1fe98d 100644 --- a/test/sessions/driver-sessions-dirty-session-errors.json +++ b/test/sessions/driver-sessions-dirty-session-errors.json @@ -36,7 +36,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -48,7 +48,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "session-tests", "documents": [ { @@ -238,7 +238,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "session-tests", "documents": [ { @@ -415,7 +415,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "session-tests", "documents": [ { @@ -544,7 +544,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "session-tests", "documents": [ { @@ -699,7 +699,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "session-tests", "documents": [ { @@ -830,7 +830,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "session-tests", "documents": [ { @@ -962,7 +962,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "session-tests", "documents": [ { diff --git a/test/sessions/driver-sessions-server-support.json b/test/sessions/driver-sessions-server-support.json index 55312b32eb..43a39958b8 100644 --- a/test/sessions/driver-sessions-server-support.json +++ b/test/sessions/driver-sessions-server-support.json @@ -27,7 +27,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -39,7 +39,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "session-tests", "documents": [ { @@ -147,7 +147,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "session-tests", "documents": [ { @@ -239,7 +239,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "session-tests", "documents": [ { diff --git a/test/test_auth.py b/test/test_auth.py index 27f6743fae..573bdcee66 100644 --- a/test/test_auth.py +++ b/test/test_auth.py @@ -231,7 +231,7 @@ def test_gssapi_threaded(self): # collection.find_one with a 1-second delay, forcing it to check out # multiple connections from the pool concurrently, proving that # auto-authentication works with GSSAPI. - collection = db.test + collection = db.coll if not collection.count_documents({}): try: collection.drop() @@ -402,10 +402,10 @@ class TestSCRAMSHA1(IntegrationTest): @client_context.require_auth def setUp(self): super().setUp() - client_context.create_user("pymongo_test", "user", "pass", roles=["userAdmin", "readWrite"]) + client_context.create_user("db", "user", "pass", roles=["userAdmin", "readWrite"]) def tearDown(self): - client_context.drop_user("pymongo_test", "user") + client_context.drop_user("db", "user") super().tearDown() @client_context.require_no_fips @@ -413,19 +413,19 @@ def test_scram_sha1(self): host, port = client_context.host, client_context.port client = self.rs_or_single_client_noauth( - "mongodb://user:pass@%s:%d/pymongo_test?authMechanism=SCRAM-SHA-1" % (host, port) + "mongodb://user:pass@%s:%d/db?authMechanism=SCRAM-SHA-1" % (host, port) ) - client.pymongo_test.command("dbstats") + client.db.command("dbstats") if client_context.is_rs: - uri = ( - "mongodb://user:pass" - "@%s:%d/pymongo_test?authMechanism=SCRAM-SHA-1" - "&replicaSet=%s" % (host, port, client_context.replica_set_name) + uri = "mongodb://user:pass" "@%s:%d/db?authMechanism=SCRAM-SHA-1" "&replicaSet=%s" % ( + host, + port, + client_context.replica_set_name, ) client = self.single_client_noauth(uri) - client.pymongo_test.command("dbstats") - db = client.get_database("pymongo_test", read_preference=ReadPreference.SECONDARY) + client.db.command("dbstats") + db = client.get_database("db", read_preference=ReadPreference.SECONDARY) db.command("dbstats") @@ -650,13 +650,13 @@ def test_cache(self): @client_context.require_sync def test_scram_threaded(self): - coll = client_context.client.db.test + coll = client_context.client.db.coll coll.drop() coll.insert_one({"_id": 1}) # The first thread to call find() will authenticate client = self.rs_or_single_client() - coll = client.db.test + coll = client.db.coll threads = [] for _ in range(4): threads.append(AutoAuthenticateThread(coll)) @@ -672,10 +672,10 @@ class TestAuthURIOptions(IntegrationTest): def setUp(self): super().setUp() client_context.create_user("admin", "admin", "pass") - client_context.create_user("pymongo_test", "user", "pass", ["userAdmin", "readWrite"]) + client_context.create_user("db", "user", "pass", ["userAdmin", "readWrite"]) def tearDown(self): - client_context.drop_user("pymongo_test", "user") + client_context.drop_user("db", "user") client_context.drop_user("admin", "admin") super().tearDown() @@ -697,14 +697,14 @@ def test_uri_options(self): self.assertTrue(db.command("dbstats")) # Test explicit database - uri = "mongodb://user:pass@%s:%d/pymongo_test" % (host, port) + uri = "mongodb://user:pass@%s:%d/db" % (host, port) client = self.rs_or_single_client_noauth(uri) with self.assertRaises(OperationFailure): client.admin.command("dbstats") - self.assertTrue(client.pymongo_test.command("dbstats")) + self.assertTrue(client.db.command("dbstats")) if client_context.is_rs: - uri = "mongodb://user:pass@%s:%d/pymongo_test?replicaSet=%s" % ( + uri = "mongodb://user:pass@%s:%d/db?replicaSet=%s" % ( host, port, client_context.replica_set_name, @@ -712,27 +712,28 @@ def test_uri_options(self): client = self.single_client_noauth(uri) with self.assertRaises(OperationFailure): client.admin.command("dbstats") - self.assertTrue(client.pymongo_test.command("dbstats")) - db = client.get_database("pymongo_test", read_preference=ReadPreference.SECONDARY) + self.assertTrue(client.db.command("dbstats")) + db = client.get_database("db", read_preference=ReadPreference.SECONDARY) self.assertTrue(db.command("dbstats")) # Test authSource - uri = "mongodb://user:pass@%s:%d/pymongo_test2?authSource=pymongo_test" % (host, port) + uri = "mongodb://user:pass@%s:%d/db2?authSource=db" % (host, port) client = self.rs_or_single_client_noauth(uri) with self.assertRaises(OperationFailure): - client.pymongo_test2.command("dbstats") - self.assertTrue(client.pymongo_test.command("dbstats")) + client.db2.command("dbstats") + self.assertTrue(client.db.command("dbstats")) if client_context.is_rs: - uri = ( - "mongodb://user:pass@%s:%d/pymongo_test2?replicaSet=" - "%s;authSource=pymongo_test" % (host, port, client_context.replica_set_name) + uri = "mongodb://user:pass@%s:%d/db2?replicaSet=" "%s;authSource=db" % ( + host, + port, + client_context.replica_set_name, ) client = self.single_client_noauth(uri) with self.assertRaises(OperationFailure): - client.pymongo_test2.command("dbstats") - self.assertTrue(client.pymongo_test.command("dbstats")) - db = client.get_database("pymongo_test", read_preference=ReadPreference.SECONDARY) + client.db2.command("dbstats") + self.assertTrue(client.db.command("dbstats")) + db = client.get_database("db", read_preference=ReadPreference.SECONDARY) self.assertTrue(db.command("dbstats")) diff --git a/test/test_auth_oidc.py b/test/test_auth_oidc.py index e88e067b2c..c0ff66aa59 100644 --- a/test/test_auth_oidc.py +++ b/test/test_auth_oidc.py @@ -177,7 +177,7 @@ def test_1_1_single_principal_implicit_username(self): # Create default OIDC client with authMechanism=MONGODB-OIDC. client = self.create_client() # Perform a find operation that succeeds. - client.test.test.find_one() + client.db.coll.find_one() # Close the client. client.close() @@ -185,7 +185,7 @@ def test_1_2_single_principal_explicit_username(self): # Create a client with MONGODB_URI_SINGLE, a username of test_user1, authMechanism=MONGODB-OIDC, and the OIDC human callback. client = self.create_client(username="test_user1") # Perform a find operation that succeeds. - client.test.test.find_one() + client.db.coll.find_one() # Close the client. client.close() @@ -195,7 +195,7 @@ def test_1_3_multiple_principal_user_1(self): # Create a client with MONGODB_URI_MULTI, a username of test_user1, authMechanism=MONGODB-OIDC, and the OIDC human callback. client = self.create_client(self.uri_multiple, username="test_user1") # Perform a find operation that succeeds. - client.test.test.find_one() + client.db.coll.find_one() # Close the client. client.close() @@ -206,7 +206,7 @@ def test_1_4_multiple_principal_user_2(self): # Create a client with MONGODB_URI_MULTI, a username of test_user2, authMechanism=MONGODB-OIDC, and the OIDC human callback. client = self.create_client(self.uri_multiple, username="test_user2") # Perform a find operation that succeeds. - client.test.test.find_one() + client.db.coll.find_one() # Close the client. client.close() @@ -217,7 +217,7 @@ def test_1_5_multiple_principal_no_user(self): client = self.create_client(self.uri_multiple) # Assert that a find operation fails. with self.assertRaises(OperationFailure): - client.test.test.find_one() + client.db.coll.find_one() # Close the client. client.close() @@ -228,7 +228,7 @@ def test_1_6_allowed_hosts_blocked(self): client = self.create_client(authmechanismproperties=props) # Assert that a find operation fails with a client-side error. with self.assertRaises(ConfigurationError): - client.test.test.find_one() + client.db.coll.find_one() # Close the client. client.close() @@ -247,7 +247,7 @@ def test_1_6_allowed_hosts_blocked(self): ) # Assert that a find operation fails with a client-side error. with self.assertRaises(ConfigurationError): - client.test.test.find_one() + client.db.coll.find_one() # Close the client. client.close() @@ -269,7 +269,7 @@ def test_1_8_machine_idp_human_callback(self): # Create a client with MONGODB_URI_SINGLE, a username of test_machine, authMechanism=MONGODB-OIDC, and the OIDC human callback. client = self.create_client(username="test_machine") # Perform a find operation that succeeds. - client.test.test.find_one() + client.db.coll.find_one() # Close the client. client.close() @@ -278,7 +278,7 @@ def test_2_1_valid_callback_inputs(self): client = self.create_client() # Perform a find operation that succeeds. Verify that the human callback was called with the appropriate inputs, including the timeout parameter if possible. # Ensure that there are no unexpected fields. - client.test.test.find_one() + client.db.coll.find_one() # Close the client. client.close() @@ -291,7 +291,7 @@ def fetch(self, ctx): client = self.create_client(request_cb=CustomCB()) # Perform a find operation that fails. with self.assertRaises(ValueError): - client.test.test.find_one() + client.db.coll.find_one() # Close the client. client.close() @@ -300,7 +300,7 @@ def test_2_3_refresh_token_is_passed_to_the_callback(self): client = self.create_client() # Perform a find operation that succeeds. - client.test.test.find_one() + client.db.coll.find_one() # Set a fail point for ``find`` commands. with self.fail_point( @@ -310,7 +310,7 @@ def test_2_3_refresh_token_is_passed_to_the_callback(self): } ): # Perform a ``find`` operation that succeeds. - client.test.test.find_one() + client.db.coll.find_one() # Assert that the callback has been called twice. self.assertEqual(self.request_called, 2) @@ -331,7 +331,7 @@ def test_3_1_uses_speculative_authentication_if_there_is_a_cached_token(self): ): # Perform a ``find`` operation that fails. with self.assertRaises(AutoReconnect): - client.test.test.find_one() + client.db.coll.find_one() # Set a fail point for ``saslStart`` commands. with self.fail_point( @@ -341,7 +341,7 @@ def test_3_1_uses_speculative_authentication_if_there_is_a_cached_token(self): } ): # Perform a ``find`` operation that succeeds - client.test.test.find_one() + client.db.coll.find_one() # Close the client. client.close() @@ -359,7 +359,7 @@ def test_3_2_does_not_use_speculative_authentication_if_there_is_no_cached_token ): # Perform a ``find`` operation that fails. with self.assertRaises(OperationFailure): - client.test.test.find_one() + client.db.coll.find_one() # Close the client. client.close() @@ -372,7 +372,7 @@ def test_4_1_reauthenticate_succeeds(self): client = self.create_client(event_listeners=[listener]) # Perform a find operation that succeeds. - client.test.test.find_one() + client.db.coll.find_one() # Assert that the human callback has been called once. self.assertEqual(self.request_called, 1) @@ -388,7 +388,7 @@ def test_4_1_reauthenticate_succeeds(self): } ): # Perform another find operation that succeeds. - client.test.test.find_one() + client.db.coll.find_one() # Assert that the human callback has been called twice. self.assertEqual(self.request_called, 2) @@ -434,7 +434,7 @@ def fetch(self, *args, **kwargs): client = self.create_client(request_cb=CustomRequest()) # Perform a find operation that succeeds. - client.test.test.find_one() + client.db.coll.find_one() # Assert that the human callback has been called once. self.assertEqual(self.request_called, 1) @@ -447,7 +447,7 @@ def fetch(self, *args, **kwargs): } ): # Perform a find operation that succeeds. - client.test.test.find_one() + client.db.coll.find_one() # Assert that the human callback has been called twice. self.assertEqual(self.request_called, 2) @@ -467,7 +467,7 @@ def fetch(self, *args, **kwargs): client = self.create_client(request_cb=CustomRequest()) # Perform a find operation that succeeds. - client.test.test.find_one() + client.db.coll.find_one() # Assert that the human callback has been called once. self.assertEqual(self.request_called, 1) @@ -480,7 +480,7 @@ def fetch(self, *args, **kwargs): } ): # Perform a find operation that succeeds. - client.test.test.find_one() + client.db.coll.find_one() # Assert that the human callback has been called 2 times. self.assertEqual(self.request_called, 2) @@ -507,7 +507,7 @@ def fetch(self, *args, **kwargs): client = self.create_client(request_cb=CustomRequest()) # Perform a find operation that succeeds (to force a speculative auth). - client.test.test.find_one() + client.db.coll.find_one() # Assert that the human callback has been called once. self.assertEqual(self.request_called, 1) @@ -520,7 +520,7 @@ def fetch(self, *args, **kwargs): ): # Perform a find operation that fails. with self.assertRaises(OperationFailure): - client.test.test.find_one() + client.db.coll.find_one() # Assert that the human callback has been called three times. self.assertEqual(self.request_called, 3) @@ -535,7 +535,7 @@ def fetch(self, a): client = self.create_client(request_cb=RequestTokenNull()) with self.assertRaises(ValueError): - client.test.test.find_one() + client.db.coll.find_one() client.close() def test_request_callback_invalid_result(self): @@ -545,7 +545,7 @@ def fetch(self, a): client = self.create_client(request_cb=CallbackInvalidToken()) with self.assertRaises(ValueError): - client.test.test.find_one() + client.db.coll.find_one() client.close() def test_reauthentication_succeeds_multiple_connections(self): @@ -556,8 +556,8 @@ def test_reauthentication_succeeds_multiple_connections(self): client2 = self.create_client(request_cb=request_cb) # Perform an insert operation. - client1.test.test.insert_many([{"a": 1}, {"a": 1}]) - client2.test.test.find_one() + client1.db.coll.insert_many([{"a": 1}, {"a": 1}]) + client2.db.coll.find_one() self.assertEqual(self.request_called, 2) # Use the same authenticator for both clients @@ -568,8 +568,8 @@ def test_reauthentication_succeeds_multiple_connections(self): client1.options.pool_options._credentials.cache.data ) - client1.test.test.find_one() - client2.test.test.find_one() + client1.db.coll.find_one() + client2.db.coll.find_one() with self.fail_point( { @@ -577,7 +577,7 @@ def test_reauthentication_succeeds_multiple_connections(self): "data": {"failCommands": ["find"], "errorCode": 391}, } ): - client1.test.test.find_one() + client1.db.coll.find_one() self.assertEqual(self.request_called, 3) @@ -587,7 +587,7 @@ def test_reauthentication_succeeds_multiple_connections(self): "data": {"failCommands": ["find"], "errorCode": 391}, } ): - client2.test.test.find_one() + client2.db.coll.find_one() self.assertEqual(self.request_called, 3) client1.close() @@ -600,7 +600,7 @@ def test_reauthenticate_succeeds_bulk_write(self): client = self.create_client() # Perform a find operation. - client.test.test.find_one() + client.db.coll.find_one() # Assert that the request callback has been called once. self.assertEqual(self.request_called, 1) @@ -612,7 +612,7 @@ def test_reauthenticate_succeeds_bulk_write(self): } ): # Perform a bulk write operation. - client.test.test.bulk_write([InsertOne({})]) # type:ignore[type-var] + client.db.coll.bulk_write([InsertOne({})]) # type:ignore[type-var] # Assert that the request callback has been called twice. self.assertEqual(self.request_called, 2) @@ -623,10 +623,10 @@ def test_reauthenticate_succeeds_bulk_read(self): client = self.create_client() # Perform a find operation. - client.test.test.find_one() + client.db.coll.find_one() # Perform a bulk write operation. - client.test.test.bulk_write([InsertOne({})]) # type:ignore[type-var] + client.db.coll.bulk_write([InsertOne({})]) # type:ignore[type-var] # Assert that the request callback has been called once. self.assertEqual(self.request_called, 1) @@ -638,7 +638,7 @@ def test_reauthenticate_succeeds_bulk_read(self): } ): # Perform a bulk read operation. - cursor = client.test.test.find_raw_batches({}) + cursor = client.db.coll.find_raw_batches({}) cursor.to_list() # Assert that the request callback has been called twice. @@ -650,7 +650,7 @@ def test_reauthenticate_succeeds_cursor(self): client = self.create_client() # Perform an insert operation. - client.test.test.insert_one({"a": 1}) + client.db.coll.insert_one({"a": 1}) # Assert that the request callback has been called once. self.assertEqual(self.request_called, 1) @@ -662,7 +662,7 @@ def test_reauthenticate_succeeds_cursor(self): } ): # Perform a find operation. - cursor = client.test.test.find({"a": 1}) + cursor = client.db.coll.find({"a": 1}) self.assertGreaterEqual(len(cursor.to_list()), 1) # Assert that the request callback has been called twice. @@ -674,7 +674,7 @@ def test_reauthenticate_succeeds_get_more(self): client = self.create_client() # Perform an insert operation. - client.test.test.insert_many([{"a": 1}, {"a": 1}]) + client.db.coll.insert_many([{"a": 1}, {"a": 1}]) # Assert that the request callback has been called once. self.assertEqual(self.request_called, 1) @@ -686,7 +686,7 @@ def test_reauthenticate_succeeds_get_more(self): } ): # Perform a find operation. - cursor = client.test.test.find({"a": 1}, batch_size=1) + cursor = client.db.coll.find({"a": 1}, batch_size=1) self.assertGreaterEqual(len(cursor.to_list()), 1) # Assert that the request callback has been called twice. @@ -704,7 +704,7 @@ def test_reauthenticate_succeeds_get_more_exhaust(self): client = self.create_client() # Perform an insert operation. - client.test.test.insert_many([{"a": 1}, {"a": 1}]) + client.db.coll.insert_many([{"a": 1}, {"a": 1}]) # Assert that the request callback has been called once. self.assertEqual(self.request_called, 1) @@ -716,7 +716,7 @@ def test_reauthenticate_succeeds_get_more_exhaust(self): } ): # Perform a find operation. - cursor = client.test.test.find({"a": 1}, batch_size=1, cursor_type=CursorType.EXHAUST) + cursor = client.db.coll.find({"a": 1}, batch_size=1, cursor_type=CursorType.EXHAUST) self.assertGreaterEqual(len(cursor.to_list()), 1) # Assert that the request callback has been called twice. @@ -728,7 +728,7 @@ def test_reauthenticate_succeeds_command(self): client = self.create_client() # Perform an insert operation. - client.test.test.insert_one({"a": 1}) + client.db.coll.insert_one({"a": 1}) # Assert that the request callback has been called once. self.assertEqual(self.request_called, 1) @@ -787,7 +787,7 @@ def test_1_1_callback_is_called_during_reauthentication(self): # implements the provider logic. client = self.create_client() # Perform a ``find`` operation that succeeds. - client.test.test.find_one() + client.db.coll.find_one() # Assert that the callback was called 1 time. self.assertEqual(self.request_called, 1) @@ -800,7 +800,7 @@ def test_1_2_callback_is_called_once_for_multiple_connections(self): # Start 10 tasks and run 100 find operations that all succeed in each task. def target(): for _ in range(100): - client.test.test.find_one() + client.db.coll.find_one() tasks = [] for i in range(10): @@ -816,7 +816,7 @@ def test_2_1_valid_callback_inputs(self): # Create a MongoClient configured with an OIDC callback that validates its inputs and returns a valid access token. client = self.create_client() # Perform a find operation that succeeds. - client.test.test.find_one() + client.db.coll.find_one() # Assert that the OIDC callback was called with the appropriate inputs, including the timeout parameter if possible. Ensure that there are no unexpected fields. self.assertEqual(self.request_called, 1) @@ -829,7 +829,7 @@ def fetch(self, a): client = self.create_client(request_cb=CallbackNullToken()) # Perform a find operation that fails. with self.assertRaises(ValueError): - client.test.test.find_one() + client.db.coll.find_one() def test_2_3_oidc_callback_returns_missing_data(self): # Create a MongoClient configured with an OIDC callback that returns data not conforming to the OIDCCredential with missing fields. @@ -843,7 +843,7 @@ def fetch(self, a): client = self.create_client(request_cb=CustomCallback()) # Perform a find operation that fails. with self.assertRaises(ValueError): - client.test.test.find_one() + client.db.coll.find_one() def test_2_4_invalid_client_configuration_with_callback(self): # Create a MongoClient configured with an OIDC callback and auth mechanism property ENVIRONMENT:test. @@ -898,13 +898,13 @@ def test_3_1_authentication_failure_with_cached_tokens_fetch_a_new_token_and_ret # Perform a ``find`` operation that fails. This is to force the ``MongoClient`` # to cache an access token. with self.assertRaises(AutoReconnect): - client.test.test.find_one() + client.db.coll.find_one() # Poison the cache of the client. client.options.pool_options._credentials.cache.data.access_token = "bad" # Reset the request count. self.request_called = 0 # Verify that a find succeeds. - client.test.test.find_one() + client.db.coll.find_one() # Verify that the callback was called 1 time. self.assertEqual(self.request_called, 1) @@ -921,7 +921,7 @@ def fetch(self, a): client = self.create_client(request_cb=callback) # Perform a ``find`` operation that fails. with self.assertRaises(OperationFailure): - client.test.test.find_one() + client.db.coll.find_one() # Verify that the callback was called 1 time. self.assertEqual(callback.count, 1) @@ -938,13 +938,13 @@ def test_3_3_unexpected_error_code_does_not_clear_cache(self): ): # Perform a ``find`` operation that fails. with self.assertRaises(OperationFailure): - client.test.test.find_one() + client.db.coll.find_one() # Assert that the callback has been called once. self.assertEqual(self.request_called, 1) # Perform a ``find`` operation that succeeds. - client.test.test.find_one() + client.db.coll.find_one() # Assert that the callback has been called once. self.assertEqual(self.request_called, 1) @@ -963,7 +963,7 @@ def test_4_1_reauthentication_succeeds(self): } ): # Perform a ``find`` operation that succeeds. - client.test.test.find_one() + client.db.coll.find_one() # Verify that the callback was called 2 times (once during the connection # handshake, and again during reauthentication). @@ -989,7 +989,7 @@ def fetch(self, _): client = self.create_client(request_cb=callback) # Perform a read operation that succeeds. - client.test.test.find_one() + client.db.coll.find_one() # Set a fail point for the find command. with self.fail_point( @@ -1000,7 +1000,7 @@ def fetch(self, _): ): # Perform a ``find`` operation that fails. with self.assertRaises(OperationFailure): - client.test.test.find_one() + client.db.coll.find_one() # Verify that the callback was called 2 times. self.assertEqual(callback.count, 2) @@ -1025,7 +1025,7 @@ def fetch(self, _): client = self.create_client(request_cb=callback) # Perform an insert operation that succeeds. - client.test.test.insert_one({}) + client.db.coll.insert_one({}) # Set a fail point for the find command. with self.fail_point( @@ -1036,7 +1036,7 @@ def fetch(self, _): ): # Perform a ``insert`` operation that fails. with self.assertRaises(OperationFailure): - client.test.test.insert_one({}) + client.db.coll.insert_one({}) # Verify that the callback was called 2 times. self.assertEqual(callback.count, 2) @@ -1049,7 +1049,7 @@ def test_4_4_speculative_authentication_should_be_ignored_on_reauthentication(se # Preload the *Client Cache* with a valid access token to enforce Speculative Authentication. client2 = self.create_client() - client2.test.test.find_one() + client2.db.coll.find_one() client.options.pool_options._credentials.cache.data = ( client2.options.pool_options._credentials.cache.data ) @@ -1057,7 +1057,7 @@ def test_4_4_speculative_authentication_should_be_ignored_on_reauthentication(se self.request_called = 0 # Perform an `insert` operation that succeeds. - client.test.test.insert_one({}) + client.db.coll.insert_one({}) # Assert that the callback was not called. self.assertEqual(self.request_called, 0) @@ -1076,7 +1076,7 @@ def test_4_4_speculative_authentication_should_be_ignored_on_reauthentication(se } ): # Perform an `insert` operation that succeeds. - client.test.test.insert_one({}) + client.db.coll.insert_one({}) # Assert that the callback was called once. self.assertEqual(self.request_called, 1) @@ -1098,7 +1098,7 @@ def test_4_5_reauthentication_succeeds_when_a_session_is_involved(self): # Start a new session. with client.start_session() as session: # In the started session perform a `find` operation that succeeds. - client.test.test.find_one({}, session=session) + client.db.coll.find_one({}, session=session) # Assert that the callback was called 2 times (once during the connection handshake, and again during reauthentication). self.assertEqual(self.request_called, 2) @@ -1111,7 +1111,7 @@ def test_5_1_azure_with_no_username(self): props = dict(TOKEN_RESOURCE=resource, ENVIRONMENT="azure") client = self.create_client(authMechanismProperties=props) - client.test.test.find_one() + client.db.coll.find_one() def test_5_2_azure_with_bad_username(self): if ENVIRON != "azure": @@ -1123,11 +1123,11 @@ def test_5_2_azure_with_bad_username(self): props = dict(TOKEN_RESOURCE=token_aud, ENVIRONMENT="azure") client = self.create_client(username="bad", authmechanismproperties=props) with self.assertRaises(ValueError): - client.test.test.find_one() + client.db.coll.find_one() def test_speculative_auth_success(self): client1 = self.create_client() - client1.test.test.find_one() + client1.db.coll.find_one() client2 = self.create_client() client2._connect() @@ -1144,15 +1144,15 @@ def test_speculative_auth_success(self): } ): # Perform a find operation. - client2.test.test.find_one() + client2.db.coll.find_one() def test_reauthentication_succeeds_multiple_connections(self): client1 = self.create_client() client2 = self.create_client() # Perform an insert operation. - client1.test.test.insert_many([{"a": 1}, {"a": 1}]) - client2.test.test.find_one() + client1.db.coll.insert_many([{"a": 1}, {"a": 1}]) + client2.db.coll.find_one() self.assertEqual(self.request_called, 2) # Use the same authenticator for both clients @@ -1163,8 +1163,8 @@ def test_reauthentication_succeeds_multiple_connections(self): client1.options.pool_options._credentials.cache.data ) - client1.test.test.find_one() - client2.test.test.find_one() + client1.db.coll.find_one() + client2.db.coll.find_one() with self.fail_point( { @@ -1172,7 +1172,7 @@ def test_reauthentication_succeeds_multiple_connections(self): "data": {"failCommands": ["find"], "errorCode": 391}, } ): - client1.test.test.find_one() + client1.db.coll.find_one() self.assertEqual(self.request_called, 3) @@ -1182,7 +1182,7 @@ def test_reauthentication_succeeds_multiple_connections(self): "data": {"failCommands": ["find"], "errorCode": 391}, } ): - client2.test.test.find_one() + client2.db.coll.find_one() self.assertEqual(self.request_called, 3) diff --git a/test/test_binary.py b/test/test_binary.py index a64aa42280..328dc3fb25 100644 --- a/test/test_binary.py +++ b/test/test_binary.py @@ -389,7 +389,7 @@ def _get_coll_w_uuid_rep(self, uuid_rep): uuid_representation=validate_uuid_representation(None, uuid_rep) ) coll = self.db.get_collection( - "pymongo_test", codec_options=codec_options, write_concern=WriteConcern("majority") + "db", codec_options=codec_options, write_concern=WriteConcern("majority") ) return coll diff --git a/test/test_bulk.py b/test/test_bulk.py index 712c6c6a26..b193de5e43 100644 --- a/test/test_bulk.py +++ b/test/test_bulk.py @@ -44,7 +44,7 @@ class BulkTestBase(IntegrationTest): def setUp(self): super().setUp() - self.coll = self.db.test + self.coll = self.db.coll self.coll.drop() self.coll_w0 = self.coll.with_options(write_concern=WriteConcern(w=0)) @@ -792,7 +792,7 @@ def setUp(self): privileges=[ { "actions": ["insert", "update", "find"], - "resource": {"db": "pymongo_test", "collection": "test"}, + "resource": {"db": "db", "collection": "coll"}, } ], roles=[], @@ -896,10 +896,8 @@ class TestBulkAuthorization(BulkAuthorizationTestBase): def test_readonly(self): # We test that an authorization failure aborts the batch and is raised # as OperationFailure. - cli = self.rs_or_single_client_noauth( - username="readonly", password="pw", authSource="pymongo_test" - ) - coll = cli.pymongo_test.test + cli = self.rs_or_single_client_noauth(username="readonly", password="pw", authSource="db") + coll = cli.db.coll coll.find_one() with self.assertRaises(OperationFailure): coll.bulk_write([InsertOne({"x": 1})]) @@ -907,10 +905,8 @@ def test_readonly(self): def test_no_remove(self): # We test that an authorization failure aborts the batch and is raised # as OperationFailure. - cli = self.rs_or_single_client_noauth( - username="noremove", password="pw", authSource="pymongo_test" - ) - coll = cli.pymongo_test.test + cli = self.rs_or_single_client_noauth(username="noremove", password="pw", authSource="db") + coll = cli.db.coll coll.find_one() requests = [ InsertOne({"x": 1}), diff --git a/test/test_change_stream.py b/test/test_change_stream.py index 717d7d3bd7..1c3b73225f 100644 --- a/test/test_change_stream.py +++ b/test/test_change_stream.py @@ -762,7 +762,7 @@ class TestClusterChangeStream(TestChangeStreamBase, APITestsMixin): @client_context.require_change_streams # type:ignore[untyped-decorator] def setUp(self) -> None: super().setUp() - self.dbs = [self.db, self.client.pymongo_test_2] + self.dbs = [self.db, self.client.db2] def tearDown(self): for db in self.dbs: @@ -893,7 +893,7 @@ def test_simple(self): def test_isolation(self): # Ensure inserts to other dbs don't show up in our ChangeStream. - other_db = self.client.pymongo_test_temp + other_db = self.client.coll self.assertNotEqual(other_db, self.db, msg="Isolation must be tested on separate DBs") collname = self.id() with self.change_stream() as change_stream: diff --git a/test/test_client.py b/test/test_client.py index d62a89ef8d..52d5da5a21 100644 --- a/test/test_client.py +++ b/test/test_client.py @@ -849,13 +849,13 @@ def test_init_disconnected(self): bad_host = "somedomainthatdoesntexist.org" c = self.simple_client(bad_host, port, connectTimeoutMS=1, serverSelectionTimeoutMS=10) with self.assertRaises(ConnectionFailure): - c.pymongo_test.test.find_one() + c.db.coll.find_one() def test_init_disconnected_with_auth(self): uri = "mongodb://user:pass@somedomainthatdoesntexist" c = self.simple_client(uri, connectTimeoutMS=1, serverSelectionTimeoutMS=10) with self.assertRaises(ConnectionFailure): - c.pymongo_test.test.find_one() + c.db.coll.find_one() @client_context.require_replica_set @client_context.require_no_load_balancer @@ -1020,7 +1020,7 @@ def test_list_databases(self): for doc in client.list_databases(): self.assertIs(type(doc), dict) - self.client.pymongo_test.test.insert_one({}) + self.client.db.coll.insert_one({}) cursor = self.client.list_databases(filter={"name": "admin"}) docs = cursor.to_list() self.assertEqual(1, len(docs)) @@ -1031,14 +1031,14 @@ def test_list_databases(self): self.assertEqual(["name"], list(doc)) def test_list_database_names(self): - self.client.pymongo_test.test.insert_one({"dummy": "object"}) - self.client.pymongo_test_mike.test.insert_one({"dummy": "object"}) + self.client.db.coll.insert_one({"dummy": "object"}) + self.client.db_mike.test.insert_one({"dummy": "object"}) cmd_docs = (self.client.admin.command("listDatabases"))["databases"] cmd_names = [doc["name"] for doc in cmd_docs] db_names = self.client.list_database_names() - self.assertIn("pymongo_test", db_names) - self.assertIn("pymongo_test_mike", db_names) + self.assertIn("db", db_names) + self.assertIn("db_mike", db_names) self.assertCountEqual(db_names, cmd_names) def test_drop_database(self): @@ -1047,26 +1047,26 @@ def test_drop_database(self): with self.assertRaises(TypeError): self.client.drop_database(None) # type: ignore[arg-type] - self.client.pymongo_test.test.insert_one({"dummy": "object"}) - self.client.pymongo_test2.test.insert_one({"dummy": "object"}) + self.client.db.coll.insert_one({"dummy": "object"}) + self.client.db2.coll.insert_one({"dummy": "object"}) dbs = self.client.list_database_names() - self.assertIn("pymongo_test", dbs) - self.assertIn("pymongo_test2", dbs) - self.client.drop_database("pymongo_test") + self.assertIn("db", dbs) + self.assertIn("db2", dbs) + self.client.drop_database("db") if client_context.is_rs: wc_client = self.rs_or_single_client(w=len(client_context.nodes) + 1) with self.assertRaises(WriteConcernError): - wc_client.drop_database("pymongo_test2") + wc_client.drop_database("db2") - self.client.drop_database(self.client.pymongo_test2) + self.client.drop_database(self.client.db2) dbs = self.client.list_database_names() - self.assertNotIn("pymongo_test", dbs) - self.assertNotIn("pymongo_test2", dbs) + self.assertNotIn("db", dbs) + self.assertNotIn("db2", dbs) def test_close(self): test_client = self.rs_or_single_client() - coll = test_client.pymongo_test.bar + coll = test_client.db.coll test_client.close() with self.assertRaises(InvalidOperation): coll.count_documents({}) @@ -1078,7 +1078,7 @@ def test_close_kills_cursors(self): test_client._process_periodic_tasks() # Add some test data. - coll = test_client.pymongo_test.test_close_kills_cursors + coll = test_client.db.coll_close_kills_cursors docs_inserted = 1000 coll.insert_many([{"i": i} for i in range(docs_inserted)]) @@ -1106,7 +1106,7 @@ def test_close_kills_cursors(self): def test_close_stops_kill_cursors_thread(self): client = self.rs_client() - client.test.test.find_one() + client.db.coll.find_one() self.assertFalse(client._kill_cursors_executor._stopped) # Closing the client should stop the thread. @@ -1150,7 +1150,7 @@ def test_close_does_not_open_servers(self): def test_close_closes_sockets(self): client = self.rs_client() - client.test.test.find_one() + client.db.coll.find_one() topology = client._topology client.close() for server in topology._servers.values(): @@ -1170,9 +1170,9 @@ def test_auth_from_uri(self): host, port = client_context.host, client_context.port client_context.create_user("admin", "admin", "pass") self.addCleanup(client_context.drop_user, "admin", "admin") - self.addCleanup(remove_all_users, self.client.pymongo_test) + self.addCleanup(remove_all_users, self.client.db) - client_context.create_user("pymongo_test", "user", "pass", roles=["userAdmin", "readWrite"]) + client_context.create_user("db", "user", "pass", roles=["userAdmin", "readWrite"]) with self.assertRaises(OperationFailure): connected(self.rs_or_single_client_noauth("mongodb://a:b@%s:%d" % (host, port))) @@ -1181,29 +1181,27 @@ def test_auth_from_uri(self): connected(self.rs_or_single_client_noauth("mongodb://admin:pass@%s:%d" % (host, port))) # Wrong database. - uri = "mongodb://admin:pass@%s:%d/pymongo_test" % (host, port) + uri = "mongodb://admin:pass@%s:%d/db" % (host, port) with self.assertRaises(OperationFailure): connected(self.rs_or_single_client_noauth(uri)) # No error. - connected( - self.rs_or_single_client_noauth("mongodb://user:pass@%s:%d/pymongo_test" % (host, port)) - ) + connected(self.rs_or_single_client_noauth("mongodb://user:pass@%s:%d/db" % (host, port))) # Auth with lazy connection. ( self.rs_or_single_client_noauth( - "mongodb://user:pass@%s:%d/pymongo_test" % (host, port), connect=False + "mongodb://user:pass@%s:%d/db" % (host, port), connect=False ) - ).pymongo_test.test.find_one() + ).db.coll.find_one() # Wrong password. bad_client = self.rs_or_single_client_noauth( - "mongodb://user:wrong@%s:%d/pymongo_test" % (host, port), connect=False + "mongodb://user:wrong@%s:%d/db" % (host, port), connect=False ) with self.assertRaises(OperationFailure): - bad_client.pymongo_test.test.find_one() + bad_client.db.coll.find_one() @client_context.require_auth def test_username_and_password(self): @@ -1229,10 +1227,10 @@ def test_username_and_password(self): def test_lazy_auth_raises_operation_failure(self): host = client_context.host lazy_client = self.rs_or_single_client_noauth( - f"mongodb://user:wrong@{host}/pymongo_test", connect=False + f"mongodb://user:wrong@{host}/db", connect=False ) - assertRaisesExactly(OperationFailure, lazy_client.test.collection.find_one) + assertRaisesExactly(OperationFailure, lazy_client.db.coll.find_one) @client_context.require_no_tls def test_unix_socket(self): @@ -1247,9 +1245,9 @@ def test_unix_socket(self): uri = "mongodb://%s" % encoded_socket # Confirm we can do operations via the socket. client = self.rs_or_single_client(uri) - client.pymongo_test.test.insert_one({"dummy": "object"}) + client.db.coll.insert_one({"dummy": "object"}) dbs = client.list_database_names() - self.assertIn("pymongo_test", dbs) + self.assertIn("db", dbs) self.assertIn(mongodb_socket, repr(client)) @@ -1262,19 +1260,19 @@ def test_unix_socket(self): def test_document_class(self): c = self.client - db = c.pymongo_test - db.test.insert_one({"x": 1}) + db = c.db + db.coll.insert_one({"x": 1}) self.assertEqual(dict, c.codec_options.document_class) - self.assertIsInstance(db.test.find_one(), dict) - self.assertNotIsInstance(db.test.find_one(), SON) + self.assertIsInstance(db.coll.find_one(), dict) + self.assertNotIsInstance(db.coll.find_one(), SON) c = self.rs_or_single_client(document_class=SON) - db = c.pymongo_test + db = c.db self.assertEqual(SON, c.codec_options.document_class) - self.assertIsInstance(db.test.find_one(), SON) + self.assertIsInstance(db.coll.find_one(), SON) def test_timeouts(self): client = self.rs_or_single_client( @@ -1316,19 +1314,19 @@ def test_socket_timeout(self): timeout_sec = 1 timeout = self.rs_or_single_client(socketTimeoutMS=1000 * timeout_sec) - no_timeout.pymongo_test.drop_collection("test") - no_timeout.pymongo_test.test.insert_one({"x": 1}) + no_timeout.db.drop_collection("coll") + no_timeout.db.coll.insert_one({"x": 1}) # A $where clause that takes a second longer than the timeout where_func = delay(timeout_sec + 1) def get_x(db): - doc = next(db.test.find().where(where_func)) + doc = next(db.coll.find().where(where_func)) return doc["x"] - self.assertEqual(1, get_x(no_timeout.pymongo_test)) + self.assertEqual(1, get_x(no_timeout.db)) with self.assertRaises(NetworkTimeout): - get_x(timeout.pymongo_test) + get_x(timeout.db) def test_server_selection_timeout(self): client = MongoClient(serverSelectionTimeoutMS=100, connect=False) @@ -1387,16 +1385,16 @@ def test_tz_aware(self): aware = self.rs_or_single_client(tz_aware=True) self.addCleanup(aware.close) naive = self.client - aware.pymongo_test.drop_collection("test") + aware.db.drop_collection("coll") now = datetime.datetime.now(tz=datetime.timezone.utc) - aware.pymongo_test.test.insert_one({"x": now}) + aware.db.coll.insert_one({"x": now}) - self.assertEqual(None, (naive.pymongo_test.test.find_one())["x"].tzinfo) - self.assertEqual(utc, (aware.pymongo_test.test.find_one())["x"].tzinfo) + self.assertEqual(None, (naive.db.coll.find_one())["x"].tzinfo) + self.assertEqual(utc, (aware.db.coll.find_one())["x"].tzinfo) self.assertEqual( - (aware.pymongo_test.test.find_one())["x"].replace(tzinfo=None), - (naive.pymongo_test.test.find_one())["x"], + (aware.db.coll.find_one())["x"].replace(tzinfo=None), + (naive.db.coll.find_one())["x"], ) @client_context.require_ipv6 @@ -1415,17 +1413,17 @@ def test_ipv6(self): uri += "/?replicaSet=" + (client_context.replica_set_name or "") client = self.rs_or_single_client_noauth(uri) - client.pymongo_test.test.insert_one({"dummy": "object"}) - client.pymongo_test_bernie.test.insert_one({"dummy": "object"}) + client.db.coll.insert_one({"dummy": "object"}) + client.db_bernie.coll.insert_one({"dummy": "object"}) dbs = client.list_database_names() - self.assertIn("pymongo_test", dbs) - self.assertIn("pymongo_test_bernie", dbs) + self.assertIn("db", dbs) + self.assertIn("db_bernie", dbs) def test_contextlib(self): client = self.rs_or_single_client() - client.pymongo_test.drop_collection("test") - client.pymongo_test.test.insert_one({"foo": "bar"}) + client.db.drop_collection("coll") + client.db.coll.insert_one({"foo": "bar"}) # The socket used for the previous commands has been returned to the # pool @@ -1434,14 +1432,14 @@ def test_contextlib(self): # contextlib async support was added in Python 3.10 if _IS_SYNC or sys.version_info >= (3, 10): with contextlib.closing(client): - self.assertEqual("bar", (client.pymongo_test.test.find_one())["foo"]) + self.assertEqual("bar", (client.db.coll.find_one())["foo"]) with self.assertRaises(InvalidOperation): - client.pymongo_test.test.find_one() + client.db.coll.find_one() client = self.rs_or_single_client() with client as client: - self.assertEqual("bar", (client.pymongo_test.test.find_one())["foo"]) + self.assertEqual("bar", (client.db.coll.find_one())["foo"]) with self.assertRaises(InvalidOperation): - client.pymongo_test.test.find_one() + client.db.coll.find_one() @client_context.require_sync def test_interrupt_signal(self): @@ -1450,7 +1448,7 @@ def test_interrupt_signal(self): # Test fix for PYTHON-294 -- make sure MongoClient closes its # socket if it gets an interrupt while waiting to recv() from it. - db = self.client.pymongo_test + db = self.client.db # A $where clause which takes 1.5 sec to execute where = delay(1.5) @@ -1510,15 +1508,15 @@ def test_operation_failure(self): # to avoid race conditions caused by replica set failover or idle # socket reaping. client = self.single_client() - client.pymongo_test.test.find_one() + client.db.coll.find_one() pool = get_pool(client) socket_count = len(pool.conns) self.assertGreaterEqual(socket_count, 1) old_conn = next(iter(pool.conns)) - client.pymongo_test.test.drop() - client.pymongo_test.test.insert_one({"_id": "foo"}) + client.db.coll.drop() + client.db.coll.insert_one({"_id": "foo"}) with self.assertRaises(OperationFailure): - client.pymongo_test.test.insert_one({"_id": "foo"}) + client.db.coll.insert_one({"_id": "foo"}) self.assertEqual(socket_count, len(pool.conns)) new_con = next(iter(pool.conns)) @@ -1534,26 +1532,26 @@ def test_lazy_connect_w0(self): self.addCleanup(client_context.client.drop_database, "test_lazy_connect_w0") client = self.rs_or_single_client(connect=False, w=0) - client.test_lazy_connect_w0.test.insert_one({}) + client.test_lazy_connect_w0.coll.insert_one({}) def predicate(): - return client.test_lazy_connect_w0.test.count_documents({}) == 1 + return client.test_lazy_connect_w0.coll.count_documents({}) == 1 wait_until(predicate, "find one document") client = self.rs_or_single_client(connect=False, w=0) - client.test_lazy_connect_w0.test.update_one({}, {"$set": {"x": 1}}) + client.test_lazy_connect_w0.coll.update_one({}, {"$set": {"x": 1}}) def predicate(): - return (client.test_lazy_connect_w0.test.find_one()).get("x") == 1 + return (client.test_lazy_connect_w0.coll.find_one()).get("x") == 1 wait_until(predicate, "update one document") client = self.rs_or_single_client(connect=False, w=0) - client.test_lazy_connect_w0.test.delete_one({}) + client.test_lazy_connect_w0.list_collection_names.delete_one({}) def predicate(): - return client.test_lazy_connect_w0.test.count_documents({}) == 0 + return client.test_lazy_connect_w0.coll.count_documents({}) == 0 wait_until(predicate, "delete one document") @@ -1562,7 +1560,7 @@ def test_exhaust_network_error(self): # When doing an exhaust query, the socket stays checked out on success # but must be checked in on error to avoid semaphore leaks. client = self.rs_or_single_client(maxPoolSize=1, retryReads=False) - collection = client.pymongo_test.test + collection = client.db.coll pool = get_pool(client) pool._check_interval_seconds = None # Never check. @@ -1599,16 +1597,16 @@ def test_auth_network_error(self): # Connection.authenticate logs, but gets a socket.error. Should be # reraised as AutoReconnect. with self.assertRaises(AutoReconnect): - c.test.collection.find_one() + c.db.coll.find_one() # No semaphore leak, the pool is allowed to make a new socket. - c.test.collection.find_one() + c.db.coll.find_one() @client_context.require_no_replica_set def test_connect_to_standalone_using_replica_set_name(self): client = self.single_client(replicaSet="anything", serverSelectionTimeoutMS=100) with self.assertRaises(AutoReconnect): - client.test.test.find_one() + client.db.coll.find_one() @client_context.require_replica_set def test_stale_getmore(self): @@ -1619,8 +1617,8 @@ def test_stale_getmore(self): client = self.rs_client(connect=False, serverSelectionTimeoutMS=100) client._run_operation( operation=message._GetMore( - "pymongo_test", - "collection", + "db", + "coll", 101, 1234, client.codec_options, @@ -1632,7 +1630,7 @@ def test_stale_getmore(self): False, None, ), - unpack_res=Cursor(client.pymongo_test.collection)._unpack_response, + unpack_res=Cursor(client.db.coll)._unpack_response, address=("not-a-member", 27017), ) @@ -1766,7 +1764,7 @@ def compression_settings(client): for level in range(-1, 10): client = self.single_client(zlibcompressionlevel=level) # No error - client.pymongo_test.test.find_one() + client.db.coll.find_one() @client_context.require_sync def test_reset_during_update_pool(self): @@ -1905,7 +1903,7 @@ def server_description_count(): ) initial_count = server_description_count() with self.assertRaises(ServerSelectionTimeoutError): - client.test.test.find_one() + client.db.coll.find_one() gc.collect() final_count = server_description_count() client.close() @@ -1924,12 +1922,12 @@ def test_network_error_message(self): assert client.address is not None expected = "{}:{}: ".format(*(client.address)) with self.assertRaisesRegex(AutoReconnect, expected): - client.pymongo_test.test.find_one({}) + client.db.coll.find_one({}) @unittest.skipIf("PyPy" in sys.version, "PYTHON-2938 could fail on PyPy") def test_process_periodic_tasks(self): client = self.rs_or_single_client() - coll = client.db.collection + coll = client.db.coll coll.insert_many([{} for _ in range(5)]) cursor = coll.find(batch_size=2) cursor.next() @@ -2126,23 +2124,23 @@ def test_handshake_09_container_with_provider(self): ) def test_dict_hints(self): - self.db.t.find(hint={"x": 1}) + self.db.coll.find(hint={"x": 1}) def test_dict_hints_sort(self): - result = self.db.t.find() + result = self.db.coll.find() result.sort({"x": 1}) - self.db.t.find(sort={"x": 1}) + self.db.coll.find(sort={"x": 1}) def test_dict_hints_create_index(self): - self.db.t.create_index({"x": pymongo.ASCENDING}) + self.db.coll.create_index({"x": pymongo.ASCENDING}) def test_legacy_java_uuid_roundtrip(self): data = BinaryData.java_data docs = bson.decode_all(data, CodecOptions(SON[str, Any], False, JAVA_LEGACY)) - client_context.client.pymongo_test.drop_collection("java_uuid") - db = client_context.client.pymongo_test + client_context.client.db.drop_collection("java_uuid") + db = client_context.client.db coll = db.get_collection("java_uuid", CodecOptions(uuid_representation=JAVA_LEGACY)) coll.insert_many(docs) @@ -2153,14 +2151,14 @@ def test_legacy_java_uuid_roundtrip(self): coll = db.get_collection("java_uuid", CodecOptions(uuid_representation=PYTHON_LEGACY)) for d in coll.find(): self.assertNotEqual(d["newguid"], d["newguidstring"]) - client_context.client.pymongo_test.drop_collection("java_uuid") + client_context.client.db.drop_collection("java_uuid") def test_legacy_csharp_uuid_roundtrip(self): data = BinaryData.csharp_data docs = bson.decode_all(data, CodecOptions(SON[str, Any], False, CSHARP_LEGACY)) - client_context.client.pymongo_test.drop_collection("csharp_uuid") - db = client_context.client.pymongo_test + client_context.client.db.drop_collection("csharp_uuid") + db = client_context.client.db coll = db.get_collection("csharp_uuid", CodecOptions(uuid_representation=CSHARP_LEGACY)) coll.insert_many(docs) @@ -2171,16 +2169,16 @@ def test_legacy_csharp_uuid_roundtrip(self): coll = db.get_collection("csharp_uuid", CodecOptions(uuid_representation=PYTHON_LEGACY)) for d in coll.find(): self.assertNotEqual(d["newguid"], d["newguidstring"]) - client_context.client.pymongo_test.drop_collection("csharp_uuid") + client_context.client.db.drop_collection("csharp_uuid") def test_uri_to_uuid(self): uri = "mongodb://foo/?uuidrepresentation=csharpLegacy" client = self.single_client(uri, connect=False) - self.assertEqual(client.pymongo_test.test.codec_options.uuid_representation, CSHARP_LEGACY) + self.assertEqual(client.db.coll.codec_options.uuid_representation, CSHARP_LEGACY) def test_uuid_queries(self): - db = client_context.client.pymongo_test - coll = db.test + db = client_context.client.db + coll = db.coll coll.drop() uu = uuid.uuid4() @@ -2189,7 +2187,7 @@ def test_uuid_queries(self): # Test regular UUID queries (using subtype 4). coll = db.get_collection( - "test", CodecOptions(uuid_representation=UuidRepresentation.STANDARD) + "coll", CodecOptions(uuid_representation=UuidRepresentation.STANDARD) ) self.assertEqual(0, coll.count_documents({"uuid": uu})) coll.insert_one({"uuid": uu}) @@ -2220,7 +2218,7 @@ def test_exhaust_query_server_error(self): # but must be checked in on error to avoid semaphore leaks. client = connected(self.rs_or_single_client(maxPoolSize=1)) - collection = client.pymongo_test.test + collection = client.db.coll pool = get_pool(client) conn = one(pool.conns) @@ -2242,11 +2240,11 @@ def test_exhaust_getmore_server_error(self): # When doing a getmore on an exhaust cursor, the socket stays checked # out on success but it's checked in on error to avoid semaphore leaks. client = self.rs_or_single_client(maxPoolSize=1) - collection = client.pymongo_test.test + collection = client.db.coll collection.drop() collection.insert_many([{} for _ in range(200)]) - self.addCleanup(client_context.client.pymongo_test.test.drop) + self.addCleanup(client_context.client.db.coll.drop) pool = get_pool(client) pool._check_interval_seconds = None # Never check. @@ -2281,7 +2279,7 @@ def test_exhaust_query_network_error(self): # When doing an exhaust query, the socket stays checked out on success # but must be checked in on error to avoid semaphore leaks. client = connected(self.rs_or_single_client(maxPoolSize=1, retryReads=False)) - collection = client.pymongo_test.test + collection = client.db.coll pool = get_pool(client) pool._check_interval_seconds = None # Never check. @@ -2302,7 +2300,7 @@ def test_exhaust_getmore_network_error(self): # When doing a getmore on an exhaust cursor, the socket stays checked # out on success but it's checked in on error to avoid semaphore leaks. client = self.rs_or_single_client(maxPoolSize=1) - collection = client.pymongo_test.test + collection = client.db.coll collection.drop() collection.insert_many([{} for _ in range(200)]) # More than one batch. pool = get_pool(client) @@ -2338,7 +2336,7 @@ def test_gevent_task(self): def poller(): while True: - client_context.client.pymongo_test.test.insert_one({}) + client_context.client.db.coll.insert_one({}) task = spawn(poller) task.kill() @@ -2351,7 +2349,7 @@ def test_gevent_timeout(self): from gevent import Timeout, spawn client = self.rs_or_single_client(maxPoolSize=1) - coll = client.pymongo_test.test + coll = client.db.coll coll.insert_one({}) def contentious_task(): @@ -2384,7 +2382,7 @@ def test_gevent_timeout_when_creating_connection(self): client = self.rs_or_single_client() self.addCleanup(client.close) - coll = client.pymongo_test.test + coll = client.db.coll pool = get_pool(client) # type:ignore # Patch the pool to delay the connect method. @@ -2531,7 +2529,7 @@ def test_reconnect(self): # ServerSelectionTimeoutError or AutoReconnect (from # MockPool.get_socket). with self.assertRaises(AutoReconnect): - c.db.collection.find_one() + c.db.coll.find_one() # But it can reconnect. c.revive_host("a:1") @@ -2588,31 +2586,31 @@ def _test_network_error(self, operation_callback): def test_network_error_on_query(self): def callback(client): - return client.db.collection.find_one() + return client.db.coll.find_one() self._test_network_error(callback) def test_network_error_on_insert(self): def callback(client): - return client.db.collection.insert_one({}) + return client.db.coll.insert_one({}) self._test_network_error(callback) def test_network_error_on_update(self): def callback(client): - return client.db.collection.update_one({}, {"$unset": "x"}) + return client.db.coll.update_one({}, {"$unset": "x"}) self._test_network_error(callback) def test_network_error_on_replace(self): def callback(client): - return client.db.collection.replace_one({}, {}) + return client.db.coll.replace_one({}, {}) self._test_network_error(callback) def test_network_error_on_delete(self): def callback(client): - return client.db.collection.delete_many({}) + return client.db.coll.delete_many({}) self._test_network_error(callback) diff --git a/test/test_client_backpressure.py b/test/test_client_backpressure.py index 61334a1218..63f7abe0f9 100644 --- a/test/test_client_backpressure.py +++ b/test/test_client_backpressure.py @@ -60,36 +60,36 @@ class TestBackpressure(IntegrationTest): @client_context.require_failCommand_appName def test_retry_overload_error_command(self): - self.db.t.insert_one({"x": 1}) + self.db.coll.insert_one({"x": 1}) # Ensure command is retried on overload error. fail_many = get_mock_overload_error(MAX_ADAPTIVE_RETRIES) with self.fail_point(fail_many): - self.db.command("find", "t") + self.db.command("find", "coll") # Ensure command stops retrying after MAX_ADAPTIVE_RETRIES. fail_too_many = get_mock_overload_error(MAX_ADAPTIVE_RETRIES + 1) with self.fail_point(fail_too_many): with self.assertRaises(PyMongoError) as error: - self.db.command("find", "t") + self.db.command("find", "coll") self.assertIn("RetryableError", str(error.exception)) self.assertIn("SystemOverloadedError", str(error.exception)) @client_context.require_failCommand_appName def test_retry_overload_error_find(self): - self.db.t.insert_one({"x": 1}) + self.db.coll.insert_one({"x": 1}) # Ensure command is retried on overload error. fail_many = get_mock_overload_error(MAX_ADAPTIVE_RETRIES) with self.fail_point(fail_many): - self.db.t.find_one() + self.db.coll.find_one() # Ensure command stops retrying after MAX_ADAPTIVE_RETRIES. fail_too_many = get_mock_overload_error(MAX_ADAPTIVE_RETRIES + 1) with self.fail_point(fail_too_many): with self.assertRaises(PyMongoError) as error: - self.db.t.find_one() + self.db.coll.find_one() self.assertIn("RetryableError", str(error.exception)) self.assertIn("SystemOverloadedError", str(error.exception)) @@ -99,13 +99,13 @@ def test_retry_overload_error_insert_one(self): # Ensure command is retried on overload error. fail_many = get_mock_overload_error(MAX_ADAPTIVE_RETRIES) with self.fail_point(fail_many): - self.db.t.insert_one({"x": 1}) + self.db.coll.insert_one({"x": 1}) # Ensure command stops retrying after MAX_ADAPTIVE_RETRIES. fail_too_many = get_mock_overload_error(MAX_ADAPTIVE_RETRIES + 1) with self.fail_point(fail_too_many): with self.assertRaises(PyMongoError) as error: - self.db.t.insert_one({"x": 1}) + self.db.coll.insert_one({"x": 1}) self.assertIn("RetryableError", str(error.exception)) self.assertIn("SystemOverloadedError", str(error.exception)) @@ -114,25 +114,25 @@ def test_retry_overload_error_insert_one(self): def test_retry_overload_error_update_many(self): # Even though update_many is not a retryable write operation, it will # still be retried via the "RetryableError" error label. - self.db.t.insert_one({"x": 1}) + self.db.coll.insert_one({"x": 1}) # Ensure command is retried on overload error. fail_many = get_mock_overload_error(MAX_ADAPTIVE_RETRIES) with self.fail_point(fail_many): - self.db.t.update_many({}, {"$set": {"x": 2}}) + self.db.coll.update_many({}, {"$set": {"x": 2}}) # Ensure command stops retrying after MAX_ADAPTIVE_RETRIES. fail_too_many = get_mock_overload_error(MAX_ADAPTIVE_RETRIES + 1) with self.fail_point(fail_too_many): with self.assertRaises(PyMongoError) as error: - self.db.t.update_many({}, {"$set": {"x": 2}}) + self.db.coll.update_many({}, {"$set": {"x": 2}}) self.assertIn("RetryableError", str(error.exception)) self.assertIn("SystemOverloadedError", str(error.exception)) @client_context.require_failCommand_appName def test_retry_overload_error_getMore(self): - coll = self.db.t + coll = self.db.coll coll.insert_many([{"x": 1} for _ in range(10)]) # Ensure command is retried on overload error. @@ -189,7 +189,7 @@ def test_01_operation_retry_uses_exponential_backoff(self, random_func): client = self.client # 2. let `collection` be a collection - collection = client.test.test + collection = client.db.coll # 3. Now, run transactions without backoff: @@ -234,7 +234,7 @@ def test_03_overload_retries_limited(self): # 1. Let `client` be a `MongoClient`. client = self.client # 2. Let `coll` be a collection. - coll = client.pymongo_test.coll + coll = client.db.coll # 3. Configure the following failpoint: failpoint = { @@ -267,7 +267,7 @@ def test_04_overload_retries_limited_configured(self): # 1. Let `client` be a `MongoClient` with `maxAdaptiveRetries=1` and command event monitoring enabled. client = self.single_client(maxAdaptiveRetries=max_retries, event_listeners=[self.listener]) # 2. Let `coll` be a collection. - coll = client.pymongo_test.coll + coll = client.db.coll # 3. Configure the following failpoint: failpoint = { diff --git a/test/test_collation.py b/test/test_collation.py index 0f5efa92dd..eefa9d7ee7 100644 --- a/test/test_collation.py +++ b/test/test_collation.py @@ -102,7 +102,7 @@ def setUp(self) -> None: super().setUp() self.listener = OvertCommandListener() self.client = self.rs_or_single_client(event_listeners=[self.listener]) - self.db = self.client.pymongo_test + self.db = self.client.db self.collation = Collation("en_US") self.warn_context = warnings.catch_warnings() self.warn_context.__enter__() @@ -120,14 +120,14 @@ def assertCollationInLastCommand(self): self.assertEqual(self.collation.document, self.last_command_started()["collation"]) def test_create_collection(self): - self.db.test.drop() - self.db.create_collection("test", collation=self.collation) + self.db.coll.drop() + self.db.create_collection("coll", collation=self.collation) self.assertCollationInLastCommand() # Test passing collation as a dict as well. - self.db.test.drop() + self.db.coll.drop() self.listener.reset() - self.db.create_collection("test", collation=self.collation.document) + self.db.create_collection("coll", collation=self.collation.document) self.assertCollationInLastCommand() def test_index_model(self): @@ -135,81 +135,81 @@ def test_index_model(self): self.assertEqual(self.collation.document, model.document["collation"]) def test_create_index(self): - self.db.test.create_index("foo", collation=self.collation) + self.db.coll.create_index("foo", collation=self.collation) ci_cmd = self.listener.started_events[0].command self.assertEqual(self.collation.document, ci_cmd["indexes"][0]["collation"]) def test_aggregate(self): - self.db.test.aggregate([{"$group": {"_id": 42}}], collation=self.collation) + self.db.coll.aggregate([{"$group": {"_id": 42}}], collation=self.collation) self.assertCollationInLastCommand() def test_count_documents(self): - self.db.test.count_documents({}, collation=self.collation) + self.db.coll.count_documents({}, collation=self.collation) self.assertCollationInLastCommand() def test_distinct(self): - self.db.test.distinct("foo", collation=self.collation) + self.db.coll.distinct("foo", collation=self.collation) self.assertCollationInLastCommand() self.listener.reset() - self.db.test.find(collation=self.collation).distinct("foo") + self.db.coll.find(collation=self.collation).distinct("foo") self.assertCollationInLastCommand() def test_find_command(self): - self.db.test.insert_one({"is this thing on?": True}) + self.db.coll.insert_one({"is this thing on?": True}) self.listener.reset() - next(self.db.test.find(collation=self.collation)) + next(self.db.coll.find(collation=self.collation)) self.assertCollationInLastCommand() def test_explain_command(self): self.listener.reset() - self.db.test.find(collation=self.collation).explain() + self.db.coll.find(collation=self.collation).explain() # The collation should be part of the explained command. self.assertEqual( self.collation.document, self.last_command_started()["explain"]["collation"] ) def test_delete(self): - self.db.test.delete_one({"foo": 42}, collation=self.collation) + self.db.coll.delete_one({"foo": 42}, collation=self.collation) command = self.listener.started_events[0].command self.assertEqual(self.collation.document, command["deletes"][0]["collation"]) self.listener.reset() - self.db.test.delete_many({"foo": 42}, collation=self.collation) + self.db.coll.delete_many({"foo": 42}, collation=self.collation) command = self.listener.started_events[0].command self.assertEqual(self.collation.document, command["deletes"][0]["collation"]) def test_update(self): - self.db.test.replace_one({"foo": 42}, {"foo": 43}, collation=self.collation) + self.db.coll.replace_one({"foo": 42}, {"foo": 43}, collation=self.collation) command = self.listener.started_events[0].command self.assertEqual(self.collation.document, command["updates"][0]["collation"]) self.listener.reset() - self.db.test.update_one({"foo": 42}, {"$set": {"foo": 43}}, collation=self.collation) + self.db.coll.update_one({"foo": 42}, {"$set": {"foo": 43}}, collation=self.collation) command = self.listener.started_events[0].command self.assertEqual(self.collation.document, command["updates"][0]["collation"]) self.listener.reset() - self.db.test.update_many({"foo": 42}, {"$set": {"foo": 43}}, collation=self.collation) + self.db.coll.update_many({"foo": 42}, {"$set": {"foo": 43}}, collation=self.collation) command = self.listener.started_events[0].command self.assertEqual(self.collation.document, command["updates"][0]["collation"]) def test_find_and(self): - self.db.test.find_one_and_delete({"foo": 42}, collation=self.collation) + self.db.coll.find_one_and_delete({"foo": 42}, collation=self.collation) self.assertCollationInLastCommand() self.listener.reset() - self.db.test.find_one_and_update( + self.db.coll.find_one_and_update( {"foo": 42}, {"$set": {"foo": 43}}, collation=self.collation ) self.assertCollationInLastCommand() self.listener.reset() - self.db.test.find_one_and_replace({"foo": 42}, {"foo": 43}, collation=self.collation) + self.db.coll.find_one_and_replace({"foo": 42}, {"foo": 43}, collation=self.collation) self.assertCollationInLastCommand() def test_bulk_write(self): - self.db.test.collection.bulk_write( + self.db.coll.collection.bulk_write( [ DeleteOne({"noCollation": 42}), DeleteMany({"noCollation": 42}), @@ -240,32 +240,32 @@ def check_ops(ops): check_ops(update_cmd["updates"]) def test_indexes_same_keys_different_collations(self): - self.db.test.drop() + self.db.coll.drop() usa_collation = Collation("en_US") ja_collation = Collation("ja") - self.db.test.create_indexes( + self.db.coll.create_indexes( [ IndexModel("fieldname", collation=usa_collation), IndexModel("fieldname", name="japanese_version", collation=ja_collation), IndexModel("fieldname", name="simple"), ] ) - indexes = self.db.test.index_information() + indexes = self.db.coll.index_information() self.assertEqual( usa_collation.document["locale"], indexes["fieldname_1"]["collation"]["locale"] ) self.assertEqual( ja_collation.document["locale"], indexes["japanese_version"]["collation"]["locale"] ) - self.db.test.drop_index("fieldname_1") - indexes = self.db.test.index_information() + self.db.coll.drop_index("fieldname_1") + indexes = self.db.coll.index_information() self.assertIn("japanese_version", indexes) self.assertIn("simple", indexes) self.assertNotIn("fieldname", indexes) def test_unacknowledged_write(self): unacknowledged = WriteConcern(w=0) - collection = self.db.get_collection("test", write_concern=unacknowledged) + collection = self.db.get_collection("coll", write_concern=unacknowledged) with self.assertRaises(ConfigurationError): collection.update_one( {"hello": "world"}, {"$set": {"hello": "moon"}}, collation=self.collation @@ -277,6 +277,6 @@ def test_unacknowledged_write(self): collection.bulk_write([update_one]) def test_cursor_collation(self): - self.db.test.insert_one({"hello": "world"}) - next(self.db.test.find().collation(self.collation)) + self.db.coll.insert_one({"hello": "world"}) + next(self.db.coll.find().collation(self.collation)) self.assertCollationInLastCommand() diff --git a/test/test_collection.py b/test/test_collection.py index a7912100b0..ed957db8ab 100644 --- a/test/test_collection.py +++ b/test/test_collection.py @@ -90,7 +90,7 @@ class TestCollectionNoConnect(UnitTest): def setUp(self) -> None: super().setUp() self.client = self.simple_client(connect=False) - self.db = self.client.pymongo_test + self.db = self.client.db def test_collection(self): self.assertRaises(TypeError, Collection, self.db, 5) @@ -103,15 +103,15 @@ def make_col(base, name): self.assertRaises(InvalidName, make_col, self.db, ".test") self.assertRaises(InvalidName, make_col, self.db, "test.") self.assertRaises(InvalidName, make_col, self.db, "tes..t") - self.assertRaises(InvalidName, make_col, self.db.test, "") - self.assertRaises(InvalidName, make_col, self.db.test, "te$t") - self.assertRaises(InvalidName, make_col, self.db.test, ".test") - self.assertRaises(InvalidName, make_col, self.db.test, "test.") - self.assertRaises(InvalidName, make_col, self.db.test, "tes..t") - self.assertRaises(InvalidName, make_col, self.db.test, "tes\x00t") + self.assertRaises(InvalidName, make_col, self.db.coll, "") + self.assertRaises(InvalidName, make_col, self.db.coll, "te$t") + self.assertRaises(InvalidName, make_col, self.db.coll, ".test") + self.assertRaises(InvalidName, make_col, self.db.coll, "test.") + self.assertRaises(InvalidName, make_col, self.db.coll, "tes..t") + self.assertRaises(InvalidName, make_col, self.db.coll, "tes\x00t") def test_getattr(self): - coll = self.db.test + coll = self.db.coll self.assertIsInstance(coll["_does_not_exist"], Collection) with self.assertRaises(AttributeError) as context: @@ -159,7 +159,7 @@ def setUp(self): self.w = client_context.w # type: ignore def tearDown(self): - self.db.test.drop() + self.db.coll.drop() self.db.drop_collection("test_large_limit") super().tearDown() @@ -170,25 +170,25 @@ def write_concern_collection(self): # Unsatisfiable write concern. yield Collection( self.db, - "test", + "coll", write_concern=WriteConcern(w=len(client_context.nodes) + 1), ) else: - yield self.db.test + yield self.db.coll def test_equality(self): - self.assertIsInstance(self.db.test, Collection) - self.assertEqual(self.db.test, self.db["test"]) - self.assertEqual(self.db.test, Collection(self.db, "test")) - self.assertEqual(self.db.test.mike, self.db["test.mike"]) - self.assertEqual(self.db.test["mike"], self.db["test.mike"]) + self.assertIsInstance(self.db.coll, Collection) + self.assertEqual(self.db.coll, self.db["coll"]) + self.assertEqual(self.db.coll, Collection(self.db, "coll")) + self.assertEqual(self.db.coll.mike, self.db["coll.mike"]) + self.assertEqual(self.db.coll["mike"], self.db["coll.mike"]) def test_hashable(self): - self.assertIn(self.db.test.mike, {self.db["test.mike"]}) + self.assertIn(self.db.coll.mike, {self.db["coll.mike"]}) def test_create(self): # No Exception. - db = client_context.client.pymongo_test + db = client_context.client.db db.create_test_no_wc.drop() def lambda_test(): @@ -212,59 +212,59 @@ def lambda_test_2(): db.create_collection("create-test-wc", write_concern=IMPOSSIBLE_WRITE_CONCERN) def test_drop_nonexistent_collection(self): - self.db.drop_collection("test") - self.assertNotIn("test", self.db.list_collection_names()) + self.db.drop_collection("coll") + self.assertNotIn("coll", self.db.list_collection_names()) # No exception - self.db.drop_collection("test") + self.db.drop_collection("coll") def test_create_indexes(self): db = self.db with self.assertRaises(TypeError): - db.test.create_indexes("foo") # type: ignore[arg-type] + db.coll.create_indexes("foo") # type: ignore[arg-type] with self.assertRaises(TypeError): - db.test.create_indexes(["foo"]) # type: ignore[list-item] + db.coll.create_indexes(["foo"]) # type: ignore[list-item] self.assertRaises(TypeError, IndexModel, 5) self.assertRaises(ValueError, IndexModel, []) - db.test.drop_indexes() - db.create_collection("test") - self.assertEqual(len(db.test.index_information()), 1) + db.coll.drop_indexes() + db.create_collection("coll") + self.assertEqual(len(db.coll.index_information()), 1) - db.test.create_indexes([IndexModel("hello")]) - db.test.create_indexes([IndexModel([("hello", DESCENDING), ("world", ASCENDING)])]) + db.coll.create_indexes([IndexModel("hello")]) + db.coll.create_indexes([IndexModel([("hello", DESCENDING), ("world", ASCENDING)])]) # Tuple instead of list. - db.test.create_indexes([IndexModel((("world", ASCENDING),))]) + db.coll.create_indexes([IndexModel((("world", ASCENDING),))]) - self.assertEqual(len(db.test.index_information()), 4) + self.assertEqual(len(db.coll.index_information()), 4) - db.test.drop_indexes() - names = db.test.create_indexes( + db.coll.drop_indexes() + names = db.coll.create_indexes( [IndexModel([("hello", DESCENDING), ("world", ASCENDING)], name="hello_world")] ) self.assertEqual(names, ["hello_world"]) - db.test.drop_indexes() - self.assertEqual(len(db.test.index_information()), 1) - db.test.create_indexes([IndexModel("hello")]) - self.assertIn("hello_1", db.test.index_information()) + db.coll.drop_indexes() + self.assertEqual(len(db.coll.index_information()), 1) + db.coll.create_indexes([IndexModel("hello")]) + self.assertIn("hello_1", db.coll.index_information()) - db.test.drop_indexes() - self.assertEqual(len(db.test.index_information()), 1) - names = db.test.create_indexes( + db.coll.drop_indexes() + self.assertEqual(len(db.coll.index_information()), 1) + names = db.coll.create_indexes( [IndexModel([("hello", DESCENDING), ("world", ASCENDING)]), IndexModel("hello")] ) - info = db.test.index_information() + info = db.coll.index_information() for name in names: self.assertIn(name, info) - db.test.drop() - db.test.insert_one({"a": 1}) - db.test.insert_one({"a": 1}) + db.coll.drop() + db.coll.insert_one({"a": 1}) + db.coll.insert_one({"a": 1}) with self.assertRaises(DuplicateKeyError): - db.test.create_indexes([IndexModel("a", unique=True)]) + db.coll.create_indexes([IndexModel("a", unique=True)]) with self.write_concern_collection() as coll: coll.create_indexes([IndexModel("hello")]) @@ -287,81 +287,81 @@ def test_create_index(self): db = self.db with self.assertRaises(TypeError): - db.test.create_index(5) # type: ignore[arg-type] + db.coll.create_index(5) # type: ignore[arg-type] with self.assertRaises(ValueError): - db.test.create_index([]) + db.coll.create_index([]) - db.test.drop_indexes() - db.create_collection("test") - self.assertEqual(len(db.test.index_information()), 1) + db.coll.drop_indexes() + db.create_collection("coll") + self.assertEqual(len(db.coll.index_information()), 1) - db.test.create_index("hello") - db.test.create_index([("hello", DESCENDING), ("world", ASCENDING)]) + db.coll.create_index("hello") + db.coll.create_index([("hello", DESCENDING), ("world", ASCENDING)]) # Tuple instead of list. - db.test.create_index((("world", ASCENDING),)) + db.coll.create_index((("world", ASCENDING),)) - self.assertEqual(len(db.test.index_information()), 4) + self.assertEqual(len(db.coll.index_information()), 4) - db.test.drop_indexes() - ix = db.test.create_index([("hello", DESCENDING), ("world", ASCENDING)], name="hello_world") + db.coll.drop_indexes() + ix = db.coll.create_index([("hello", DESCENDING), ("world", ASCENDING)], name="hello_world") self.assertEqual(ix, "hello_world") - db.test.drop_indexes() - self.assertEqual(len(db.test.index_information()), 1) - db.test.create_index("hello") - self.assertIn("hello_1", db.test.index_information()) + db.coll.drop_indexes() + self.assertEqual(len(db.coll.index_information()), 1) + db.coll.create_index("hello") + self.assertIn("hello_1", db.coll.index_information()) - db.test.drop_indexes() - self.assertEqual(len(db.test.index_information()), 1) - db.test.create_index([("hello", DESCENDING), ("world", ASCENDING)]) - self.assertIn("hello_-1_world_1", db.test.index_information()) + db.coll.drop_indexes() + self.assertEqual(len(db.coll.index_information()), 1) + db.coll.create_index([("hello", DESCENDING), ("world", ASCENDING)]) + self.assertIn("hello_-1_world_1", db.coll.index_information()) - db.test.drop_indexes() - db.test.create_index([("hello", DESCENDING), ("world", ASCENDING)], name=None) - self.assertIn("hello_-1_world_1", db.test.index_information()) + db.coll.drop_indexes() + db.coll.create_index([("hello", DESCENDING), ("world", ASCENDING)], name=None) + self.assertIn("hello_-1_world_1", db.coll.index_information()) - db.test.drop() - db.test.insert_one({"a": 1}) - db.test.insert_one({"a": 1}) + db.coll.drop() + db.coll.insert_one({"a": 1}) + db.coll.insert_one({"a": 1}) with self.assertRaises(DuplicateKeyError): - db.test.create_index("a", unique=True) + db.coll.create_index("a", unique=True) with self.write_concern_collection() as coll: coll.create_index([("hello", DESCENDING)]) - db.test.create_index(["hello", "world"]) - db.test.create_index(["hello", ("world", DESCENDING)]) - db.test.create_index({"hello": 1}.items()) # type:ignore[arg-type] + db.coll.create_index(["hello", "world"]) + db.coll.create_index(["hello", ("world", DESCENDING)]) + db.coll.create_index({"hello": 1}.items()) # type:ignore[arg-type] def test_drop_index(self): db = self.db - db.test.drop_indexes() - db.test.create_index("hello") - name = db.test.create_index("goodbye") + db.coll.drop_indexes() + db.coll.create_index("hello") + name = db.coll.create_index("goodbye") - self.assertEqual(len(db.test.index_information()), 3) + self.assertEqual(len(db.coll.index_information()), 3) self.assertEqual(name, "goodbye_1") - db.test.drop_index(name) + db.coll.drop_index(name) # Drop it again. if client_context.version < Version(8, 3, -1): with self.assertRaises(OperationFailure): - db.test.drop_index(name) + db.coll.drop_index(name) else: - db.test.drop_index(name) - self.assertEqual(len(db.test.index_information()), 2) - self.assertIn("hello_1", db.test.index_information()) + db.coll.drop_index(name) + self.assertEqual(len(db.coll.index_information()), 2) + self.assertIn("hello_1", db.coll.index_information()) - db.test.drop_indexes() - db.test.create_index("hello") - name = db.test.create_index("goodbye") + db.coll.drop_indexes() + db.coll.create_index("hello") + name = db.coll.create_index("goodbye") - self.assertEqual(len(db.test.index_information()), 3) + self.assertEqual(len(db.coll.index_information()), 3) self.assertEqual(name, "goodbye_1") - db.test.drop_index([("goodbye", ASCENDING)]) - self.assertEqual(len(db.test.index_information()), 2) - self.assertIn("hello_1", db.test.index_information()) + db.coll.drop_index([("goodbye", ASCENDING)]) + self.assertEqual(len(db.coll.index_information()), 2) + self.assertIn("hello_1", db.coll.index_information()) with self.write_concern_collection() as coll: coll.drop_index("hello_1") @@ -369,7 +369,7 @@ def test_drop_index(self): @client_context.require_no_mongos @client_context.require_test_commands def test_index_management_max_time_ms(self): - coll = self.db.test + coll = self.db.coll self.client.admin.command("configureFailPoint", "maxTimeAlwaysTimeOut", mode="alwaysOn") try: with self.assertRaises(ExecutionTimeout): @@ -385,23 +385,23 @@ def test_index_management_max_time_ms(self): def test_list_indexes(self): db = self.db - db.test.drop() - db.create_collection("test") + db.coll.drop() + db.create_collection("coll") def map_indexes(indexes): return {index["name"]: index for index in indexes} - indexes = (db.test.list_indexes()).to_list() + indexes = (db.coll.list_indexes()).to_list() self.assertEqual(len(indexes), 1) self.assertIn("_id_", map_indexes(indexes)) - db.test.create_index("hello") - indexes = (db.test.list_indexes()).to_list() + db.coll.create_index("hello") + indexes = (db.coll.list_indexes()).to_list() self.assertEqual(len(indexes), 2) self.assertEqual(map_indexes(indexes)["hello_1"]["key"], SON([("hello", ASCENDING)])) - db.test.create_index([("hello", DESCENDING), ("world", ASCENDING)], unique=True) - indexes = (db.test.list_indexes()).to_list() + db.coll.create_index([("hello", DESCENDING), ("world", ASCENDING)], unique=True) + indexes = (db.coll.list_indexes()).to_list() self.assertEqual(len(indexes), 3) index_map = map_indexes(indexes) self.assertEqual( @@ -419,29 +419,29 @@ def map_indexes(indexes): def test_index_info(self): db = self.db - db.test.drop() - db.create_collection("test") - self.assertEqual(len(db.test.index_information()), 1) - self.assertIn("_id_", db.test.index_information()) - - db.test.create_index("hello") - self.assertEqual(len(db.test.index_information()), 2) - self.assertEqual((db.test.index_information())["hello_1"]["key"], [("hello", ASCENDING)]) - - db.test.create_index([("hello", DESCENDING), ("world", ASCENDING)], unique=True) - self.assertEqual((db.test.index_information())["hello_1"]["key"], [("hello", ASCENDING)]) - self.assertEqual(len(db.test.index_information()), 3) + db.coll.drop() + db.create_collection("coll") + self.assertEqual(len(db.coll.index_information()), 1) + self.assertIn("_id_", db.coll.index_information()) + + db.coll.create_index("hello") + self.assertEqual(len(db.coll.index_information()), 2) + self.assertEqual((db.coll.index_information())["hello_1"]["key"], [("hello", ASCENDING)]) + + db.coll.create_index([("hello", DESCENDING), ("world", ASCENDING)], unique=True) + self.assertEqual((db.coll.index_information())["hello_1"]["key"], [("hello", ASCENDING)]) + self.assertEqual(len(db.coll.index_information()), 3) self.assertEqual( [("hello", DESCENDING), ("world", ASCENDING)], - (db.test.index_information())["hello_-1_world_1"]["key"], + (db.coll.index_information())["hello_-1_world_1"]["key"], ) - self.assertEqual(True, (db.test.index_information())["hello_-1_world_1"]["unique"]) + self.assertEqual(True, (db.coll.index_information())["hello_-1_world_1"]["unique"]) def test_index_geo2d(self): db = self.db - db.test.drop_indexes() - self.assertEqual("loc_2d", db.test.create_index([("loc", GEO2D)])) - index_info = (db.test.index_information())["loc_2d"] + db.coll.drop_indexes() + self.assertEqual("loc_2d", db.coll.create_index([("loc", GEO2D)])) + index_info = (db.coll.index_information())["loc_2d"] self.assertEqual([("loc", "2d")], index_info["key"]) # geoSearch was deprecated in 4.4 and removed in 5.0 @@ -449,13 +449,13 @@ def test_index_geo2d(self): @client_context.require_no_mongos def test_index_haystack(self): db = self.db - db.test.drop() + db.coll.drop() _id = ( - db.test.insert_one({"pos": {"long": 34.2, "lat": 33.3}, "type": "restaurant"}) + db.coll.insert_one({"pos": {"long": 34.2, "lat": 33.3}, "type": "restaurant"}) ).inserted_id - db.test.insert_one({"pos": {"long": 34.2, "lat": 37.3}, "type": "restaurant"}) - db.test.insert_one({"pos": {"long": 59.1, "lat": 87.2}, "type": "office"}) - db.test.create_index([("pos", "geoHaystack"), ("type", ASCENDING)], bucketSize=1) + db.coll.insert_one({"pos": {"long": 34.2, "lat": 37.3}, "type": "restaurant"}) + db.coll.insert_one({"pos": {"long": 59.1, "lat": 87.2}, "type": "office"}) + db.coll.create_index([("pos", "geoHaystack"), ("type", ASCENDING)], bucketSize=1) results = ( db.command( @@ -479,31 +479,31 @@ def test_index_haystack(self): @client_context.require_no_mongos def test_index_text(self): db = self.db - db.test.drop_indexes() - self.assertEqual("t_text", db.test.create_index([("t", TEXT)])) - index_info = (db.test.index_information())["t_text"] + db.coll.drop_indexes() + self.assertEqual("t_text", db.coll.create_index([("t", TEXT)])) + index_info = (db.coll.index_information())["t_text"] self.assertIn("weights", index_info) - db.test.insert_many( + db.coll.insert_many( [{"t": "spam eggs and spam"}, {"t": "spam"}, {"t": "egg sausage and bacon"}] ) # MongoDB 2.6 text search. Create 'score' field in projection. - cursor = db.test.find({"$text": {"$search": "spam"}}, {"score": {"$meta": "textScore"}}) + cursor = db.coll.find({"$text": {"$search": "spam"}}, {"score": {"$meta": "textScore"}}) # Sort by 'score' field. cursor.sort([("score", {"$meta": "textScore"})]) results = cursor.to_list() self.assertGreaterEqual(results[0]["score"], results[1]["score"]) - db.test.drop_indexes() + db.coll.drop_indexes() def test_index_2dsphere(self): db = self.db - db.test.drop_indexes() - self.assertEqual("geo_2dsphere", db.test.create_index([("geo", GEOSPHERE)])) + db.coll.drop_indexes() + self.assertEqual("geo_2dsphere", db.coll.create_index([("geo", GEOSPHERE)])) - for dummy, info in (db.test.index_information()).items(): + for dummy, info in (db.coll.index_information()).items(): field, idx_type = info["key"][0] if field == "geo" and idx_type == "2dsphere": break @@ -514,45 +514,45 @@ def test_index_2dsphere(self): query = {"geo": {"$within": {"$geometry": poly}}} # This query will error without a 2dsphere index. - db.test.find(query) - db.test.drop_indexes() + db.coll.find(query) + db.coll.drop_indexes() def test_index_hashed(self): db = self.db - db.test.drop_indexes() - self.assertEqual("a_hashed", db.test.create_index([("a", HASHED)])) + db.coll.drop_indexes() + self.assertEqual("a_hashed", db.coll.create_index([("a", HASHED)])) - for dummy, info in (db.test.index_information()).items(): + for dummy, info in (db.coll.index_information()).items(): field, idx_type = info["key"][0] if field == "a" and idx_type == "hashed": break else: self.fail("hashed index not found.") - db.test.drop_indexes() + db.coll.drop_indexes() def test_index_sparse(self): db = self.db - db.test.drop_indexes() - db.test.create_index([("key", ASCENDING)], sparse=True) - self.assertTrue((db.test.index_information())["key_1"]["sparse"]) + db.coll.drop_indexes() + db.coll.create_index([("key", ASCENDING)], sparse=True) + self.assertTrue((db.coll.index_information())["key_1"]["sparse"]) def test_index_background(self): db = self.db - db.test.drop_indexes() - db.test.create_index([("keya", ASCENDING)]) - db.test.create_index([("keyb", ASCENDING)], background=False) - db.test.create_index([("keyc", ASCENDING)], background=True) - self.assertNotIn("background", (db.test.index_information())["keya_1"]) - self.assertFalse((db.test.index_information())["keyb_1"]["background"]) - self.assertTrue((db.test.index_information())["keyc_1"]["background"]) + db.coll.drop_indexes() + db.coll.create_index([("keya", ASCENDING)]) + db.coll.create_index([("keyb", ASCENDING)], background=False) + db.coll.create_index([("keyc", ASCENDING)], background=True) + self.assertNotIn("background", (db.coll.index_information())["keya_1"]) + self.assertFalse((db.coll.index_information())["keyb_1"]["background"]) + self.assertTrue((db.coll.index_information())["keyc_1"]["background"]) def _drop_dups_setup(self, db): - db.drop_collection("test") - db.test.insert_one({"i": 1}) - db.test.insert_one({"i": 2}) - db.test.insert_one({"i": 2}) # duplicate - db.test.insert_one({"i": 3}) + db.drop_collection("coll") + db.coll.insert_one({"i": 1}) + db.coll.insert_one({"i": 2}) + db.coll.insert_one({"i": 2}) # duplicate + db.coll.insert_one({"i": 3}) def test_index_dont_drop_dups(self): # Try *not* dropping duplicates @@ -561,16 +561,16 @@ def test_index_dont_drop_dups(self): # There's a duplicate def _test_create(): - db.test.create_index([("i", ASCENDING)], unique=True, dropDups=False) + db.coll.create_index([("i", ASCENDING)], unique=True, dropDups=False) with self.assertRaises(DuplicateKeyError): _test_create() # Duplicate wasn't dropped - self.assertEqual(4, db.test.count_documents({})) + self.assertEqual(4, db.coll.count_documents({})) # Index wasn't created, only the default index on _id - self.assertEqual(1, len(db.test.index_information())) + self.assertEqual(1, len(db.coll.index_information())) # Get the plan dynamically because the explain format will change. def get_plan_stage(self, root, stage): @@ -595,139 +595,139 @@ def get_plan_stage(self, root, stage): def test_index_filter(self): db = self.db - db.drop_collection("test") + db.drop_collection("coll") # Test bad filter spec on create. with self.assertRaises(OperationFailure): - db.test.create_index("x", partialFilterExpression=5) + db.coll.create_index("x", partialFilterExpression=5) with self.assertRaises(OperationFailure): - db.test.create_index("x", partialFilterExpression={"x": {"$asdasd": 3}}) + db.coll.create_index("x", partialFilterExpression={"x": {"$asdasd": 3}}) with self.assertRaises(OperationFailure): - db.test.create_index("x", partialFilterExpression={"$and": 5}) + db.coll.create_index("x", partialFilterExpression={"$and": 5}) self.assertEqual( "x_1", - db.test.create_index([("x", ASCENDING)], partialFilterExpression={"a": {"$lte": 1.5}}), + db.coll.create_index([("x", ASCENDING)], partialFilterExpression={"a": {"$lte": 1.5}}), ) - db.test.insert_one({"x": 5, "a": 2}) - db.test.insert_one({"x": 6, "a": 1}) + db.coll.insert_one({"x": 5, "a": 2}) + db.coll.insert_one({"x": 6, "a": 1}) # Operations that use the partial index. - explain = db.test.find({"x": 6, "a": 1}).explain() + explain = db.coll.find({"x": 6, "a": 1}).explain() stage = self.get_plan_stage(explain["queryPlanner"]["winningPlan"], "IXSCAN") self.assertEqual("x_1", stage.get("indexName")) self.assertTrue(stage.get("isPartial")) - explain = db.test.find({"x": {"$gt": 1}, "a": 1}).explain() + explain = db.coll.find({"x": {"$gt": 1}, "a": 1}).explain() stage = self.get_plan_stage(explain["queryPlanner"]["winningPlan"], "IXSCAN") self.assertEqual("x_1", stage.get("indexName")) self.assertTrue(stage.get("isPartial")) - explain = db.test.find({"x": 6, "a": {"$lte": 1}}).explain() + explain = db.coll.find({"x": 6, "a": {"$lte": 1}}).explain() stage = self.get_plan_stage(explain["queryPlanner"]["winningPlan"], "IXSCAN") self.assertEqual("x_1", stage.get("indexName")) self.assertTrue(stage.get("isPartial")) # Operations that do not use the partial index. - explain = db.test.find({"x": 6, "a": {"$lte": 1.6}}).explain() + explain = db.coll.find({"x": 6, "a": {"$lte": 1.6}}).explain() stage = self.get_plan_stage(explain["queryPlanner"]["winningPlan"], "COLLSCAN") self.assertNotEqual({}, stage) - explain = db.test.find({"x": 6}).explain() + explain = db.coll.find({"x": 6}).explain() stage = self.get_plan_stage(explain["queryPlanner"]["winningPlan"], "COLLSCAN") self.assertNotEqual({}, stage) # Test drop_indexes. - db.test.drop_index("x_1") - explain = db.test.find({"x": 6, "a": 1}).explain() + db.coll.drop_index("x_1") + explain = db.coll.find({"x": 6, "a": 1}).explain() stage = self.get_plan_stage(explain["queryPlanner"]["winningPlan"], "COLLSCAN") self.assertNotEqual({}, stage) def test_field_selection(self): db = self.db - db.drop_collection("test") + db.drop_collection("coll") doc = {"a": 1, "b": 5, "c": {"d": 5, "e": 10}} - db.test.insert_one(doc) + db.coll.insert_one(doc) # Test field inclusion - doc = next(db.test.find({}, ["_id"])) + doc = next(db.coll.find({}, ["_id"])) self.assertEqual(list(doc), ["_id"]) - doc = next(db.test.find({}, ["a"])) + doc = next(db.coll.find({}, ["a"])) l = list(doc) l.sort() self.assertEqual(l, ["_id", "a"]) - doc = next(db.test.find({}, ["b"])) + doc = next(db.coll.find({}, ["b"])) l = list(doc) l.sort() self.assertEqual(l, ["_id", "b"]) - doc = next(db.test.find({}, ["c"])) + doc = next(db.coll.find({}, ["c"])) l = list(doc) l.sort() self.assertEqual(l, ["_id", "c"]) - doc = next(db.test.find({}, ["a"])) + doc = next(db.coll.find({}, ["a"])) self.assertEqual(doc["a"], 1) - doc = next(db.test.find({}, ["b"])) + doc = next(db.coll.find({}, ["b"])) self.assertEqual(doc["b"], 5) - doc = next(db.test.find({}, ["c"])) + doc = next(db.coll.find({}, ["c"])) self.assertEqual(doc["c"], {"d": 5, "e": 10}) # Test inclusion of fields with dots - doc = next(db.test.find({}, ["c.d"])) + doc = next(db.coll.find({}, ["c.d"])) self.assertEqual(doc["c"], {"d": 5}) - doc = next(db.test.find({}, ["c.e"])) + doc = next(db.coll.find({}, ["c.e"])) self.assertEqual(doc["c"], {"e": 10}) - doc = next(db.test.find({}, ["b", "c.e"])) + doc = next(db.coll.find({}, ["b", "c.e"])) self.assertEqual(doc["c"], {"e": 10}) - doc = next(db.test.find({}, ["b", "c.e"])) + doc = next(db.coll.find({}, ["b", "c.e"])) l = list(doc) l.sort() self.assertEqual(l, ["_id", "b", "c"]) - doc = next(db.test.find({}, ["b", "c.e"])) + doc = next(db.coll.find({}, ["b", "c.e"])) self.assertEqual(doc["b"], 5) # Test field exclusion - doc = next(db.test.find({}, {"a": False, "b": 0})) + doc = next(db.coll.find({}, {"a": False, "b": 0})) l = list(doc) l.sort() self.assertEqual(l, ["_id", "c"]) - doc = next(db.test.find({}, {"_id": False})) + doc = next(db.coll.find({}, {"_id": False})) l = list(doc) self.assertNotIn("_id", l) def test_options(self): db = self.db - db.drop_collection("test") - db.create_collection("test", capped=True, size=4096) - result = db.test.options() + db.drop_collection("coll") + db.create_collection("coll", capped=True, size=4096) + result = db.coll.options() self.assertEqual(result, {"capped": True, "size": 4096}) - db.drop_collection("test") + db.drop_collection("coll") def test_insert_one(self): db = self.db - db.test.drop() + db.coll.drop() document: dict[str, Any] = {"_id": 1000} - result = db.test.insert_one(document) + result = db.coll.insert_one(document) self.assertIsInstance(result, InsertOneResult) self.assertIsInstance(result.inserted_id, int) self.assertEqual(document["_id"], result.inserted_id) self.assertTrue(result.acknowledged) - self.assertIsNotNone(db.test.find_one({"_id": document["_id"]})) - self.assertEqual(1, db.test.count_documents({})) + self.assertIsNotNone(db.coll.find_one({"_id": document["_id"]})) + self.assertEqual(1, db.coll.count_documents({})) document = {"foo": "bar"} - result = db.test.insert_one(document) + result = db.coll.insert_one(document) self.assertIsInstance(result, InsertOneResult) self.assertIsInstance(result.inserted_id, ObjectId) self.assertEqual(document["_id"], result.inserted_id) self.assertTrue(result.acknowledged) - self.assertIsNotNone(db.test.find_one({"_id": document["_id"]})) - self.assertEqual(2, db.test.count_documents({})) + self.assertIsNotNone(db.coll.find_one({"_id": document["_id"]})) + self.assertEqual(2, db.coll.count_documents({})) db = db.client.get_database(db.name, write_concern=WriteConcern(w=0)) - result = db.test.insert_one(document) + result = db.coll.insert_one(document) self.assertIsInstance(result, InsertOneResult) self.assertIsInstance(result.inserted_id, ObjectId) self.assertEqual(document["_id"], result.inserted_id) @@ -735,21 +735,21 @@ def test_insert_one(self): # The insert failed duplicate key... def async_lambda(): - return db.test.count_documents({}) == 2 + return db.coll.count_documents({}) == 2 wait_until(async_lambda, "forcing duplicate key error") document = RawBSONDocument(encode({"_id": ObjectId(), "foo": "bar"})) - result = db.test.insert_one(document) + result = db.coll.insert_one(document) self.assertIsInstance(result, InsertOneResult) self.assertEqual(result.inserted_id, None) def test_insert_many(self): db = self.db - db.test.drop() + db.coll.drop() docs: list = [{} for _ in range(5)] - result = db.test.insert_many(docs) + result = db.coll.insert_many(docs) self.assertIsInstance(result, InsertManyResult) self.assertIsInstance(result.inserted_ids, list) self.assertEqual(5, len(result.inserted_ids)) @@ -757,11 +757,11 @@ def test_insert_many(self): _id = doc["_id"] self.assertIsInstance(_id, ObjectId) self.assertIn(_id, result.inserted_ids) - self.assertEqual(1, db.test.count_documents({"_id": _id})) + self.assertEqual(1, db.coll.count_documents({"_id": _id})) self.assertTrue(result.acknowledged) docs = [{"_id": i} for i in range(5)] - result = db.test.insert_many(docs) + result = db.coll.insert_many(docs) self.assertIsInstance(result, InsertManyResult) self.assertIsInstance(result.inserted_ids, list) self.assertEqual(5, len(result.inserted_ids)) @@ -769,24 +769,24 @@ def test_insert_many(self): _id = doc["_id"] self.assertIsInstance(_id, int) self.assertIn(_id, result.inserted_ids) - self.assertEqual(1, db.test.count_documents({"_id": _id})) + self.assertEqual(1, db.coll.count_documents({"_id": _id})) self.assertTrue(result.acknowledged) docs = [RawBSONDocument(encode({"_id": i + 5})) for i in range(5)] - result = db.test.insert_many(docs) + result = db.coll.insert_many(docs) self.assertIsInstance(result, InsertManyResult) self.assertIsInstance(result.inserted_ids, list) self.assertEqual([], result.inserted_ids) db = db.client.get_database(db.name, write_concern=WriteConcern(w=0)) docs: list = [{} for _ in range(5)] - result = db.test.insert_many(docs) + result = db.coll.insert_many(docs) self.assertIsInstance(result, InsertManyResult) self.assertFalse(result.acknowledged) - self.assertEqual(20, db.test.count_documents({})) + self.assertEqual(20, db.coll.count_documents({})) def test_insert_many_generator(self): - coll = self.db.test + coll = self.db.coll coll.delete_many({}) def gen(): @@ -803,75 +803,75 @@ def test_insert_many_invalid(self): db = self.db with self.assertRaisesRegex(TypeError, "documents must be a non-empty list"): - db.test.insert_many({}) + db.coll.insert_many({}) with self.assertRaisesRegex(TypeError, "documents must be a non-empty list"): - db.test.insert_many([]) + db.coll.insert_many([]) with self.assertRaisesRegex(TypeError, "documents must be a non-empty list"): - db.test.insert_many(1) # type: ignore[arg-type] + db.coll.insert_many(1) # type: ignore[arg-type] with self.assertRaisesRegex(TypeError, "documents must be a non-empty list"): - db.test.insert_many(RawBSONDocument(encode({"_id": 2}))) + db.coll.insert_many(RawBSONDocument(encode({"_id": 2}))) def test_delete_one(self): - self.db.test.drop() + self.db.coll.drop() - self.db.test.insert_one({"x": 1}) - self.db.test.insert_one({"y": 1}) - self.db.test.insert_one({"z": 1}) + self.db.coll.insert_one({"x": 1}) + self.db.coll.insert_one({"y": 1}) + self.db.coll.insert_one({"z": 1}) - result = self.db.test.delete_one({"x": 1}) + result = self.db.coll.delete_one({"x": 1}) self.assertIsInstance(result, DeleteResult) self.assertEqual(1, result.deleted_count) self.assertTrue(result.acknowledged) - self.assertEqual(2, self.db.test.count_documents({})) + self.assertEqual(2, self.db.coll.count_documents({})) - result = self.db.test.delete_one({"y": 1}) + result = self.db.coll.delete_one({"y": 1}) self.assertIsInstance(result, DeleteResult) self.assertEqual(1, result.deleted_count) self.assertTrue(result.acknowledged) - self.assertEqual(1, self.db.test.count_documents({})) + self.assertEqual(1, self.db.coll.count_documents({})) db = self.db.client.get_database(self.db.name, write_concern=WriteConcern(w=0)) - result = db.test.delete_one({"z": 1}) + result = db.coll.delete_one({"z": 1}) self.assertIsInstance(result, DeleteResult) self.assertRaises(InvalidOperation, lambda: result.deleted_count) self.assertFalse(result.acknowledged) def lambda_async(): - return db.test.count_documents({}) == 0 + return db.coll.count_documents({}) == 0 wait_until(lambda_async, "delete 1 documents") def test_delete_many(self): - self.db.test.drop() + self.db.coll.drop() - self.db.test.insert_one({"x": 1}) - self.db.test.insert_one({"x": 1}) - self.db.test.insert_one({"y": 1}) - self.db.test.insert_one({"y": 1}) + self.db.coll.insert_one({"x": 1}) + self.db.coll.insert_one({"x": 1}) + self.db.coll.insert_one({"y": 1}) + self.db.coll.insert_one({"y": 1}) - result = self.db.test.delete_many({"x": 1}) + result = self.db.coll.delete_many({"x": 1}) self.assertIsInstance(result, DeleteResult) self.assertEqual(2, result.deleted_count) self.assertTrue(result.acknowledged) - self.assertEqual(0, self.db.test.count_documents({"x": 1})) + self.assertEqual(0, self.db.coll.count_documents({"x": 1})) db = self.db.client.get_database(self.db.name, write_concern=WriteConcern(w=0)) - result = db.test.delete_many({"y": 1}) + result = db.coll.delete_many({"y": 1}) self.assertIsInstance(result, DeleteResult) self.assertRaises(InvalidOperation, lambda: result.deleted_count) self.assertFalse(result.acknowledged) def lambda_async(): - return db.test.count_documents({}) == 0 + return db.coll.count_documents({}) == 0 wait_until(lambda_async, "delete 2 documents") def test_command_document_too_large(self): large = "*" * (client_context.max_bson_size + _COMMAND_OVERHEAD) - coll = self.db.test + coll = self.db.coll with self.assertRaises(DocumentTooLarge): coll.insert_one({"data": large}) # update_one and update_many are the same @@ -888,33 +888,33 @@ def test_write_large_document(self): self.assertEqual(max_size, 16777216) with self.assertRaises(OperationFailure): - self.db.test.insert_one({"foo": max_str}) + self.db.coll.insert_one({"foo": max_str}) with self.assertRaises(OperationFailure): - self.db.test.replace_one({}, {"foo": max_str}, upsert=True) + self.db.coll.replace_one({}, {"foo": max_str}, upsert=True) with self.assertRaises(OperationFailure): - self.db.test.insert_many([{"x": 1}, {"foo": max_str}]) - self.db.test.insert_many([{"foo": half_str}, {"foo": half_str}]) + self.db.coll.insert_many([{"x": 1}, {"foo": max_str}]) + self.db.coll.insert_many([{"foo": half_str}, {"foo": half_str}]) - self.db.test.insert_one({"bar": "x"}) + self.db.coll.insert_one({"bar": "x"}) # Use w=0 here to test legacy doc size checking in all server versions - unack_coll = self.db.test.with_options(write_concern=WriteConcern(w=0)) + unack_coll = self.db.coll.with_options(write_concern=WriteConcern(w=0)) with self.assertRaises(DocumentTooLarge): unack_coll.replace_one({"bar": "x"}, {"bar": "x" * (max_size - 14)}) - self.db.test.replace_one({"bar": "x"}, {"bar": "x" * (max_size - 32)}) + self.db.coll.replace_one({"bar": "x"}, {"bar": "x" * (max_size - 32)}) def test_insert_bypass_document_validation(self): db = self.db - db.test.drop() - db.create_collection("test", validator={"a": {"$exists": True}}) + db.coll.drop() + db.create_collection("coll", validator={"a": {"$exists": True}}) db_w0 = self.db.client.get_database(self.db.name, write_concern=WriteConcern(w=0)) # Test insert_one with self.assertRaises(OperationFailure): - db.test.insert_one({"_id": 1, "x": 100}) - result = db.test.insert_one({"_id": 1, "x": 100}, bypass_document_validation=True) + db.coll.insert_one({"_id": 1, "x": 100}) + result = db.coll.insert_one({"_id": 1, "x": 100}, bypass_document_validation=True) self.assertIsInstance(result, InsertOneResult) self.assertEqual(1, result.inserted_id) - result = db.test.insert_one({"_id": 2, "a": 0}) + result = db.coll.insert_one({"_id": 2, "a": 0}) self.assertIsInstance(result, InsertOneResult) self.assertEqual(2, result.inserted_id) @@ -928,25 +928,25 @@ def async_lambda(): # Test insert_many docs = [{"_id": i, "x": 100 - i} for i in range(3, 100)] with self.assertRaises(OperationFailure): - db.test.insert_many(docs) - result = db.test.insert_many(docs, bypass_document_validation=True) + db.coll.insert_many(docs) + result = db.coll.insert_many(docs, bypass_document_validation=True) self.assertIsInstance(result, InsertManyResult) self.assertTrue(97, len(result.inserted_ids)) for doc in docs: _id = doc["_id"] self.assertIsInstance(_id, int) self.assertIn(_id, result.inserted_ids) - self.assertEqual(1, db.test.count_documents({"x": doc["x"]})) + self.assertEqual(1, db.coll.count_documents({"x": doc["x"]})) self.assertTrue(result.acknowledged) docs = [{"_id": i, "a": 200 - i} for i in range(100, 200)] - result = db.test.insert_many(docs) + result = db.coll.insert_many(docs) self.assertIsInstance(result, InsertManyResult) self.assertTrue(97, len(result.inserted_ids)) for doc in docs: _id = doc["_id"] self.assertIsInstance(_id, int) self.assertIn(_id, result.inserted_ids) - self.assertEqual(1, db.test.count_documents({"a": doc["a"]})) + self.assertEqual(1, db.coll.count_documents({"a": doc["a"]})) self.assertTrue(result.acknowledged) with self.assertRaises(OperationFailure): @@ -957,37 +957,37 @@ def async_lambda(): def test_replace_bypass_document_validation(self): db = self.db - db.test.drop() - db.create_collection("test", validator={"a": {"$exists": True}}) + db.coll.drop() + db.create_collection("coll", validator={"a": {"$exists": True}}) db_w0 = self.db.client.get_database(self.db.name, write_concern=WriteConcern(w=0)) # Test replace_one - db.test.insert_one({"a": 101}) + db.coll.insert_one({"a": 101}) with self.assertRaises(OperationFailure): - db.test.replace_one({"a": 101}, {"y": 1}) - self.assertEqual(0, db.test.count_documents({"y": 1})) - self.assertEqual(1, db.test.count_documents({"a": 101})) - db.test.replace_one({"a": 101}, {"y": 1}, bypass_document_validation=True) - self.assertEqual(0, db.test.count_documents({"a": 101})) - self.assertEqual(1, db.test.count_documents({"y": 1})) - db.test.replace_one({"y": 1}, {"a": 102}) - self.assertEqual(0, db.test.count_documents({"y": 1})) - self.assertEqual(0, db.test.count_documents({"a": 101})) - self.assertEqual(1, db.test.count_documents({"a": 102})) - - db.test.insert_one({"y": 1}, bypass_document_validation=True) + db.coll.replace_one({"a": 101}, {"y": 1}) + self.assertEqual(0, db.coll.count_documents({"y": 1})) + self.assertEqual(1, db.coll.count_documents({"a": 101})) + db.coll.replace_one({"a": 101}, {"y": 1}, bypass_document_validation=True) + self.assertEqual(0, db.coll.count_documents({"a": 101})) + self.assertEqual(1, db.coll.count_documents({"y": 1})) + db.coll.replace_one({"y": 1}, {"a": 102}) + self.assertEqual(0, db.coll.count_documents({"y": 1})) + self.assertEqual(0, db.coll.count_documents({"a": 101})) + self.assertEqual(1, db.coll.count_documents({"a": 102})) + + db.coll.insert_one({"y": 1}, bypass_document_validation=True) with self.assertRaises(OperationFailure): - db.test.replace_one({"y": 1}, {"x": 101}) - self.assertEqual(0, db.test.count_documents({"x": 101})) - self.assertEqual(1, db.test.count_documents({"y": 1})) - db.test.replace_one({"y": 1}, {"x": 101}, bypass_document_validation=True) - self.assertEqual(0, db.test.count_documents({"y": 1})) - self.assertEqual(1, db.test.count_documents({"x": 101})) - db.test.replace_one({"x": 101}, {"a": 103}, bypass_document_validation=False) - self.assertEqual(0, db.test.count_documents({"x": 101})) - self.assertEqual(1, db.test.count_documents({"a": 103})) - - db.test.insert_one({"y": 1}, bypass_document_validation=True) + db.coll.replace_one({"y": 1}, {"x": 101}) + self.assertEqual(0, db.coll.count_documents({"x": 101})) + self.assertEqual(1, db.coll.count_documents({"y": 1})) + db.coll.replace_one({"y": 1}, {"x": 101}, bypass_document_validation=True) + self.assertEqual(0, db.coll.count_documents({"y": 1})) + self.assertEqual(1, db.coll.count_documents({"x": 101})) + db.coll.replace_one({"x": 101}, {"a": 103}, bypass_document_validation=False) + self.assertEqual(0, db.coll.count_documents({"x": 101})) + self.assertEqual(1, db.coll.count_documents({"a": 103})) + + db.coll.insert_one({"y": 1}, bypass_document_validation=True) db_w0.test.replace_one({"y": 1}, {"x": 1}, bypass_document_validation=True) def predicate(): @@ -997,36 +997,36 @@ def predicate(): def test_update_bypass_document_validation(self): db = self.db - db.test.drop() - db.test.insert_one({"z": 5}) + db.coll.drop() + db.coll.insert_one({"z": 5}) db.command(SON([("collMod", "test"), ("validator", {"z": {"$gte": 0}})])) db_w0 = self.db.client.get_database(self.db.name, write_concern=WriteConcern(w=0)) # Test update_one with self.assertRaises(OperationFailure): - db.test.update_one({"z": 5}, {"$inc": {"z": -10}}) - self.assertEqual(0, db.test.count_documents({"z": -5})) - self.assertEqual(1, db.test.count_documents({"z": 5})) - db.test.update_one({"z": 5}, {"$inc": {"z": -10}}, bypass_document_validation=True) - self.assertEqual(0, db.test.count_documents({"z": 5})) - self.assertEqual(1, db.test.count_documents({"z": -5})) - db.test.update_one({"z": -5}, {"$inc": {"z": 6}}, bypass_document_validation=False) - self.assertEqual(1, db.test.count_documents({"z": 1})) - self.assertEqual(0, db.test.count_documents({"z": -5})) - - db.test.insert_one({"z": -10}, bypass_document_validation=True) + db.coll.update_one({"z": 5}, {"$inc": {"z": -10}}) + self.assertEqual(0, db.coll.count_documents({"z": -5})) + self.assertEqual(1, db.coll.count_documents({"z": 5})) + db.coll.update_one({"z": 5}, {"$inc": {"z": -10}}, bypass_document_validation=True) + self.assertEqual(0, db.coll.count_documents({"z": 5})) + self.assertEqual(1, db.coll.count_documents({"z": -5})) + db.coll.update_one({"z": -5}, {"$inc": {"z": 6}}, bypass_document_validation=False) + self.assertEqual(1, db.coll.count_documents({"z": 1})) + self.assertEqual(0, db.coll.count_documents({"z": -5})) + + db.coll.insert_one({"z": -10}, bypass_document_validation=True) with self.assertRaises(OperationFailure): - db.test.update_one({"z": -10}, {"$inc": {"z": 1}}) - self.assertEqual(0, db.test.count_documents({"z": -9})) - self.assertEqual(1, db.test.count_documents({"z": -10})) - db.test.update_one({"z": -10}, {"$inc": {"z": 1}}, bypass_document_validation=True) - self.assertEqual(1, db.test.count_documents({"z": -9})) - self.assertEqual(0, db.test.count_documents({"z": -10})) - db.test.update_one({"z": -9}, {"$inc": {"z": 9}}, bypass_document_validation=False) - self.assertEqual(0, db.test.count_documents({"z": -9})) - self.assertEqual(1, db.test.count_documents({"z": 0})) - - db.test.insert_one({"y": 1, "x": 0}, bypass_document_validation=True) + db.coll.update_one({"z": -10}, {"$inc": {"z": 1}}) + self.assertEqual(0, db.coll.count_documents({"z": -9})) + self.assertEqual(1, db.coll.count_documents({"z": -10})) + db.coll.update_one({"z": -10}, {"$inc": {"z": 1}}, bypass_document_validation=True) + self.assertEqual(1, db.coll.count_documents({"z": -9})) + self.assertEqual(0, db.coll.count_documents({"z": -10})) + db.coll.update_one({"z": -9}, {"$inc": {"z": 9}}, bypass_document_validation=False) + self.assertEqual(0, db.coll.count_documents({"z": -9})) + self.assertEqual(1, db.coll.count_documents({"z": 0})) + + db.coll.insert_one({"y": 1, "x": 0}, bypass_document_validation=True) db_w0.test.update_one({"y": 1}, {"$inc": {"x": 1}}, bypass_document_validation=True) def async_lambda(): @@ -1035,42 +1035,42 @@ def async_lambda(): wait_until(async_lambda, "find w:0 updated document") # Test update_many - db.test.insert_many([{"z": i} for i in range(3, 101)]) - db.test.insert_one({"y": 0}, bypass_document_validation=True) + db.coll.insert_many([{"z": i} for i in range(3, 101)]) + db.coll.insert_one({"y": 0}, bypass_document_validation=True) with self.assertRaises(OperationFailure): - db.test.update_many({}, {"$inc": {"z": -100}}) - self.assertEqual(100, db.test.count_documents({"z": {"$gte": 0}})) - self.assertEqual(0, db.test.count_documents({"z": {"$lt": 0}})) - self.assertEqual(0, db.test.count_documents({"y": 0, "z": -100})) - db.test.update_many( + db.coll.update_many({}, {"$inc": {"z": -100}}) + self.assertEqual(100, db.coll.count_documents({"z": {"$gte": 0}})) + self.assertEqual(0, db.coll.count_documents({"z": {"$lt": 0}})) + self.assertEqual(0, db.coll.count_documents({"y": 0, "z": -100})) + db.coll.update_many( {"z": {"$gte": 0}}, {"$inc": {"z": -100}}, bypass_document_validation=True ) - self.assertEqual(0, db.test.count_documents({"z": {"$gt": 0}})) - self.assertEqual(100, db.test.count_documents({"z": {"$lte": 0}})) - db.test.update_many( + self.assertEqual(0, db.coll.count_documents({"z": {"$gt": 0}})) + self.assertEqual(100, db.coll.count_documents({"z": {"$lte": 0}})) + db.coll.update_many( {"z": {"$gt": -50}}, {"$inc": {"z": 100}}, bypass_document_validation=False ) - self.assertEqual(50, db.test.count_documents({"z": {"$gt": 0}})) - self.assertEqual(50, db.test.count_documents({"z": {"$lt": 0}})) + self.assertEqual(50, db.coll.count_documents({"z": {"$gt": 0}})) + self.assertEqual(50, db.coll.count_documents({"z": {"$lt": 0}})) - db.test.insert_many([{"z": -i} for i in range(50)], bypass_document_validation=True) + db.coll.insert_many([{"z": -i} for i in range(50)], bypass_document_validation=True) with self.assertRaises(OperationFailure): - db.test.update_many({}, {"$inc": {"z": 1}}) - self.assertEqual(100, db.test.count_documents({"z": {"$lte": 0}})) - self.assertEqual(50, db.test.count_documents({"z": {"$gt": 1}})) - db.test.update_many( + db.coll.update_many({}, {"$inc": {"z": 1}}) + self.assertEqual(100, db.coll.count_documents({"z": {"$lte": 0}})) + self.assertEqual(50, db.coll.count_documents({"z": {"$gt": 1}})) + db.coll.update_many( {"z": {"$gte": 0}}, {"$inc": {"z": -100}}, bypass_document_validation=True ) - self.assertEqual(0, db.test.count_documents({"z": {"$gt": 0}})) - self.assertEqual(150, db.test.count_documents({"z": {"$lte": 0}})) - db.test.update_many( + self.assertEqual(0, db.coll.count_documents({"z": {"$gt": 0}})) + self.assertEqual(150, db.coll.count_documents({"z": {"$lte": 0}})) + db.coll.update_many( {"z": {"$lte": 0}}, {"$inc": {"z": 100}}, bypass_document_validation=False ) - self.assertEqual(150, db.test.count_documents({"z": {"$gte": 0}})) - self.assertEqual(0, db.test.count_documents({"z": {"$lt": 0}})) + self.assertEqual(150, db.coll.count_documents({"z": {"$gte": 0}})) + self.assertEqual(0, db.coll.count_documents({"z": {"$lt": 0}})) - db.test.insert_one({"m": 1, "x": 0}, bypass_document_validation=True) - db.test.insert_one({"m": 1, "x": 0}, bypass_document_validation=True) + db.coll.insert_one({"m": 1, "x": 0}, bypass_document_validation=True) + db.coll.insert_one({"m": 1, "x": 0}, bypass_document_validation=True) db_w0.test.update_many({"m": 1}, {"$inc": {"x": 1}}, bypass_document_validation=True) def async_lambda(): @@ -1080,8 +1080,8 @@ def async_lambda(): def test_bypass_document_validation_bulk_write(self): db = self.db - db.test.drop() - db.create_collection("test", validator={"a": {"$gte": 0}}) + db.coll.drop() + db.create_collection("coll", validator={"a": {"$gte": 0}}) db_w0 = self.db.client.get_database(self.db.name, write_concern=WriteConcern(w=0)) ops: list = [ @@ -1092,140 +1092,140 @@ def test_bypass_document_validation_bulk_write(self): UpdateMany({"a": {"$lte": -10}}, {"$inc": {"a": 1}}), ReplaceOne({"a": {"$lte": -10}}, {"a": -1}), ] - db.test.bulk_write(ops, bypass_document_validation=True) + db.coll.bulk_write(ops, bypass_document_validation=True) - self.assertEqual(3, db.test.count_documents({})) - self.assertEqual(1, db.test.count_documents({"a": -11})) - self.assertEqual(1, db.test.count_documents({"a": -1})) - self.assertEqual(1, db.test.count_documents({"a": -9})) + self.assertEqual(3, db.coll.count_documents({})) + self.assertEqual(1, db.coll.count_documents({"a": -11})) + self.assertEqual(1, db.coll.count_documents({"a": -1})) + self.assertEqual(1, db.coll.count_documents({"a": -9})) # Assert that the operations would fail without bypass_doc_val for op in ops: with self.assertRaises(BulkWriteError): - db.test.bulk_write([op]) + db.coll.bulk_write([op]) with self.assertRaises(OperationFailure): db_w0.test.bulk_write(ops, bypass_document_validation=True) def test_find_by_default_dct(self): db = self.db - db.test.insert_one({"foo": "bar"}) + db.coll.insert_one({"foo": "bar"}) dct = defaultdict(dict, [("foo", "bar")]) # type: ignore[arg-type] - self.assertIsNotNone(db.test.find_one(dct)) + self.assertIsNotNone(db.coll.find_one(dct)) self.assertEqual(dct, defaultdict(dict, [("foo", "bar")])) def test_find_w_fields(self): db = self.db - db.test.delete_many({}) + db.coll.delete_many({}) - db.test.insert_one({"x": 1, "mike": "awesome", "extra thing": "abcdefghijklmnopqrstuvwxyz"}) - self.assertEqual(1, db.test.count_documents({})) - doc = next(db.test.find({})) + db.coll.insert_one({"x": 1, "mike": "awesome", "extra thing": "abcdefghijklmnopqrstuvwxyz"}) + self.assertEqual(1, db.coll.count_documents({})) + doc = next(db.coll.find({})) self.assertIn("x", doc) - doc = next(db.test.find({})) + doc = next(db.coll.find({})) self.assertIn("mike", doc) - doc = next(db.test.find({})) + doc = next(db.coll.find({})) self.assertIn("extra thing", doc) - doc = next(db.test.find({}, ["x", "mike"])) + doc = next(db.coll.find({}, ["x", "mike"])) self.assertIn("x", doc) - doc = next(db.test.find({}, ["x", "mike"])) + doc = next(db.coll.find({}, ["x", "mike"])) self.assertIn("mike", doc) - doc = next(db.test.find({}, ["x", "mike"])) + doc = next(db.coll.find({}, ["x", "mike"])) self.assertNotIn("extra thing", doc) - doc = next(db.test.find({}, ["mike"])) + doc = next(db.coll.find({}, ["mike"])) self.assertNotIn("x", doc) - doc = next(db.test.find({}, ["mike"])) + doc = next(db.coll.find({}, ["mike"])) self.assertIn("mike", doc) - doc = next(db.test.find({}, ["mike"])) + doc = next(db.coll.find({}, ["mike"])) self.assertNotIn("extra thing", doc) @no_type_check def test_fields_specifier_as_dict(self): db = self.db - db.test.delete_many({}) + db.coll.delete_many({}) - db.test.insert_one({"x": [1, 2, 3], "mike": "awesome"}) + db.coll.insert_one({"x": [1, 2, 3], "mike": "awesome"}) - self.assertEqual([1, 2, 3], (db.test.find_one())["x"]) - self.assertEqual([2, 3], (db.test.find_one(projection={"x": {"$slice": -2}}))["x"]) - self.assertNotIn("x", db.test.find_one(projection={"x": 0})) - self.assertIn("mike", db.test.find_one(projection={"x": 0})) + self.assertEqual([1, 2, 3], (db.coll.find_one())["x"]) + self.assertEqual([2, 3], (db.coll.find_one(projection={"x": {"$slice": -2}}))["x"]) + self.assertNotIn("x", db.coll.find_one(projection={"x": 0})) + self.assertIn("mike", db.coll.find_one(projection={"x": 0})) def test_find_w_regex(self): db = self.db - db.test.delete_many({}) + db.coll.delete_many({}) - db.test.insert_one({"x": "hello_world"}) - db.test.insert_one({"x": "hello_mike"}) - db.test.insert_one({"x": "hello_mikey"}) - db.test.insert_one({"x": "hello_test"}) + db.coll.insert_one({"x": "hello_world"}) + db.coll.insert_one({"x": "hello_mike"}) + db.coll.insert_one({"x": "hello_mikey"}) + db.coll.insert_one({"x": "hello_test"}) - self.assertEqual(len(db.test.find().to_list()), 4) - self.assertEqual(len(db.test.find({"x": re.compile("^hello.*")}).to_list()), 4) - self.assertEqual(len(db.test.find({"x": re.compile("ello")}).to_list()), 4) - self.assertEqual(len(db.test.find({"x": re.compile("^hello$")}).to_list()), 0) - self.assertEqual(len(db.test.find({"x": re.compile("^hello_mi.*$")}).to_list()), 2) + self.assertEqual(len(db.coll.find().to_list()), 4) + self.assertEqual(len(db.coll.find({"x": re.compile("^hello.*")}).to_list()), 4) + self.assertEqual(len(db.coll.find({"x": re.compile("ello")}).to_list()), 4) + self.assertEqual(len(db.coll.find({"x": re.compile("^hello$")}).to_list()), 0) + self.assertEqual(len(db.coll.find({"x": re.compile("^hello_mi.*$")}).to_list()), 2) def test_id_can_be_anything(self): db = self.db - db.test.delete_many({}) + db.coll.delete_many({}) auto_id = {"hello": "world"} - db.test.insert_one(auto_id) + db.coll.insert_one(auto_id) self.assertIsInstance(auto_id["_id"], ObjectId) numeric = {"_id": 240, "hello": "world"} - db.test.insert_one(numeric) + db.coll.insert_one(numeric) self.assertEqual(numeric["_id"], 240) obj = {"_id": numeric, "hello": "world"} - db.test.insert_one(obj) + db.coll.insert_one(obj) self.assertEqual(obj["_id"], numeric) - for x in db.test.find(): + for x in db.coll.find(): self.assertEqual(x["hello"], "world") self.assertIn("_id", x) def test_unique_index(self): db = self.db - db.drop_collection("test") - db.test.create_index("hello") + db.drop_collection("coll") + db.coll.create_index("hello") # No error. - db.test.insert_one({"hello": "world"}) - db.test.insert_one({"hello": "world"}) + db.coll.insert_one({"hello": "world"}) + db.coll.insert_one({"hello": "world"}) - db.drop_collection("test") - db.test.create_index("hello", unique=True) + db.drop_collection("coll") + db.coll.create_index("hello", unique=True) with self.assertRaises(DuplicateKeyError): - db.test.insert_one({"hello": "world"}) - db.test.insert_one({"hello": "world"}) + db.coll.insert_one({"hello": "world"}) + db.coll.insert_one({"hello": "world"}) def test_duplicate_key_error(self): db = self.db - db.drop_collection("test") + db.drop_collection("coll") - db.test.create_index("x", unique=True) + db.coll.create_index("x", unique=True) - db.test.insert_one({"_id": 1, "x": 1}) + db.coll.insert_one({"_id": 1, "x": 1}) with self.assertRaises(DuplicateKeyError) as context: - db.test.insert_one({"x": 1}) + db.coll.insert_one({"x": 1}) self.assertIsNotNone(context.exception.details) with self.assertRaises(DuplicateKeyError) as context: - db.test.insert_one({"x": 1}) + db.coll.insert_one({"x": 1}) self.assertIsNotNone(context.exception.details) - self.assertEqual(1, db.test.count_documents({})) + self.assertEqual(1, db.coll.count_documents({})) def test_write_error_text_handling(self): db = self.db - db.drop_collection("test") + db.drop_collection("coll") - db.test.create_index("text", unique=True) + db.coll.create_index("text", unique=True) # Test workaround for SERVER-24007 data = ( @@ -1260,21 +1260,21 @@ def test_write_error_text_handling(self): ) text = utf_8_decode(data, None, True) - db.test.insert_one({"text": text}) + db.coll.insert_one({"text": text}) # Should raise DuplicateKeyError, not InvalidBSON with self.assertRaises(DuplicateKeyError): - db.test.insert_one({"text": text}) + db.coll.insert_one({"text": text}) with self.assertRaises(DuplicateKeyError): - db.test.replace_one({"_id": ObjectId()}, {"text": text}, upsert=True) + db.coll.replace_one({"_id": ObjectId()}, {"text": text}, upsert=True) # Should raise BulkWriteError, not InvalidBSON with self.assertRaises(BulkWriteError): - db.test.insert_many([{"text": text}]) + db.coll.insert_many([{"text": text}]) def test_write_error_unicode(self): - coll = self.db.test + coll = self.db.coll self.addCleanup(coll.drop) coll.create_index("a", unique=True) @@ -1288,7 +1288,7 @@ def test_write_error_unicode(self): def test_wtimeout(self): # Ensure setting wtimeout doesn't disable write concern altogether. # See SERVER-12596. - collection = self.db.test + collection = self.db.coll collection.drop() collection.insert_one({"_id": 1}) @@ -1302,7 +1302,7 @@ def test_wtimeout(self): def test_error_code(self): try: - self.db.test.update_many({}, {"$thismodifierdoesntexist": 1}) + self.db.coll.update_many({}, {"$thismodifierdoesntexist": 1}) except OperationFailure as exc: self.assertIn(exc.code, (9, 10147, 16840, 17009)) # Just check that we set the error document. Fields @@ -1313,59 +1313,59 @@ def test_error_code(self): def test_index_on_subfield(self): db = self.db - db.drop_collection("test") + db.drop_collection("coll") - db.test.insert_one({"hello": {"a": 4, "b": 5}}) - db.test.insert_one({"hello": {"a": 7, "b": 2}}) - db.test.insert_one({"hello": {"a": 4, "b": 10}}) + db.coll.insert_one({"hello": {"a": 4, "b": 5}}) + db.coll.insert_one({"hello": {"a": 7, "b": 2}}) + db.coll.insert_one({"hello": {"a": 4, "b": 10}}) - db.drop_collection("test") - db.test.create_index("hello.a", unique=True) + db.drop_collection("coll") + db.coll.create_index("hello.a", unique=True) - db.test.insert_one({"hello": {"a": 4, "b": 5}}) - db.test.insert_one({"hello": {"a": 7, "b": 2}}) + db.coll.insert_one({"hello": {"a": 4, "b": 5}}) + db.coll.insert_one({"hello": {"a": 7, "b": 2}}) with self.assertRaises(DuplicateKeyError): - db.test.insert_one({"hello": {"a": 4, "b": 10}}) + db.coll.insert_one({"hello": {"a": 4, "b": 10}}) def test_replace_one(self): db = self.db - db.drop_collection("test") + db.drop_collection("coll") with self.assertRaises(ValueError): - db.test.replace_one({}, {"$set": {"x": 1}}) + db.coll.replace_one({}, {"$set": {"x": 1}}) - id1 = (db.test.insert_one({"x": 1})).inserted_id - result = db.test.replace_one({"x": 1}, {"y": 1}) + id1 = (db.coll.insert_one({"x": 1})).inserted_id + result = db.coll.replace_one({"x": 1}, {"y": 1}) self.assertIsInstance(result, UpdateResult) self.assertEqual(1, result.matched_count) self.assertIn(result.modified_count, (None, 1)) self.assertIsNone(result.upserted_id) self.assertTrue(result.acknowledged) - self.assertEqual(1, db.test.count_documents({"y": 1})) - self.assertEqual(0, db.test.count_documents({"x": 1})) - self.assertEqual((db.test.find_one(id1))["y"], 1) # type: ignore + self.assertEqual(1, db.coll.count_documents({"y": 1})) + self.assertEqual(0, db.coll.count_documents({"x": 1})) + self.assertEqual((db.coll.find_one(id1))["y"], 1) # type: ignore replacement = RawBSONDocument(encode({"_id": id1, "z": 1})) - result = db.test.replace_one({"y": 1}, replacement, True) + result = db.coll.replace_one({"y": 1}, replacement, True) self.assertIsInstance(result, UpdateResult) self.assertEqual(1, result.matched_count) self.assertIn(result.modified_count, (None, 1)) self.assertIsNone(result.upserted_id) self.assertTrue(result.acknowledged) - self.assertEqual(1, db.test.count_documents({"z": 1})) - self.assertEqual(0, db.test.count_documents({"y": 1})) - self.assertEqual((db.test.find_one(id1))["z"], 1) # type: ignore + self.assertEqual(1, db.coll.count_documents({"z": 1})) + self.assertEqual(0, db.coll.count_documents({"y": 1})) + self.assertEqual((db.coll.find_one(id1))["z"], 1) # type: ignore - result = db.test.replace_one({"x": 2}, {"y": 2}, True) + result = db.coll.replace_one({"x": 2}, {"y": 2}, True) self.assertIsInstance(result, UpdateResult) self.assertEqual(0, result.matched_count) self.assertIn(result.modified_count, (None, 0)) self.assertIsInstance(result.upserted_id, ObjectId) self.assertTrue(result.acknowledged) - self.assertEqual(1, db.test.count_documents({"y": 2})) + self.assertEqual(1, db.coll.count_documents({"y": 2})) db = db.client.get_database(db.name, write_concern=WriteConcern(w=0)) - result = db.test.replace_one({"x": 0}, {"y": 0}) + result = db.coll.replace_one({"x": 0}, {"y": 0}) self.assertIsInstance(result, UpdateResult) self.assertRaises(InvalidOperation, lambda: result.matched_count) self.assertRaises(InvalidOperation, lambda: result.modified_count) @@ -1374,31 +1374,31 @@ def test_replace_one(self): def test_update_one(self): db = self.db - db.drop_collection("test") + db.drop_collection("coll") with self.assertRaises(ValueError): - db.test.update_one({}, {"x": 1}) + db.coll.update_one({}, {"x": 1}) - id1 = (db.test.insert_one({"x": 5})).inserted_id - result = db.test.update_one({}, {"$inc": {"x": 1}}) + id1 = (db.coll.insert_one({"x": 5})).inserted_id + result = db.coll.update_one({}, {"$inc": {"x": 1}}) self.assertIsInstance(result, UpdateResult) self.assertEqual(1, result.matched_count) self.assertIn(result.modified_count, (None, 1)) self.assertIsNone(result.upserted_id) self.assertTrue(result.acknowledged) - self.assertEqual((db.test.find_one(id1))["x"], 6) # type: ignore + self.assertEqual((db.coll.find_one(id1))["x"], 6) # type: ignore - id2 = (db.test.insert_one({"x": 1})).inserted_id - result = db.test.update_one({"x": 6}, {"$inc": {"x": 1}}) + id2 = (db.coll.insert_one({"x": 1})).inserted_id + result = db.coll.update_one({"x": 6}, {"$inc": {"x": 1}}) self.assertIsInstance(result, UpdateResult) self.assertEqual(1, result.matched_count) self.assertIn(result.modified_count, (None, 1)) self.assertIsNone(result.upserted_id) self.assertTrue(result.acknowledged) - self.assertEqual((db.test.find_one(id1))["x"], 7) # type: ignore - self.assertEqual((db.test.find_one(id2))["x"], 1) # type: ignore + self.assertEqual((db.coll.find_one(id1))["x"], 7) # type: ignore + self.assertEqual((db.coll.find_one(id2))["x"], 1) # type: ignore - result = db.test.update_one({"x": 2}, {"$set": {"y": 1}}, True) + result = db.coll.update_one({"x": 2}, {"$set": {"y": 1}}, True) self.assertIsInstance(result, UpdateResult) self.assertEqual(0, result.matched_count) self.assertIn(result.modified_count, (None, 0)) @@ -1406,7 +1406,7 @@ def test_update_one(self): self.assertTrue(result.acknowledged) db = db.client.get_database(db.name, write_concern=WriteConcern(w=0)) - result = db.test.update_one({"x": 0}, {"$inc": {"x": 1}}) + result = db.coll.update_one({"x": 0}, {"$inc": {"x": 1}}) self.assertIsInstance(result, UpdateResult) self.assertRaises(InvalidOperation, lambda: result.matched_count) self.assertRaises(InvalidOperation, lambda: result.modified_count) @@ -1415,45 +1415,45 @@ def test_update_one(self): def test_update_result(self): db = self.db - db.drop_collection("test") + db.drop_collection("coll") - result = db.test.update_one({"x": 0}, {"$inc": {"x": 1}}, upsert=True) + result = db.coll.update_one({"x": 0}, {"$inc": {"x": 1}}, upsert=True) self.assertEqual(result.did_upsert, True) - result = db.test.update_one({"_id": None, "x": 0}, {"$inc": {"x": 1}}, upsert=True) + result = db.coll.update_one({"_id": None, "x": 0}, {"$inc": {"x": 1}}, upsert=True) self.assertEqual(result.did_upsert, True) - result = db.test.update_one({"_id": None}, {"$inc": {"x": 1}}) + result = db.coll.update_one({"_id": None}, {"$inc": {"x": 1}}) self.assertEqual(result.did_upsert, False) def test_update_many(self): db = self.db - db.drop_collection("test") + db.drop_collection("coll") with self.assertRaises(ValueError): - db.test.update_many({}, {"x": 1}) + db.coll.update_many({}, {"x": 1}) - db.test.insert_one({"x": 4, "y": 3}) - db.test.insert_one({"x": 5, "y": 5}) - db.test.insert_one({"x": 4, "y": 4}) + db.coll.insert_one({"x": 4, "y": 3}) + db.coll.insert_one({"x": 5, "y": 5}) + db.coll.insert_one({"x": 4, "y": 4}) - result = db.test.update_many({"x": 4}, {"$set": {"y": 5}}) + result = db.coll.update_many({"x": 4}, {"$set": {"y": 5}}) self.assertIsInstance(result, UpdateResult) self.assertEqual(2, result.matched_count) self.assertIn(result.modified_count, (None, 2)) self.assertIsNone(result.upserted_id) self.assertTrue(result.acknowledged) - self.assertEqual(3, db.test.count_documents({"y": 5})) + self.assertEqual(3, db.coll.count_documents({"y": 5})) - result = db.test.update_many({"x": 5}, {"$set": {"y": 6}}) + result = db.coll.update_many({"x": 5}, {"$set": {"y": 6}}) self.assertIsInstance(result, UpdateResult) self.assertEqual(1, result.matched_count) self.assertIn(result.modified_count, (None, 1)) self.assertIsNone(result.upserted_id) self.assertTrue(result.acknowledged) - self.assertEqual(1, db.test.count_documents({"y": 6})) + self.assertEqual(1, db.coll.count_documents({"y": 6})) - result = db.test.update_many({"x": 2}, {"$set": {"y": 1}}, True) + result = db.coll.update_many({"x": 2}, {"$set": {"y": 1}}, True) self.assertIsInstance(result, UpdateResult) self.assertEqual(0, result.matched_count) self.assertIn(result.modified_count, (None, 0)) @@ -1461,7 +1461,7 @@ def test_update_many(self): self.assertTrue(result.acknowledged) db = db.client.get_database(db.name, write_concern=WriteConcern(w=0)) - result = db.test.update_many({"x": 0}, {"$inc": {"x": 1}}) + result = db.coll.update_many({"x": 0}, {"$inc": {"x": 1}}) self.assertIsInstance(result, UpdateResult) self.assertRaises(InvalidOperation, lambda: result.matched_count) self.assertRaises(InvalidOperation, lambda: result.modified_count) @@ -1469,19 +1469,19 @@ def test_update_many(self): self.assertFalse(result.acknowledged) def test_update_check_keys(self): - self.db.drop_collection("test") - self.assertTrue(self.db.test.insert_one({"hello": "world"})) + self.db.drop_collection("coll") + self.assertTrue(self.db.coll.insert_one({"hello": "world"})) # Modify shouldn't check keys... self.assertTrue( - self.db.test.update_one({"hello": "world"}, {"$set": {"foo.bar": "baz"}}, upsert=True) + self.db.coll.update_one({"hello": "world"}, {"$set": {"foo.bar": "baz"}}, upsert=True) ) # I know this seems like testing the server but I'd like to be notified # by CI if the server's behavior changes here. doc = SON([("$set", {"foo.bar": "bim"}), ("hello", "world")]) with self.assertRaises(OperationFailure): - self.db.test.update_one({"hello": "world"}, doc, upsert=True) + self.db.coll.update_one({"hello": "world"}, doc, upsert=True) # This is going to cause keys to be checked and raise InvalidDocument. # That's OK assuming the server's behavior in the previous assert @@ -1489,59 +1489,59 @@ def test_update_check_keys(self): # '$' in update won't be good enough anymore. doc = SON([("hello", "world"), ("$set", {"foo.bar": "bim"})]) with self.assertRaises(OperationFailure): - self.db.test.replace_one({"hello": "world"}, doc, upsert=True) + self.db.coll.replace_one({"hello": "world"}, doc, upsert=True) # Replace with empty document - self.assertNotEqual(0, (self.db.test.replace_one({"hello": "world"}, {})).matched_count) + self.assertNotEqual(0, (self.db.coll.replace_one({"hello": "world"}, {})).matched_count) def test_acknowledged_delete(self): db = self.db - db.drop_collection("test") - db.test.insert_many([{"x": 1}, {"x": 1}]) - self.assertEqual(2, (db.test.delete_many({})).deleted_count) - self.assertEqual(0, (db.test.delete_many({})).deleted_count) + db.drop_collection("coll") + db.coll.insert_many([{"x": 1}, {"x": 1}]) + self.assertEqual(2, (db.coll.delete_many({})).deleted_count) + self.assertEqual(0, (db.coll.delete_many({})).deleted_count) @client_context.require_version_max(4, 9) def test_manual_last_error(self): - coll = self.db.get_collection("test", write_concern=WriteConcern(w=0)) + coll = self.db.get_collection("coll", write_concern=WriteConcern(w=0)) coll.insert_one({"x": 1}) self.db.command("getlasterror", w=1, wtimeout=1) def test_count_documents(self): db = self.db - db.drop_collection("test") - self.addCleanup(db.drop_collection, "test") + db.drop_collection("coll") + self.addCleanup(db.drop_collection, "coll") - self.assertEqual(db.test.count_documents({}), 0) + self.assertEqual(db.coll.count_documents({}), 0) db.wrong.insert_many([{}, {}]) - self.assertEqual(db.test.count_documents({}), 0) - db.test.insert_many([{}, {}]) - self.assertEqual(db.test.count_documents({}), 2) - db.test.insert_many([{"foo": "bar"}, {"foo": "baz"}]) - self.assertEqual(db.test.count_documents({"foo": "bar"}), 1) - self.assertEqual(db.test.count_documents({"foo": re.compile(r"ba.*")}), 2) + self.assertEqual(db.coll.count_documents({}), 0) + db.coll.insert_many([{}, {}]) + self.assertEqual(db.coll.count_documents({}), 2) + db.coll.insert_many([{"foo": "bar"}, {"foo": "baz"}]) + self.assertEqual(db.coll.count_documents({"foo": "bar"}), 1) + self.assertEqual(db.coll.count_documents({"foo": re.compile(r"ba.*")}), 2) def test_estimated_document_count(self): db = self.db - db.drop_collection("test") - self.addCleanup(db.drop_collection, "test") + db.drop_collection("coll") + self.addCleanup(db.drop_collection, "coll") - self.assertEqual(db.test.estimated_document_count(), 0) + self.assertEqual(db.coll.estimated_document_count(), 0) db.wrong.insert_many([{}, {}]) - self.assertEqual(db.test.estimated_document_count(), 0) - db.test.insert_many([{}, {}]) - self.assertEqual(db.test.estimated_document_count(), 2) + self.assertEqual(db.coll.estimated_document_count(), 0) + db.coll.insert_many([{}, {}]) + self.assertEqual(db.coll.estimated_document_count(), 2) def test_aggregate(self): db = self.db - db.drop_collection("test") - db.test.insert_one({"foo": [1, 2]}) + db.drop_collection("coll") + db.coll.insert_one({"foo": [1, 2]}) with self.assertRaises(TypeError): - db.test.aggregate("wow") # type: ignore[arg-type] + db.coll.aggregate("wow") # type: ignore[arg-type] pipeline = {"$project": {"_id": False, "foo": True}} - result = db.test.aggregate([pipeline]) + result = db.coll.aggregate([pipeline]) self.assertIsInstance(result, CommandCursor) self.assertEqual([{"foo": [1, 2]}], result.to_list()) @@ -1551,14 +1551,14 @@ def test_aggregate(self): def test_aggregate_raw_bson(self): db = self.db - db.drop_collection("test") - db.test.insert_one({"foo": [1, 2]}) + db.drop_collection("coll") + db.coll.insert_one({"foo": [1, 2]}) with self.assertRaises(TypeError): - db.test.aggregate("wow") # type: ignore[arg-type] + db.coll.aggregate("wow") # type: ignore[arg-type] pipeline = {"$project": {"_id": False, "foo": True}} - coll = db.get_collection("test", codec_options=CodecOptions(document_class=RawBSONDocument)) + coll = db.get_collection("coll", codec_options=CodecOptions(document_class=RawBSONDocument)) result = coll.aggregate([pipeline]) self.assertIsInstance(result, CommandCursor) first_result = next(result) @@ -1568,7 +1568,7 @@ def test_aggregate_raw_bson(self): def test_aggregation_cursor_validation(self): db = self.db projection = {"$project": {"_id": "$_id"}} - cursor = db.test.aggregate([projection], cursor={}) + cursor = db.coll.aggregate([projection], cursor={}) self.assertIsInstance(cursor, CommandCursor) def test_aggregation_cursor(self): @@ -1582,16 +1582,16 @@ def test_aggregation_cursor(self): ) for collection_size in (10, 1000): - db.drop_collection("test") - db.test.insert_many([{"_id": i} for i in range(collection_size)]) + db.drop_collection("coll") + db.coll.insert_many([{"_id": i} for i in range(collection_size)]) expected_sum = sum(range(collection_size)) # Use batchSize to ensure multiple getMore messages - cursor = db.test.aggregate([{"$project": {"_id": "$_id"}}], batchSize=5) + cursor = db.coll.aggregate([{"$project": {"_id": "$_id"}}], batchSize=5) self.assertEqual(expected_sum, sum(doc["_id"] for doc in cursor.to_list())) # Test that batchSize is handled properly. - cursor = db.test.aggregate([], batchSize=5) + cursor = db.coll.aggregate([], batchSize=5) self.assertEqual(5, len(cursor._data)) # Force a getMore cursor._data.clear() @@ -1603,10 +1603,10 @@ def test_aggregation_cursor(self): pass def test_aggregation_cursor_alive(self): - self.db.test.delete_many({}) - self.db.test.insert_many([{} for _ in range(3)]) - self.addCleanup(self.db.test.delete_many, {}) - cursor = self.db.test.aggregate(pipeline=[], cursor={"batchSize": 2}) + self.db.coll.delete_many({}) + self.db.coll.insert_many([{} for _ in range(3)]) + self.addCleanup(self.db.coll.delete_many, {}) + cursor = self.db.coll.aggregate(pipeline=[], cursor={"batchSize": 2}) n = 0 while True: cursor.next() @@ -1619,7 +1619,7 @@ def test_aggregation_cursor_alive(self): def test_invalid_session_parameter(self): def try_invalid_session(): - with self.db.test.aggregate([], {}): # type:ignore + with self.db.coll.aggregate([], {}): # type:ignore pass with self.assertRaisesRegex(ValueError, "must be a ClientSession"): @@ -1628,14 +1628,14 @@ def try_invalid_session(): def test_large_limit(self): db = self.db db.drop_collection("test_large_limit") - db.test_large_limit.create_index([("x", 1)]) + db.coll_large_limit.create_index([("x", 1)]) my_str = "mongomongo" * 1000 - db.test_large_limit.insert_many({"x": i, "y": my_str} for i in range(2000)) + db.coll_large_limit.insert_many({"x": i, "y": my_str} for i in range(2000)) i = 0 y = 0 - for doc in db.test_large_limit.find(limit=1900).sort([("x", 1)]): + for doc in db.coll_large_limit.find(limit=1900).sort([("x", 1)]): i += 1 y += doc["x"] @@ -1644,45 +1644,45 @@ def test_large_limit(self): def test_find_kwargs(self): db = self.db - db.drop_collection("test") - db.test.insert_many({"x": i} for i in range(10)) + db.drop_collection("coll") + db.coll.insert_many({"x": i} for i in range(10)) - self.assertEqual(10, db.test.count_documents({})) + self.assertEqual(10, db.coll.count_documents({})) total = 0 - for x in db.test.find({}, skip=4, limit=2): + for x in db.coll.find({}, skip=4, limit=2): total += x["x"] self.assertEqual(9, total) def test_rename(self): db = self.db - db.drop_collection("test") + db.drop_collection("coll") db.drop_collection("foo") with self.assertRaises(TypeError): - db.test.rename(5) # type: ignore[arg-type] + db.coll.rename(5) # type: ignore[arg-type] with self.assertRaises(InvalidName): - db.test.rename("") + db.coll.rename("") with self.assertRaises(InvalidName): - db.test.rename("te$t") + db.coll.rename("te$t") with self.assertRaises(InvalidName): - db.test.rename(".test") + db.coll.rename(".test") with self.assertRaises(InvalidName): - db.test.rename("test.") + db.coll.rename("test.") with self.assertRaises(InvalidName): - db.test.rename("tes..t") + db.coll.rename("tes..t") - self.assertEqual(0, db.test.count_documents({})) + self.assertEqual(0, db.coll.count_documents({})) self.assertEqual(0, db.foo.count_documents({})) - db.test.insert_many({"x": i} for i in range(10)) + db.coll.insert_many({"x": i} for i in range(10)) - self.assertEqual(10, db.test.count_documents({})) + self.assertEqual(10, db.coll.count_documents({})) - db.test.rename("foo") + db.coll.rename("foo") - self.assertEqual(0, db.test.count_documents({})) + self.assertEqual(0, db.coll.count_documents({})) self.assertEqual(10, db.foo.count_documents({})) x = 0 @@ -1690,10 +1690,10 @@ def test_rename(self): self.assertEqual(x, doc["x"]) x += 1 - db.test.insert_one({}) + db.coll.insert_one({}) with self.assertRaises(OperationFailure): - db.foo.rename("test") - db.foo.rename("test", dropTarget=True) + db.foo.rename("coll") + db.foo.rename("coll", dropTarget=True) with self.write_concern_collection() as coll: coll.rename("foo") @@ -1701,112 +1701,112 @@ def test_rename(self): @no_type_check def test_find_one(self): db = self.db - db.drop_collection("test") + db.drop_collection("coll") - _id = (db.test.insert_one({"hello": "world", "foo": "bar"})).inserted_id + _id = (db.coll.insert_one({"hello": "world", "foo": "bar"})).inserted_id - self.assertEqual("world", (db.test.find_one())["hello"]) - self.assertEqual(db.test.find_one(_id), db.test.find_one()) - self.assertEqual(db.test.find_one(None), db.test.find_one()) - self.assertEqual(db.test.find_one({}), db.test.find_one()) - self.assertEqual(db.test.find_one({"hello": "world"}), db.test.find_one()) + self.assertEqual("world", (db.coll.find_one())["hello"]) + self.assertEqual(db.coll.find_one(_id), db.coll.find_one()) + self.assertEqual(db.coll.find_one(None), db.coll.find_one()) + self.assertEqual(db.coll.find_one({}), db.coll.find_one()) + self.assertEqual(db.coll.find_one({"hello": "world"}), db.coll.find_one()) - self.assertIn("hello", db.test.find_one(projection=["hello"])) - self.assertNotIn("hello", db.test.find_one(projection=["foo"])) + self.assertIn("hello", db.coll.find_one(projection=["hello"])) + self.assertNotIn("hello", db.coll.find_one(projection=["foo"])) - self.assertIn("hello", db.test.find_one(projection=("hello",))) - self.assertNotIn("hello", db.test.find_one(projection=("foo",))) + self.assertIn("hello", db.coll.find_one(projection=("hello",))) + self.assertNotIn("hello", db.coll.find_one(projection=("foo",))) - self.assertIn("hello", db.test.find_one(projection={"hello"})) - self.assertNotIn("hello", db.test.find_one(projection={"foo"})) + self.assertIn("hello", db.coll.find_one(projection={"hello"})) + self.assertNotIn("hello", db.coll.find_one(projection={"foo"})) - self.assertIn("hello", db.test.find_one(projection=frozenset(["hello"]))) - self.assertNotIn("hello", db.test.find_one(projection=frozenset(["foo"]))) + self.assertIn("hello", db.coll.find_one(projection=frozenset(["hello"]))) + self.assertNotIn("hello", db.coll.find_one(projection=frozenset(["foo"]))) - self.assertEqual(["_id"], list(db.test.find_one(projection={"_id": True}))) - self.assertIn("hello", list(db.test.find_one(projection={}))) - self.assertIn("hello", list(db.test.find_one(projection=[]))) + self.assertEqual(["_id"], list(db.coll.find_one(projection={"_id": True}))) + self.assertIn("hello", list(db.coll.find_one(projection={}))) + self.assertIn("hello", list(db.coll.find_one(projection=[]))) - self.assertEqual(None, db.test.find_one({"hello": "foo"})) - self.assertEqual(None, db.test.find_one(ObjectId())) + self.assertEqual(None, db.coll.find_one({"hello": "foo"})) + self.assertEqual(None, db.coll.find_one(ObjectId())) def test_find_one_non_objectid(self): db = self.db - db.drop_collection("test") + db.drop_collection("coll") - db.test.insert_one({"_id": 5}) + db.coll.insert_one({"_id": 5}) - self.assertTrue(db.test.find_one(5)) - self.assertFalse(db.test.find_one(6)) + self.assertTrue(db.coll.find_one(5)) + self.assertFalse(db.coll.find_one(6)) def test_find_one_with_find_args(self): db = self.db - db.drop_collection("test") + db.drop_collection("coll") - db.test.insert_many([{"x": i} for i in range(1, 4)]) + db.coll.insert_many([{"x": i} for i in range(1, 4)]) - self.assertEqual(1, (db.test.find_one())["x"]) - self.assertEqual(2, (db.test.find_one(skip=1, limit=2))["x"]) + self.assertEqual(1, (db.coll.find_one())["x"]) + self.assertEqual(2, (db.coll.find_one(skip=1, limit=2))["x"]) def test_find_with_sort(self): db = self.db - db.drop_collection("test") + db.drop_collection("coll") - db.test.insert_many([{"x": 2}, {"x": 1}, {"x": 3}]) + db.coll.insert_many([{"x": 2}, {"x": 1}, {"x": 3}]) - self.assertEqual(2, (db.test.find_one())["x"]) - self.assertEqual(1, (db.test.find_one(sort=[("x", 1)]))["x"]) - self.assertEqual(3, (db.test.find_one(sort=[("x", -1)]))["x"]) + self.assertEqual(2, (db.coll.find_one())["x"]) + self.assertEqual(1, (db.coll.find_one(sort=[("x", 1)]))["x"]) + self.assertEqual(3, (db.coll.find_one(sort=[("x", -1)]))["x"]) def to_list(things): return [thing["x"] for thing in things] - self.assertEqual([2, 1, 3], to_list(db.test.find())) - self.assertEqual([1, 2, 3], to_list(db.test.find(sort=[("x", 1)]))) - self.assertEqual([3, 2, 1], to_list(db.test.find(sort=[("x", -1)]))) + self.assertEqual([2, 1, 3], to_list(db.coll.find())) + self.assertEqual([1, 2, 3], to_list(db.coll.find(sort=[("x", 1)]))) + self.assertEqual([3, 2, 1], to_list(db.coll.find(sort=[("x", -1)]))) with self.assertRaises(TypeError): - db.test.find(sort=5) + db.coll.find(sort=5) with self.assertRaises(TypeError): - db.test.find(sort="hello") + db.coll.find(sort="hello") with self.assertRaises(TypeError): - db.test.find(sort=["hello", 1]) + db.coll.find(sort=["hello", 1]) # TODO doesn't actually test functionality, just that it doesn't blow up def test_cursor_timeout(self): - self.db.test.find(no_cursor_timeout=True).to_list() - self.db.test.find(no_cursor_timeout=False).to_list() + self.db.coll.find(no_cursor_timeout=True).to_list() + self.db.coll.find(no_cursor_timeout=False).to_list() def test_exhaust(self): if is_mongos(self.db.client): with self.assertRaises(InvalidOperation): - next(self.db.test.find(cursor_type=CursorType.EXHAUST)) + next(self.db.coll.find(cursor_type=CursorType.EXHAUST)) return # Limit is incompatible with exhaust. with self.assertRaises(InvalidOperation): - next(self.db.test.find(cursor_type=CursorType.EXHAUST, limit=5)) - cur = self.db.test.find(cursor_type=CursorType.EXHAUST) + next(self.db.coll.find(cursor_type=CursorType.EXHAUST, limit=5)) + cur = self.db.coll.find(cursor_type=CursorType.EXHAUST) with self.assertRaises(InvalidOperation): cur.limit(5) cur.next() - cur = self.db.test.find(limit=5) + cur = self.db.coll.find(limit=5) with self.assertRaises(InvalidOperation): cur.add_option(64) - cur = self.db.test.find() + cur = self.db.coll.find() cur.add_option(64) with self.assertRaises(InvalidOperation): cur.limit(5) - self.db.drop_collection("test") + self.db.drop_collection("coll") # Insert enough documents to require more than one batch - self.db.test.insert_many([{"i": i} for i in range(150)]) + self.db.coll.insert_many([{"i": i} for i in range(150)]) client = self.rs_or_single_client(maxPoolSize=1) pool = get_pool(client) # Make sure the socket is returned after exhaustion. - cur = client[self.db.name].test.find(cursor_type=CursorType.EXHAUST) + cur = client[self.db.name].coll.find(cursor_type=CursorType.EXHAUST) next(cur) self.assertEqual(0, len(pool.conns)) for _ in cur: @@ -1814,14 +1814,14 @@ def test_exhaust(self): self.assertEqual(1, len(pool.conns)) # Same as previous but don't call next() - for _ in client[self.db.name].test.find(cursor_type=CursorType.EXHAUST): + for _ in client[self.db.name].coll.find(cursor_type=CursorType.EXHAUST): pass self.assertEqual(1, len(pool.conns)) # If the Cursor instance is discarded before being completely iterated # and the socket has pending data (more_to_come=True) we have to close # and discard the socket. - cur = client[self.db.name].test.find(cursor_type=CursorType.EXHAUST, batch_size=2) + cur = client[self.db.name].coll.find(cursor_type=CursorType.EXHAUST, batch_size=2) if client_context.version.at_least(4, 2): # On 4.2+ we use OP_MSG which only sets more_to_come=True after the # first getMore. @@ -1840,9 +1840,9 @@ def test_exhaust(self): self.assertEqual(0, len(pool.conns)) def test_distinct(self): - self.db.drop_collection("test") + self.db.drop_collection("coll") - test = self.db.test + test = self.db.coll test.insert_many([{"a": 1}, {"a": 2}, {"a": 2}, {"a": 2}, {"a": 3}]) distinct = test.distinct("a") @@ -1858,7 +1858,7 @@ def test_distinct(self): distinct.sort() self.assertEqual([2, 3], distinct) - self.db.drop_collection("test") + self.db.drop_collection("coll") test.insert_one({"a": {"b": "a"}, "c": 12}) test.insert_one({"a": {"b": "b"}, "c": 12}) @@ -1871,19 +1871,19 @@ def test_distinct(self): self.assertEqual(["a", "b", "c"], distinct) def test_query_on_query_field(self): - self.db.drop_collection("test") - self.db.test.insert_one({"query": "foo"}) - self.db.test.insert_one({"bar": "foo"}) + self.db.drop_collection("coll") + self.db.coll.insert_one({"query": "foo"}) + self.db.coll.insert_one({"bar": "foo"}) - self.assertEqual(1, self.db.test.count_documents({"query": {"$ne": None}})) - self.assertEqual(1, len(self.db.test.find({"query": {"$ne": None}}).to_list())) + self.assertEqual(1, self.db.coll.count_documents({"query": {"$ne": None}})) + self.assertEqual(1, len(self.db.coll.find({"query": {"$ne": None}}).to_list())) def test_min_query(self): - self.db.drop_collection("test") - self.db.test.insert_many([{"x": 1}, {"x": 2}]) - self.db.test.create_index("x") + self.db.drop_collection("coll") + self.db.coll.insert_many([{"x": 1}, {"x": 2}]) + self.db.coll.create_index("x") - cursor = self.db.test.find({"$min": {"x": 2}, "$query": {}}, hint="x_1") + cursor = self.db.coll.find({"$min": {"x": 2}, "$query": {}}, hint="x_1") docs = cursor.to_list() self.assertEqual(1, len(docs)) @@ -1891,11 +1891,11 @@ def test_min_query(self): def test_numerous_inserts(self): # Ensure we don't exceed server's maxWriteBatchSize size limit. - self.db.test.drop() + self.db.coll.drop() n_docs = client_context.max_write_batch_size + 100 - self.db.test.insert_many([{} for _ in range(n_docs)]) - self.assertEqual(n_docs, self.db.test.count_documents({})) - self.db.test.drop() + self.db.coll.insert_many([{} for _ in range(n_docs)]) + self.assertEqual(n_docs, self.db.coll.count_documents({})) + self.db.coll.drop() def test_insert_many_large_batch(self): # Tests legacy insert. @@ -1984,13 +1984,13 @@ def test_messages_with_unicode_collection_names(self): db["Employés"].find().to_list() def test_drop_indexes_non_existent(self): - self.db.drop_collection("test") - self.db.test.drop_indexes() + self.db.drop_collection("coll") + self.db.coll.drop_indexes() # This is really a bson test but easier to just reproduce it here... # (Shame on me) def test_bad_encode(self): - c = self.db.test + c = self.db.coll c.drop() with self.assertRaises(InvalidDocument): c.insert_one({"x": c}) @@ -2005,7 +2005,7 @@ def __getattr__(self, name): def test_array_filters_validation(self): # array_filters must be a list. - c = self.db.test + c = self.db.coll with self.assertRaises(TypeError): c.update_one({}, {"$set": {"a": 1}}, array_filters={}) # type: ignore[arg-type] with self.assertRaises(TypeError): @@ -2015,7 +2015,7 @@ def test_array_filters_validation(self): c.find_one_and_update({}, update, array_filters={}) # type: ignore[arg-type] def test_array_filters_unacknowledged(self): - c_w0 = self.db.test.with_options(write_concern=WriteConcern(w=0)) + c_w0 = self.db.coll.with_options(write_concern=WriteConcern(w=0)) with self.assertRaises(ConfigurationError): c_w0.update_one({}, {"$set": {"y.$[i].b": 5}}, array_filters=[{"i.b": 1}]) with self.assertRaises(ConfigurationError): @@ -2024,7 +2024,7 @@ def test_array_filters_unacknowledged(self): c_w0.find_one_and_update({}, {"$set": {"y.$[i].b": 5}}, array_filters=[{"i.b": 1}]) def test_find_one_and(self): - c = self.db.test + c = self.db.coll c.drop() c.insert_one({"_id": 1, "i": 1}) @@ -2080,9 +2080,9 @@ def test_find_one_and_write_concern(self): listener = OvertCommandListener() db = (self.single_client(event_listeners=[listener]))[self.db.name] # non-default WriteConcern. - c_w0 = db.get_collection("test", write_concern=WriteConcern(w=0)) + c_w0 = db.get_collection("coll", write_concern=WriteConcern(w=0)) # default WriteConcern. - c_default = db.get_collection("test", write_concern=WriteConcern()) + c_default = db.get_collection("coll", write_concern=WriteConcern()) # Authenticate the client and throw out auth commands from the listener. db.command("ping") listener.reset() @@ -2101,7 +2101,7 @@ def test_find_one_and_write_concern(self): # Test write concern errors. if client_context.is_rs: c_wc_error = db.get_collection( - "test", write_concern=WriteConcern(w=len(client_context.nodes) + 1) + "coll", write_concern=WriteConcern(w=len(client_context.nodes) + 1) ) with self.assertRaises(WriteConcernError): c_wc_error.find_one_and_update({"_id": 1}, {"$set": {"foo": "bar"}}) @@ -2128,7 +2128,7 @@ def test_find_one_and_write_concern(self): listener.reset() def test_find_with_nested(self): - c = self.db.test + c = self.db.coll c.drop() c.insert_many([{"i": i} for i in range(5)]) # [0, 1, 2, 3, 4] self.assertEqual( @@ -2186,7 +2186,7 @@ def test_find_with_nested(self): ) def test_find_regex(self): - c = self.db.test + c = self.db.coll c.drop() c.insert_one({"r": re.compile(".*")}) @@ -2211,11 +2211,11 @@ def test_find_command_generation(self): def test_bool(self): with self.assertRaises(NotImplementedError): - bool(Collection(self.db, "test")) + bool(Collection(self.db, "coll")) @client_context.require_version_min(5, 0, 0) def test_helpers_with_let(self): - c = self.db.test + c = self.db.coll def afind(*args, **kwargs): return c.find(*args, **kwargs) diff --git a/test/test_comment.py b/test/test_comment.py index bcab0061fa..3da50cc659 100644 --- a/test/test_comment.py +++ b/test/test_comment.py @@ -92,7 +92,7 @@ def test_database_helpers(self): (db.list_collections, []), (db.list_collection_names, []), (db.drop_collection, ["hello"]), - (db.validate_collection, ["test"]), + (db.validate_collection, ["coll"]), (db.dereference, [DBRef("collection", 1)]), ] already_supported = [db.command, db.list_collections, db.list_collection_names] @@ -107,7 +107,7 @@ def test_client_helpers(self): (cli.watch, []), (cli.list_databases, []), (cli.list_database_names, []), - (cli.drop_database, ["test"]), + (cli.drop_database, ["db"]), ] already_supported = [ cli.list_databases, @@ -118,7 +118,7 @@ def test_client_helpers(self): def test_collection_helpers(self): listener = OvertCommandListener() db = (self.rs_or_single_client(event_listeners=[listener]))[self.db.name] - coll = db.get_collection("test") + coll = db.get_collection("coll") helpers = [ (coll.list_indexes, []), diff --git a/test/test_common.py b/test/test_common.py index e69b421c9f..dbd583efb8 100644 --- a/test/test_common.py +++ b/test/test_common.py @@ -119,23 +119,23 @@ def test_write_concern(self): self.assertEqual(wc, c.write_concern) # Can we override back to the server default? - db = c.get_database("pymongo_test", write_concern=WriteConcern()) + db = c.get_database("db", write_concern=WriteConcern()) self.assertEqual(db.write_concern, WriteConcern()) - db = c.pymongo_test + db = c.db self.assertEqual(wc, db.write_concern) - coll = db.test + coll = db.coll self.assertEqual(wc, coll.write_concern) cwc = WriteConcern(j=True) - coll = db.get_collection("test", write_concern=cwc) + coll = db.get_collection("coll", write_concern=cwc) self.assertEqual(cwc, coll.write_concern) self.assertEqual(wc, db.write_concern) def test_mongo_client(self): pair = client_context.pair m = self.rs_or_single_client(w=0) - coll = m.pymongo_test.write_concern_test + coll = m.db.write_concern_test coll.drop() doc = {"_id": ObjectId()} coll.insert_one(doc) @@ -145,7 +145,7 @@ def test_mongo_client(self): coll.insert_one(doc) m = self.rs_or_single_client() - coll = m.pymongo_test.write_concern_test + coll = m.db.write_concern_test new_coll = coll.with_options(write_concern=WriteConcern(w=0)) self.assertTrue(new_coll.insert_one(doc)) with self.assertRaises(OperationFailure): @@ -155,14 +155,14 @@ def test_mongo_client(self): f"mongodb://{pair}/", replicaSet=client_context.replica_set_name ) - coll = m.pymongo_test.write_concern_test + coll = m.db.write_concern_test with self.assertRaises(OperationFailure): coll.insert_one(doc) m = self.rs_or_single_client( f"mongodb://{pair}/?w=0", replicaSet=client_context.replica_set_name ) - coll = m.pymongo_test.write_concern_test + coll = m.db.write_concern_test coll.insert_one(doc) # Equality tests @@ -172,11 +172,11 @@ def test_mongo_client(self): self.assertFalse(direct != direct2) def test_validate_boolean(self): - self.db.test.update_one({}, {"$set": {"total": 1}}, upsert=True) + self.db.coll.update_one({}, {"$set": {"total": 1}}, upsert=True) with self.assertRaisesRegex( TypeError, "upsert must be True or False, was: upsert={'upsert': True}" ): - self.db.test.update_one({}, {"$set": {"total": 1}}, {"upsert": True}) # type: ignore + self.db.coll.update_one({}, {"$set": {"total": 1}}, {"upsert": True}) # type: ignore if __name__ == "__main__": diff --git a/test/test_csot.py b/test/test_csot.py index d6dec51d37..de5d8c6430 100644 --- a/test/test_csot.py +++ b/test/test_csot.py @@ -78,7 +78,7 @@ def test_timeout_nested(self): @client_context.require_change_streams @flaky(reason="PYTHON-3522") def test_change_stream_can_resume_after_timeouts(self): - coll = self.db.test + coll = self.db.coll coll.insert_one({}) with coll.watch() as stream: with pymongo.timeout(0.1): diff --git a/test/test_cursor.py b/test/test_cursor.py index af5c9b89e8..282e6381ad 100644 --- a/test/test_cursor.py +++ b/test/test_cursor.py @@ -60,7 +60,7 @@ class TestCursor(IntegrationTest): def test_deepcopy_cursor_littered_with_regexes(self): - cursor = self.db.test.find( + cursor = self.db.coll.find( { "x": re.compile("^hmmm.*"), "y": [re.compile("^hmm.*")], @@ -73,18 +73,18 @@ def test_deepcopy_cursor_littered_with_regexes(self): self.assertEqual(cursor._spec, cursor2._spec) def test_add_remove_option(self): - cursor = self.db.test.find() + cursor = self.db.coll.find() self.assertEqual(0, cursor._query_flags) cursor.add_option(2) - cursor2 = self.db.test.find(cursor_type=CursorType.TAILABLE) + cursor2 = self.db.coll.find(cursor_type=CursorType.TAILABLE) self.assertEqual(2, cursor2._query_flags) self.assertEqual(cursor._query_flags, cursor2._query_flags) cursor.add_option(32) - cursor2 = self.db.test.find(cursor_type=CursorType.TAILABLE_AWAIT) + cursor2 = self.db.coll.find(cursor_type=CursorType.TAILABLE_AWAIT) self.assertEqual(34, cursor2._query_flags) self.assertEqual(cursor._query_flags, cursor2._query_flags) cursor.add_option(128) - cursor2 = self.db.test.find(cursor_type=CursorType.TAILABLE_AWAIT).add_option(128) + cursor2 = self.db.coll.find(cursor_type=CursorType.TAILABLE_AWAIT).add_option(128) self.assertEqual(162, cursor2._query_flags) self.assertEqual(cursor._query_flags, cursor2._query_flags) @@ -93,11 +93,11 @@ def test_add_remove_option(self): self.assertEqual(162, cursor._query_flags) cursor.remove_option(128) - cursor2 = self.db.test.find(cursor_type=CursorType.TAILABLE_AWAIT) + cursor2 = self.db.coll.find(cursor_type=CursorType.TAILABLE_AWAIT) self.assertEqual(34, cursor2._query_flags) self.assertEqual(cursor._query_flags, cursor2._query_flags) cursor.remove_option(32) - cursor2 = self.db.test.find(cursor_type=CursorType.TAILABLE) + cursor2 = self.db.coll.find(cursor_type=CursorType.TAILABLE) self.assertEqual(2, cursor2._query_flags) self.assertEqual(cursor._query_flags, cursor2._query_flags) @@ -106,25 +106,25 @@ def test_add_remove_option(self): self.assertEqual(2, cursor._query_flags) # Timeout - cursor = self.db.test.find(no_cursor_timeout=True) + cursor = self.db.coll.find(no_cursor_timeout=True) self.assertEqual(16, cursor._query_flags) - cursor2 = self.db.test.find().add_option(16) + cursor2 = self.db.coll.find().add_option(16) self.assertEqual(cursor._query_flags, cursor2._query_flags) cursor.remove_option(16) self.assertEqual(0, cursor._query_flags) # Tailable / Await data - cursor = self.db.test.find(cursor_type=CursorType.TAILABLE_AWAIT) + cursor = self.db.coll.find(cursor_type=CursorType.TAILABLE_AWAIT) self.assertEqual(34, cursor._query_flags) - cursor2 = self.db.test.find().add_option(34) + cursor2 = self.db.coll.find().add_option(34) self.assertEqual(cursor._query_flags, cursor2._query_flags) cursor.remove_option(32) self.assertEqual(2, cursor._query_flags) # Partial - cursor = self.db.test.find(allow_partial_results=True) + cursor = self.db.coll.find(allow_partial_results=True) self.assertEqual(128, cursor._query_flags) - cursor2 = self.db.test.find().add_option(128) + cursor2 = self.db.coll.find().add_option(128) self.assertEqual(cursor._query_flags, cursor2._query_flags) cursor.remove_option(128) self.assertEqual(0, cursor._query_flags) @@ -133,11 +133,11 @@ def test_add_remove_option_exhaust(self): # Exhaust - which mongos doesn't support if client_context.is_mongos: with self.assertRaises(InvalidOperation): - next(self.db.test.find(cursor_type=CursorType.EXHAUST)) + next(self.db.coll.find(cursor_type=CursorType.EXHAUST)) else: - cursor = self.db.test.find(cursor_type=CursorType.EXHAUST) + cursor = self.db.coll.find(cursor_type=CursorType.EXHAUST) self.assertEqual(64, cursor._query_flags) - cursor2 = self.db.test.find().add_option(64) + cursor2 = self.db.coll.find().add_option(64) self.assertEqual(cursor._query_flags, cursor2._query_flags) self.assertTrue(cursor._exhaust) cursor.remove_option(64) @@ -146,8 +146,8 @@ def test_add_remove_option_exhaust(self): def test_allow_disk_use(self): db = self.db - db.pymongo_test.drop() - coll = db.pymongo_test + db.coll.drop() + coll = db.coll with self.assertRaises(TypeError): coll.find().allow_disk_use("baz") # type: ignore[arg-type] @@ -159,8 +159,8 @@ def test_allow_disk_use(self): def test_max_time_ms(self): db = self.db - db.pymongo_test.drop() - coll = db.pymongo_test + db.coll.drop() + coll = db.coll with self.assertRaises(TypeError): coll.find().max_time_ms("foo") # type: ignore[arg-type] coll.insert_one({"amalia": 1}) @@ -201,9 +201,9 @@ def test_max_time_ms(self): def test_maxtime_ms_message(self): db = self.db - db.t.insert_one({"x": 1}) + db.coll.insert_one({"x": 1}) with self.assertRaises(OperationFailure) as error: - db.t.find_one({"$where": delay(2)}, max_time_ms=1) + db.coll.find_one({"$where": delay(2)}, max_time_ms=1) # Newer MongoDB executes $where in WASM and returns Interrupted (11601) instead # of MaxTimeMSExpired (50) when max_time_ms kills execution; only MaxTimeMSExpired @@ -212,17 +212,17 @@ def test_maxtime_ms_message(self): self.assertIn("(configured timeouts: connectTimeoutMS: 20000.0ms", str(error.exception)) client = self.rs_client(document_class=RawBSONDocument) - client.db.t.insert_one({"x": 1}) + client.db.coll.insert_one({"x": 1}) with self.assertRaises(OperationFailure) as error: - client.db.t.find_one({"$where": delay(2)}, max_time_ms=1) + client.db.coll.find_one({"$where": delay(2)}, max_time_ms=1) if isinstance(error.exception, ExecutionTimeout): self.assertIn("(configured timeouts: connectTimeoutMS: 20000.0ms", str(error.exception)) def test_max_await_time_ms(self): db = self.db - db.pymongo_test.drop() - coll = db.create_collection("pymongo_test", capped=True, size=4096) + db.coll.drop() + coll = db.create_collection("db", capped=True, size=4096) with self.assertRaises(TypeError): coll.find().max_await_time_ms("foo") # type: ignore[arg-type] @@ -254,7 +254,7 @@ def test_max_await_time_ms(self): self.assertEqual(90, cursor._max_await_time_ms) listener = AllowListEventListener("find", "getMore") - coll = (self.rs_or_single_client(event_listeners=[listener]))[self.db.name].pymongo_test + coll = (self.rs_or_single_client(event_listeners=[listener]))[self.db.name].coll # Tailable_defaults. coll.find(cursor_type=CursorType.TAILABLE_AWAIT).to_list() @@ -340,7 +340,7 @@ def test_max_await_time_ms(self): @client_context.require_no_mongos def test_max_time_ms_getmore(self): # Test that Cursor handles server timeout error in response to getmore. - coll = self.db.pymongo_test + coll = self.db.coll coll.insert_many([{} for _ in range(200)]) cursor = coll.find().max_time_ms(100) @@ -359,7 +359,7 @@ def test_max_time_ms_getmore(self): self.client.admin.command("configureFailPoint", "maxTimeAlwaysTimeOut", mode="off") def test_explain(self): - a = self.db.test.find() + a = self.db.coll.find() a.explain() for _ in a: break @@ -370,7 +370,7 @@ def test_explain_with_read_concern(self): # Do not add readConcern level to explain. listener = AllowListEventListener("explain") client = self.rs_or_single_client(event_listeners=[listener]) - coll = client.pymongo_test.test.with_options(read_concern=ReadConcern(level="local")) + coll = client.db.coll.with_options(read_concern=ReadConcern(level="local")) self.assertTrue(coll.find().explain()) started = listener.started_events self.assertEqual(len(started), 1) @@ -402,104 +402,104 @@ def test_explain_csot(self): def test_hint(self): db = self.db with self.assertRaises(TypeError): - db.test.find().hint(5.5) # type: ignore[arg-type] - db.test.drop() + db.coll.find().hint(5.5) # type: ignore[arg-type] + db.coll.drop() - db.test.insert_many([{"num": i, "foo": i} for i in range(100)]) + db.coll.insert_many([{"num": i, "foo": i} for i in range(100)]) with self.assertRaises(OperationFailure): - db.test.find({"num": 17, "foo": 17}).hint([("num", ASCENDING)]).explain() + db.coll.find({"num": 17, "foo": 17}).hint([("num", ASCENDING)]).explain() with self.assertRaises(OperationFailure): - db.test.find({"num": 17, "foo": 17}).hint([("foo", ASCENDING)]).explain() + db.coll.find({"num": 17, "foo": 17}).hint([("foo", ASCENDING)]).explain() spec: list[Any] = [("num", DESCENDING)] - _ = db.test.create_index(spec) + _ = db.coll.create_index(spec) - first = next(db.test.find()) + first = next(db.coll.find()) self.assertEqual(0, first.get("num")) - first = next(db.test.find().hint(spec)) + first = next(db.coll.find().hint(spec)) self.assertEqual(99, first.get("num")) with self.assertRaises(OperationFailure): - db.test.find({"num": 17, "foo": 17}).hint([("foo", ASCENDING)]).explain() + db.coll.find({"num": 17, "foo": 17}).hint([("foo", ASCENDING)]).explain() - a = db.test.find({"num": 17}) + a = db.coll.find({"num": 17}) a.hint(spec) for _ in a: break self.assertRaises(InvalidOperation, a.hint, spec) - db.test.drop() - db.test.insert_many([{"num": i, "foo": i} for i in range(100)]) + db.coll.drop() + db.coll.insert_many([{"num": i, "foo": i} for i in range(100)]) spec: _IndexList = ["num", ("foo", DESCENDING)] - db.test.create_index(spec) - first = next(db.test.find().hint(spec)) + db.coll.create_index(spec) + first = next(db.coll.find().hint(spec)) self.assertEqual(0, first.get("num")) self.assertEqual(0, first.get("foo")) - db.test.drop() - db.test.insert_many([{"num": i, "foo": i} for i in range(100)]) + db.coll.drop() + db.coll.insert_many([{"num": i, "foo": i} for i in range(100)]) spec = ["num"] - db.test.create_index(spec) - first = next(db.test.find().hint(spec)) + db.coll.create_index(spec) + first = next(db.coll.find().hint(spec)) self.assertEqual(0, first.get("num")) def test_hint_by_name(self): db = self.db - db.test.drop() + db.coll.drop() - db.test.insert_many([{"i": i} for i in range(100)]) + db.coll.insert_many([{"i": i} for i in range(100)]) - db.test.create_index([("i", DESCENDING)], name="fooindex") - first = next(db.test.find()) + db.coll.create_index([("i", DESCENDING)], name="fooindex") + first = next(db.coll.find()) self.assertEqual(0, first.get("i")) - first = next(db.test.find().hint("fooindex")) + first = next(db.coll.find().hint("fooindex")) self.assertEqual(99, first.get("i")) def test_limit(self): db = self.db with self.assertRaises(TypeError): - db.test.find().limit(None) # type: ignore[arg-type] + db.coll.find().limit(None) # type: ignore[arg-type] with self.assertRaises(TypeError): - db.test.find().limit("hello") # type: ignore[arg-type] + db.coll.find().limit("hello") # type: ignore[arg-type] with self.assertRaises(TypeError): - db.test.find().limit(5.5) # type: ignore[arg-type] - self.assertTrue((db.test.find()).limit(5)) + db.coll.find().limit(5.5) # type: ignore[arg-type] + self.assertTrue((db.coll.find()).limit(5)) - db.test.drop() - db.test.insert_many([{"x": i} for i in range(100)]) + db.coll.drop() + db.coll.insert_many([{"x": i} for i in range(100)]) count = 0 - for _ in db.test.find(): + for _ in db.coll.find(): count += 1 self.assertEqual(count, 100) count = 0 - for _ in db.test.find().limit(20): + for _ in db.coll.find().limit(20): count += 1 self.assertEqual(count, 20) count = 0 - for _ in db.test.find().limit(99): + for _ in db.coll.find().limit(99): count += 1 self.assertEqual(count, 99) count = 0 - for _ in db.test.find().limit(1): + for _ in db.coll.find().limit(1): count += 1 self.assertEqual(count, 1) count = 0 - for _ in db.test.find().limit(0): + for _ in db.coll.find().limit(0): count += 1 self.assertEqual(count, 100) count = 0 - for _ in db.test.find().limit(0).limit(50).limit(10): + for _ in db.coll.find().limit(0).limit(50).limit(10): count += 1 self.assertEqual(count, 10) - a = db.test.find() + a = db.coll.find() a.limit(10) for _ in a: break @@ -508,14 +508,14 @@ def test_limit(self): def test_max(self): db = self.db - db.test.drop() + db.coll.drop() j_index = [("j", ASCENDING)] - db.test.create_index(j_index) + db.coll.create_index(j_index) - db.test.insert_many([{"j": j, "k": j} for j in range(10)]) + db.coll.insert_many([{"j": j, "k": j} for j in range(10)]) def find(max_spec, expected_index): - return db.test.find().max(max_spec).hint(expected_index) + return db.coll.find().max(max_spec).hint(expected_index) cursor = find([("j", 3)], j_index) self.assertEqual(len(cursor.to_list()), 3) @@ -526,7 +526,7 @@ def find(max_spec, expected_index): # Compound index. index_keys = [("j", ASCENDING), ("k", ASCENDING)] - db.test.create_index(index_keys) + db.coll.create_index(index_keys) cursor = find([("j", 3), ("k", 3)], index_keys) self.assertEqual(len(cursor.to_list()), 3) @@ -540,20 +540,20 @@ def find(max_spec, expected_index): with self.assertRaises(OperationFailure): cursor.to_list() with self.assertRaises(TypeError): - db.test.find().max(10) # type: ignore[arg-type] + db.coll.find().max(10) # type: ignore[arg-type] with self.assertRaises(TypeError): - db.test.find().max({"j": 10}) # type: ignore[arg-type] + db.coll.find().max({"j": 10}) # type: ignore[arg-type] def test_min(self): db = self.db - db.test.drop() + db.coll.drop() j_index = [("j", ASCENDING)] - db.test.create_index(j_index) + db.coll.create_index(j_index) - db.test.insert_many([{"j": j, "k": j} for j in range(10)]) + db.coll.insert_many([{"j": j, "k": j} for j in range(10)]) def find(min_spec, expected_index): - return db.test.find().min(min_spec).hint(expected_index) + return db.coll.find().min(min_spec).hint(expected_index) cursor = find([("j", 3)], j_index) self.assertEqual(len(cursor.to_list()), 7) @@ -564,7 +564,7 @@ def find(min_spec, expected_index): # Compound index. index_keys = [("j", ASCENDING), ("k", ASCENDING)] - db.test.create_index(index_keys) + db.coll.create_index(index_keys) cursor = find([("j", 3), ("k", 3)], index_keys) self.assertEqual(len(cursor.to_list()), 7) @@ -579,12 +579,12 @@ def find(min_spec, expected_index): cursor.to_list() with self.assertRaises(TypeError): - db.test.find().min(10) # type: ignore[arg-type] + db.coll.find().min(10) # type: ignore[arg-type] with self.assertRaises(TypeError): - db.test.find().min({"j": 10}) # type: ignore[arg-type] + db.coll.find().min({"j": 10}) # type: ignore[arg-type] def test_min_max_without_hint(self): - coll = self.db.test + coll = self.db.coll j_index = [("j", ASCENDING)] coll.create_index(j_index) @@ -595,19 +595,19 @@ def test_min_max_without_hint(self): def test_batch_size(self): db = self.db - db.test.drop() - db.test.insert_many([{"x": x} for x in range(200)]) + db.coll.drop() + db.coll.insert_many([{"x": x} for x in range(200)]) with self.assertRaises(TypeError): - db.test.find().batch_size(None) # type: ignore[arg-type] + db.coll.find().batch_size(None) # type: ignore[arg-type] with self.assertRaises(TypeError): - db.test.find().batch_size("hello") # type: ignore[arg-type] + db.coll.find().batch_size("hello") # type: ignore[arg-type] with self.assertRaises(TypeError): - db.test.find().batch_size(5.5) # type: ignore[arg-type] + db.coll.find().batch_size(5.5) # type: ignore[arg-type] with self.assertRaises(ValueError): - db.test.find().batch_size(-1) - self.assertTrue((db.test.find()).batch_size(5)) - a = db.test.find() + db.coll.find().batch_size(-1) + self.assertTrue((db.coll.find()).batch_size(5)) + a = db.coll.find() for _ in a: break self.assertRaises(InvalidOperation, a.batch_size, 5) @@ -618,28 +618,28 @@ def cursor_count(cursor, expected_count): count += 1 self.assertEqual(expected_count, count) - cursor_count((db.test.find()).batch_size(0), 200) - cursor_count((db.test.find()).batch_size(1), 200) - cursor_count((db.test.find()).batch_size(2), 200) - cursor_count((db.test.find()).batch_size(5), 200) - cursor_count((db.test.find()).batch_size(100), 200) - cursor_count((db.test.find()).batch_size(500), 200) - - cursor_count((db.test.find()).batch_size(0).limit(1), 1) - cursor_count((db.test.find()).batch_size(1).limit(1), 1) - cursor_count((db.test.find()).batch_size(2).limit(1), 1) - cursor_count((db.test.find()).batch_size(5).limit(1), 1) - cursor_count((db.test.find()).batch_size(100).limit(1), 1) - cursor_count((db.test.find()).batch_size(500).limit(1), 1) - - cursor_count((db.test.find()).batch_size(0).limit(10), 10) - cursor_count((db.test.find()).batch_size(1).limit(10), 10) - cursor_count((db.test.find()).batch_size(2).limit(10), 10) - cursor_count((db.test.find()).batch_size(5).limit(10), 10) - cursor_count((db.test.find()).batch_size(100).limit(10), 10) - cursor_count((db.test.find()).batch_size(500).limit(10), 10) - - cur = db.test.find().batch_size(1) + cursor_count((db.coll.find()).batch_size(0), 200) + cursor_count((db.coll.find()).batch_size(1), 200) + cursor_count((db.coll.find()).batch_size(2), 200) + cursor_count((db.coll.find()).batch_size(5), 200) + cursor_count((db.coll.find()).batch_size(100), 200) + cursor_count((db.coll.find()).batch_size(500), 200) + + cursor_count((db.coll.find()).batch_size(0).limit(1), 1) + cursor_count((db.coll.find()).batch_size(1).limit(1), 1) + cursor_count((db.coll.find()).batch_size(2).limit(1), 1) + cursor_count((db.coll.find()).batch_size(5).limit(1), 1) + cursor_count((db.coll.find()).batch_size(100).limit(1), 1) + cursor_count((db.coll.find()).batch_size(500).limit(1), 1) + + cursor_count((db.coll.find()).batch_size(0).limit(10), 10) + cursor_count((db.coll.find()).batch_size(1).limit(10), 10) + cursor_count((db.coll.find()).batch_size(2).limit(10), 10) + cursor_count((db.coll.find()).batch_size(5).limit(10), 10) + cursor_count((db.coll.find()).batch_size(100).limit(10), 10) + cursor_count((db.coll.find()).batch_size(500).limit(10), 10) + + cur = db.coll.find().batch_size(1) next(cur) # find command batchSize should be 1 self.assertEqual(0, len(cur._data)) @@ -652,54 +652,54 @@ def cursor_count(cursor, expected_count): def test_limit_and_batch_size(self): db = self.db - db.test.drop() - db.test.insert_many([{"x": x} for x in range(500)]) + db.coll.drop() + db.coll.insert_many([{"x": x} for x in range(500)]) - curs = db.test.find().limit(0).batch_size(10) + curs = db.coll.find().limit(0).batch_size(10) next(curs) self.assertEqual(10, curs._retrieved) - curs = db.test.find(limit=0, batch_size=10) + curs = db.coll.find(limit=0, batch_size=10) next(curs) self.assertEqual(10, curs._retrieved) - curs = db.test.find().limit(-2).batch_size(0) + curs = db.coll.find().limit(-2).batch_size(0) next(curs) self.assertEqual(2, curs._retrieved) - curs = db.test.find(limit=-2, batch_size=0) + curs = db.coll.find(limit=-2, batch_size=0) next(curs) self.assertEqual(2, curs._retrieved) - curs = db.test.find().limit(-4).batch_size(5) + curs = db.coll.find().limit(-4).batch_size(5) next(curs) self.assertEqual(4, curs._retrieved) - curs = db.test.find(limit=-4, batch_size=5) + curs = db.coll.find(limit=-4, batch_size=5) next(curs) self.assertEqual(4, curs._retrieved) - curs = db.test.find().limit(50).batch_size(500) + curs = db.coll.find().limit(50).batch_size(500) next(curs) self.assertEqual(50, curs._retrieved) - curs = db.test.find(limit=50, batch_size=500) + curs = db.coll.find(limit=50, batch_size=500) next(curs) self.assertEqual(50, curs._retrieved) - curs = db.test.find().batch_size(500) + curs = db.coll.find().batch_size(500) next(curs) self.assertEqual(500, curs._retrieved) - curs = db.test.find(batch_size=500) + curs = db.coll.find(batch_size=500) next(curs) self.assertEqual(500, curs._retrieved) - curs = db.test.find().limit(50) + curs = db.coll.find().limit(50) next(curs) self.assertEqual(50, curs._retrieved) - curs = db.test.find(limit=50) + curs = db.coll.find(limit=50) next(curs) self.assertEqual(50, curs._retrieved) @@ -707,15 +707,15 @@ def test_limit_and_batch_size(self): # is set by the server. as of 2.0.0-rc0, 101 # or 1MB (whichever is smaller) is default # for queries without ntoreturn - curs = db.test.find() + curs = db.coll.find() next(curs) self.assertEqual(101, curs._retrieved) - curs = db.test.find().limit(0).batch_size(0) + curs = db.coll.find().limit(0).batch_size(0) next(curs) self.assertEqual(101, curs._retrieved) - curs = db.test.find(limit=0, batch_size=0) + curs = db.coll.find(limit=0, batch_size=0) next(curs) self.assertEqual(101, curs._retrieved) @@ -723,47 +723,47 @@ def test_skip(self): db = self.db with self.assertRaises(TypeError): - db.test.find().skip(None) # type: ignore[arg-type] + db.coll.find().skip(None) # type: ignore[arg-type] with self.assertRaises(TypeError): - db.test.find().skip("hello") # type: ignore[arg-type] + db.coll.find().skip("hello") # type: ignore[arg-type] with self.assertRaises(TypeError): - db.test.find().skip(5.5) # type: ignore[arg-type] + db.coll.find().skip(5.5) # type: ignore[arg-type] with self.assertRaises(ValueError): - db.test.find().skip(-5) - self.assertTrue((db.test.find()).skip(5)) + db.coll.find().skip(-5) + self.assertTrue((db.coll.find()).skip(5)) - db.drop_collection("test") + db.drop_collection("coll") - db.test.insert_many([{"x": i} for i in range(100)]) + db.coll.insert_many([{"x": i} for i in range(100)]) - for i in db.test.find(): + for i in db.coll.find(): self.assertEqual(i["x"], 0) break - for i in db.test.find().skip(20): + for i in db.coll.find().skip(20): self.assertEqual(i["x"], 20) break - for i in db.test.find().skip(99): + for i in db.coll.find().skip(99): self.assertEqual(i["x"], 99) break - for i in db.test.find().skip(1): + for i in db.coll.find().skip(1): self.assertEqual(i["x"], 1) break - for i in db.test.find().skip(0): + for i in db.coll.find().skip(0): self.assertEqual(i["x"], 0) break - for i in db.test.find().skip(0).skip(50).skip(10): + for i in db.coll.find().skip(0).skip(50).skip(10): self.assertEqual(i["x"], 10) break - for _ in db.test.find().skip(1000): + for _ in db.coll.find().skip(1000): self.fail() - a = db.test.find() + a = db.coll.find() a.skip(10) for _ in a: break @@ -773,52 +773,52 @@ def test_sort(self): db = self.db with self.assertRaises(TypeError): - db.test.find().sort(5) # type: ignore[arg-type] + db.coll.find().sort(5) # type: ignore[arg-type] with self.assertRaises(ValueError): - db.test.find().sort([]) # type: ignore[arg-type] + db.coll.find().sort([]) # type: ignore[arg-type] with self.assertRaises(TypeError): - db.test.find().sort([], ASCENDING) # type: ignore[arg-type] + db.coll.find().sort([], ASCENDING) # type: ignore[arg-type] with self.assertRaises(TypeError): - db.test.find().sort([("hello", DESCENDING)], DESCENDING) # type: ignore[arg-type] + db.coll.find().sort([("hello", DESCENDING)], DESCENDING) # type: ignore[arg-type] - db.test.drop() + db.coll.drop() unsort = list(range(10)) random.shuffle(unsort) - db.test.insert_many([{"x": i} for i in unsort]) + db.coll.insert_many([{"x": i} for i in unsort]) - asc = [i["x"] for i in db.test.find().sort("x", ASCENDING)] + asc = [i["x"] for i in db.coll.find().sort("x", ASCENDING)] self.assertEqual(asc, list(range(10))) - asc = [i["x"] for i in db.test.find().sort("x")] + asc = [i["x"] for i in db.coll.find().sort("x")] self.assertEqual(asc, list(range(10))) - asc = [i["x"] for i in db.test.find().sort([("x", ASCENDING)])] + asc = [i["x"] for i in db.coll.find().sort([("x", ASCENDING)])] self.assertEqual(asc, list(range(10))) expect = list(reversed(range(10))) - desc = [i["x"] for i in db.test.find().sort("x", DESCENDING)] + desc = [i["x"] for i in db.coll.find().sort("x", DESCENDING)] self.assertEqual(desc, expect) - desc = [i["x"] for i in db.test.find().sort([("x", DESCENDING)])] + desc = [i["x"] for i in db.coll.find().sort([("x", DESCENDING)])] self.assertEqual(desc, expect) - desc = [i["x"] for i in db.test.find().sort("x", ASCENDING).sort("x", DESCENDING)] + desc = [i["x"] for i in db.coll.find().sort("x", ASCENDING).sort("x", DESCENDING)] self.assertEqual(desc, expect) expected = [(1, 5), (2, 5), (0, 3), (7, 3), (9, 2), (2, 1), (3, 1)] shuffled = list(expected) random.shuffle(shuffled) - db.test.drop() + db.coll.drop() for a, b in shuffled: - db.test.insert_one({"a": a, "b": b}) + db.coll.insert_one({"a": a, "b": b}) result = [ - (i["a"], i["b"]) for i in db.test.find().sort([("b", DESCENDING), ("a", ASCENDING)]) + (i["a"], i["b"]) for i in db.coll.find().sort([("b", DESCENDING), ("a", ASCENDING)]) ] self.assertEqual(result, expected) - result = [(i["a"], i["b"]) for i in db.test.find().sort([("b", DESCENDING), "a"])] + result = [(i["a"], i["b"]) for i in db.coll.find().sort([("b", DESCENDING), "a"])] self.assertEqual(result, expected) - a = db.test.find() + a = db.coll.find() a.sort("x", ASCENDING) for _ in a: break @@ -830,9 +830,9 @@ def test_sort(self): ) def test_where(self): db = self.db - db.test.drop() + db.coll.drop() - a = db.test.find() + a = db.coll.find() with self.assertRaises(TypeError): a.where(5) # type: ignore[arg-type] with self.assertRaises(TypeError): @@ -840,41 +840,41 @@ def test_where(self): with self.assertRaises(TypeError): a.where({}) # type: ignore[arg-type] - db.test.insert_many([{"x": i} for i in range(10)]) + db.coll.insert_many([{"x": i} for i in range(10)]) - self.assertEqual(3, len(db.test.find().where("this.x < 3").to_list())) - self.assertEqual(3, len(db.test.find().where(Code("this.x < 3")).to_list())) + self.assertEqual(3, len(db.coll.find().where("this.x < 3").to_list())) + self.assertEqual(3, len(db.coll.find().where(Code("this.x < 3")).to_list())) code_with_scope = Code("this.x < i", {"i": 3}) if client_context.version.at_least(4, 3, 3): # MongoDB 4.4 removed support for Code with scope. with self.assertRaises(OperationFailure): - db.test.find().where(code_with_scope).to_list() + db.coll.find().where(code_with_scope).to_list() code_with_empty_scope = Code("this.x < 3", {}) with self.assertRaises(OperationFailure): - db.test.find().where(code_with_empty_scope).to_list() + db.coll.find().where(code_with_empty_scope).to_list() else: - self.assertEqual(3, len(db.test.find().where(code_with_scope).to_list())) + self.assertEqual(3, len(db.coll.find().where(code_with_scope).to_list())) - self.assertEqual(10, len(db.test.find().to_list())) - self.assertEqual([0, 1, 2], [a["x"] for a in db.test.find().where("this.x < 3")]) - self.assertEqual([], [a["x"] for a in db.test.find({"x": 5}).where("this.x < 3")]) - self.assertEqual([5], [a["x"] for a in db.test.find({"x": 5}).where("this.x > 3")]) + self.assertEqual(10, len(db.coll.find().to_list())) + self.assertEqual([0, 1, 2], [a["x"] for a in db.coll.find().where("this.x < 3")]) + self.assertEqual([], [a["x"] for a in db.coll.find({"x": 5}).where("this.x < 3")]) + self.assertEqual([5], [a["x"] for a in db.coll.find({"x": 5}).where("this.x > 3")]) - cursor = db.test.find().where("this.x < 3").where("this.x > 7") + cursor = db.coll.find().where("this.x < 3").where("this.x > 7") self.assertEqual([8, 9], [a["x"] for a in cursor]) - a = db.test.find() + a = db.coll.find() _ = a.where("this.x > 3") for _ in a: break self.assertRaises(InvalidOperation, a.where, "this.x < 3") def test_rewind(self): - self.db.test.insert_many([{"x": i} for i in range(1, 4)]) + self.db.coll.insert_many([{"x": i} for i in range(1, 4)]) - cursor = self.db.test.find().limit(2) + cursor = self.db.coll.find().limit(2) count = 0 for _ in cursor: @@ -906,9 +906,9 @@ def test_rewind(self): # oplog_reply, and snapshot are all deprecated. @ignore_deprecations def test_clone(self): - self.db.test.insert_many([{"x": i} for i in range(1, 4)]) + self.db.coll.insert_many([{"x": i} for i in range(1, 4)]) - cursor = self.db.test.find().limit(2) + cursor = self.db.coll.find().limit(2) count = 0 for _ in cursor: @@ -943,7 +943,7 @@ def test_clone(self): # Just test attributes cursor = ( - self.db.test.find( + self.db.coll.find( {"x": re.compile("^hello.*")}, projection={"_id": False}, skip=1, @@ -991,7 +991,7 @@ def test_clone(self): # Test memo when deepcopying queries query = {"hello": "world"} query["reflexive"] = query - cursor = self.db.test.find(query) + cursor = self.db.coll.find(query) cursor2 = copy.deepcopy(cursor) @@ -1000,7 +1000,7 @@ def test_clone(self): self.assertEqual(len(cursor2._spec), 2) # Ensure hints are cloned as the correct type - cursor = self.db.test.find().hint([("z", 1), ("a", 1)]) + cursor = self.db.coll.find().hint([("z", 1), ("a", 1)]) cursor2 = copy.deepcopy(cursor) # Internal types are now dict rather than SON by default self.assertIsInstance(cursor2._hint, dict) @@ -1008,9 +1008,9 @@ def test_clone(self): @client_context.require_sync def test_clone_empty(self): - self.db.test.delete_many({}) - self.db.test.insert_many([{"x": i} for i in range(1, 4)]) - cursor = self.db.test.find()[2:2] + self.db.coll.delete_many({}) + self.db.coll.insert_many([{"x": i} for i in range(1, 4)]) + cursor = self.db.coll.find()[2:2] cursor2 = cursor.clone() self.assertRaises(StopIteration, cursor.next) self.assertRaises(StopIteration, cursor2.next) @@ -1018,130 +1018,130 @@ def test_clone_empty(self): # Cursors don't support slicing @client_context.require_sync def test_bad_getitem(self): - self.assertRaises(TypeError, lambda x: self.db.test.find()[x], "hello") - self.assertRaises(TypeError, lambda x: self.db.test.find()[x], 5.5) - self.assertRaises(TypeError, lambda x: self.db.test.find()[x], None) + self.assertRaises(TypeError, lambda x: self.db.coll.find()[x], "hello") + self.assertRaises(TypeError, lambda x: self.db.coll.find()[x], 5.5) + self.assertRaises(TypeError, lambda x: self.db.coll.find()[x], None) # Cursors don't support slicing @client_context.require_sync def test_getitem_slice_index(self): - self.db.drop_collection("test") - self.db.test.insert_many([{"i": i} for i in range(100)]) + self.db.drop_collection("coll") + self.db.coll.insert_many([{"i": i} for i in range(100)]) count = itertools.count - self.assertRaises(IndexError, lambda: self.db.test.find()[-1:]) - self.assertRaises(IndexError, lambda: self.db.test.find()[1:2:2]) + self.assertRaises(IndexError, lambda: self.db.coll.find()[-1:]) + self.assertRaises(IndexError, lambda: self.db.coll.find()[1:2:2]) - for a, b in zip(count(0), self.db.test.find()): # type: ignore[call-overload] + for a, b in zip(count(0), self.db.coll.find()): # type: ignore[call-overload] self.assertEqual(a, b["i"]) - self.assertEqual(100, len(list(self.db.test.find()[0:]))) # type: ignore[call-overload] - for a, b in zip(count(0), self.db.test.find()[0:]): # type: ignore[call-overload] + self.assertEqual(100, len(list(self.db.coll.find()[0:]))) # type: ignore[call-overload] + for a, b in zip(count(0), self.db.coll.find()[0:]): # type: ignore[call-overload] self.assertEqual(a, b["i"]) - self.assertEqual(80, len(list(self.db.test.find()[20:]))) # type: ignore[call-overload] - for a, b in zip(count(20), self.db.test.find()[20:]): # type: ignore[call-overload] + self.assertEqual(80, len(list(self.db.coll.find()[20:]))) # type: ignore[call-overload] + for a, b in zip(count(20), self.db.coll.find()[20:]): # type: ignore[call-overload] self.assertEqual(a, b["i"]) - for a, b in zip(count(99), self.db.test.find()[99:]): # type: ignore[call-overload] + for a, b in zip(count(99), self.db.coll.find()[99:]): # type: ignore[call-overload] self.assertEqual(a, b["i"]) - for _i in self.db.test.find()[1000:]: + for _i in self.db.coll.find()[1000:]: self.fail() - self.assertEqual(5, len(list(self.db.test.find()[20:25]))) # type: ignore[call-overload] - self.assertEqual(5, len(list(self.db.test.find()[20:25]))) # type: ignore[call-overload] - for a, b in zip(count(20), self.db.test.find()[20:25]): # type: ignore[call-overload] + self.assertEqual(5, len(list(self.db.coll.find()[20:25]))) # type: ignore[call-overload] + self.assertEqual(5, len(list(self.db.coll.find()[20:25]))) # type: ignore[call-overload] + for a, b in zip(count(20), self.db.coll.find()[20:25]): # type: ignore[call-overload] self.assertEqual(a, b["i"]) - self.assertEqual(80, len(list(self.db.test.find()[40:45][20:]))) # type: ignore[call-overload] - for a, b in zip(count(20), self.db.test.find()[40:45][20:]): # type: ignore[call-overload] + self.assertEqual(80, len(list(self.db.coll.find()[40:45][20:]))) # type: ignore[call-overload] + for a, b in zip(count(20), self.db.coll.find()[40:45][20:]): # type: ignore[call-overload] self.assertEqual(a, b["i"]) - self.assertEqual(80, len(list(self.db.test.find()[40:45].limit(0).skip(20)))) # type: ignore[call-overload] - for a, b in zip(count(20), self.db.test.find()[40:45].limit(0).skip(20)): # type: ignore[call-overload] + self.assertEqual(80, len(list(self.db.coll.find()[40:45].limit(0).skip(20)))) # type: ignore[call-overload] + for a, b in zip(count(20), self.db.coll.find()[40:45].limit(0).skip(20)): # type: ignore[call-overload] self.assertEqual(a, b["i"]) - self.assertEqual(80, len(list(self.db.test.find().limit(10).skip(40)[20:]))) # type: ignore[call-overload] - for a, b in zip(count(20), self.db.test.find().limit(10).skip(40)[20:]): # type: ignore[call-overload] + self.assertEqual(80, len(list(self.db.coll.find().limit(10).skip(40)[20:]))) # type: ignore[call-overload] + for a, b in zip(count(20), self.db.coll.find().limit(10).skip(40)[20:]): # type: ignore[call-overload] self.assertEqual(a, b["i"]) - self.assertEqual(1, len(list(self.db.test.find()[:1]))) # type: ignore[call-overload] - self.assertEqual(5, len(list(self.db.test.find()[:5]))) # type: ignore[call-overload] + self.assertEqual(1, len(list(self.db.coll.find()[:1]))) # type: ignore[call-overload] + self.assertEqual(5, len(list(self.db.coll.find()[:5]))) # type: ignore[call-overload] - self.assertEqual(1, len(list(self.db.test.find()[99:100]))) # type: ignore[call-overload] - self.assertEqual(1, len(list(self.db.test.find()[99:1000]))) # type: ignore[call-overload] - self.assertEqual(0, len(list(self.db.test.find()[10:10]))) # type: ignore[call-overload] - self.assertEqual(0, len(list(self.db.test.find()[:0]))) # type: ignore[call-overload] - self.assertEqual(80, len(list(self.db.test.find()[10:10].limit(0).skip(20)))) # type: ignore[call-overload] + self.assertEqual(1, len(list(self.db.coll.find()[99:100]))) # type: ignore[call-overload] + self.assertEqual(1, len(list(self.db.coll.find()[99:1000]))) # type: ignore[call-overload] + self.assertEqual(0, len(list(self.db.coll.find()[10:10]))) # type: ignore[call-overload] + self.assertEqual(0, len(list(self.db.coll.find()[:0]))) # type: ignore[call-overload] + self.assertEqual(80, len(list(self.db.coll.find()[10:10].limit(0).skip(20)))) # type: ignore[call-overload] - self.assertRaises(IndexError, lambda: self.db.test.find()[10:8]) + self.assertRaises(IndexError, lambda: self.db.coll.find()[10:8]) # Cursors don't support slicing @client_context.require_sync def test_getitem_numeric_index(self): - self.db.drop_collection("test") - self.db.test.insert_many([{"i": i} for i in range(100)]) + self.db.drop_collection("coll") + self.db.coll.insert_many([{"i": i} for i in range(100)]) - self.assertEqual(0, self.db.test.find()[0]["i"]) - self.assertEqual(50, self.db.test.find()[50]["i"]) - self.assertEqual(50, self.db.test.find().skip(50)[0]["i"]) - self.assertEqual(50, self.db.test.find().skip(49)[1]["i"]) - self.assertEqual(50, self.db.test.find()[50]["i"]) - self.assertEqual(99, self.db.test.find()[99]["i"]) + self.assertEqual(0, self.db.coll.find()[0]["i"]) + self.assertEqual(50, self.db.coll.find()[50]["i"]) + self.assertEqual(50, self.db.coll.find().skip(50)[0]["i"]) + self.assertEqual(50, self.db.coll.find().skip(49)[1]["i"]) + self.assertEqual(50, self.db.coll.find()[50]["i"]) + self.assertEqual(99, self.db.coll.find()[99]["i"]) - self.assertRaises(IndexError, lambda x: self.db.test.find()[x], -1) - self.assertRaises(IndexError, lambda x: self.db.test.find()[x], 100) - self.assertRaises(IndexError, lambda x: self.db.test.find().skip(50)[x], 50) + self.assertRaises(IndexError, lambda x: self.db.coll.find()[x], -1) + self.assertRaises(IndexError, lambda x: self.db.coll.find()[x], 100) + self.assertRaises(IndexError, lambda x: self.db.coll.find().skip(50)[x], 50) @client_context.require_sync def test_iteration_with_list(self): - self.db.drop_collection("test") - self.db.test.insert_many([{"i": i} for i in range(100)]) + self.db.drop_collection("coll") + self.db.coll.insert_many([{"i": i} for i in range(100)]) - cur = self.db.test.find().batch_size(10) + cur = self.db.coll.find().batch_size(10) self.assertEqual(100, len(list(cur))) # type: ignore[call-overload] def test_len(self): with self.assertRaises(TypeError): - len(self.db.test.find()) # type: ignore[arg-type] + len(self.db.coll.find()) # type: ignore[arg-type] def test_properties(self): - self.assertEqual(self.db.test, self.db.test.find().collection) + self.assertEqual(self.db.coll, self.db.coll.find().collection) with self.assertRaises(AttributeError): - self.db.test.find().collection = "hello" # type: ignore + self.db.coll.find().collection = "hello" # type: ignore def test_get_more(self): db = self.db - db.drop_collection("test") - db.test.insert_many([{"i": i} for i in range(10)]) - self.assertEqual(10, len(db.test.find().batch_size(5).to_list())) + db.drop_collection("coll") + db.coll.insert_many([{"i": i} for i in range(10)]) + self.assertEqual(10, len(db.coll.find().batch_size(5).to_list())) def test_tailable(self): db = self.db - db.drop_collection("test") - db.create_collection("test", capped=True, size=1000, max=3) - self.addCleanup(db.drop_collection, "test") - cursor = db.test.find(cursor_type=CursorType.TAILABLE) + db.drop_collection("coll") + db.create_collection("coll", capped=True, size=1000, max=3) + self.addCleanup(db.drop_collection, "coll") + cursor = db.coll.find(cursor_type=CursorType.TAILABLE) - db.test.insert_one({"x": 1}) + db.coll.insert_one({"x": 1}) count = 0 for doc in cursor: count += 1 self.assertEqual(1, doc["x"]) self.assertEqual(1, count) - db.test.insert_one({"x": 2}) + db.coll.insert_one({"x": 2}) count = 0 for doc in cursor: count += 1 self.assertEqual(2, doc["x"]) self.assertEqual(1, count) - db.test.insert_one({"x": 3}) + db.coll.insert_one({"x": 3}) count = 0 for doc in cursor: count += 1 @@ -1151,19 +1151,19 @@ def test_tailable(self): # Capped rollover - the collection can never # have more than 3 documents. Just make sure # this doesn't raise... - db.test.insert_many([{"x": i} for i in range(4, 7)]) + db.coll.insert_many([{"x": i} for i in range(4, 7)]) self.assertEqual(0, len(cursor.to_list())) # and that the cursor doesn't think it's still alive. self.assertFalse(cursor.alive) - self.assertEqual(3, db.test.count_documents({})) + self.assertEqual(3, db.coll.count_documents({})) # __getitem__(index) if _IS_SYNC: for cursor in ( - db.test.find(cursor_type=CursorType.TAILABLE), - db.test.find(cursor_type=CursorType.TAILABLE_AWAIT), + db.coll.find(cursor_type=CursorType.TAILABLE), + db.coll.find(cursor_type=CursorType.TAILABLE_AWAIT), ): self.assertEqual(4, cursor[0]["x"]) self.assertEqual(5, cursor[1]["x"]) @@ -1187,10 +1187,10 @@ def test_tailable(self): def test_concurrent_close(self): """Ensure a tailable can be closed from another thread.""" db = self.db - db.drop_collection("test") - db.create_collection("test", capped=True, size=1000, max=3) - self.addCleanup(db.drop_collection, "test") - cursor = db.test.find(cursor_type=CursorType.TAILABLE) + db.drop_collection("coll") + db.create_collection("coll", capped=True, size=1000, max=3) + self.addCleanup(db.drop_collection, "coll") + cursor = db.coll.find(cursor_type=CursorType.TAILABLE) def iterate_cursor(): while cursor.alive: @@ -1210,37 +1210,37 @@ def iterate_cursor(): self.assertFalse(t.is_alive()) def test_distinct(self): - self.db.drop_collection("test") + self.db.drop_collection("coll") - self.db.test.insert_many([{"a": 1}, {"a": 2}, {"a": 2}, {"a": 2}, {"a": 3}]) + self.db.coll.insert_many([{"a": 1}, {"a": 2}, {"a": 2}, {"a": 2}, {"a": 3}]) - distinct = self.db.test.find({"a": {"$lt": 3}}).distinct("a") + distinct = self.db.coll.find({"a": {"$lt": 3}}).distinct("a") distinct.sort() self.assertEqual([1, 2], distinct) - self.db.drop_collection("test") + self.db.drop_collection("coll") - self.db.test.insert_one({"a": {"b": "a"}, "c": 12}) - self.db.test.insert_one({"a": {"b": "b"}, "c": 8}) - self.db.test.insert_one({"a": {"b": "c"}, "c": 12}) - self.db.test.insert_one({"a": {"b": "c"}, "c": 8}) + self.db.coll.insert_one({"a": {"b": "a"}, "c": 12}) + self.db.coll.insert_one({"a": {"b": "b"}, "c": 8}) + self.db.coll.insert_one({"a": {"b": "c"}, "c": 12}) + self.db.coll.insert_one({"a": {"b": "c"}, "c": 8}) - distinct = self.db.test.find({"c": 8}).distinct("a.b") + distinct = self.db.coll.find({"c": 8}).distinct("a.b") distinct.sort() self.assertEqual(["b", "c"], distinct) def test_with_statement(self): - self.db.drop_collection("test") - self.db.test.insert_many([{} for _ in range(100)]) + self.db.drop_collection("coll") + self.db.coll.insert_many([{} for _ in range(100)]) - c1 = self.db.test.find() - with self.db.test.find() as c2: + c1 = self.db.coll.find() + with self.db.coll.find() as c2: self.assertTrue(c2.alive) self.assertFalse(c2.alive) - with self.db.test.find() as c2: + with self.db.coll.find() as c2: self.assertEqual(100, len(c2.to_list())) self.assertFalse(c2.alive) self.assertTrue(c1.alive) @@ -1250,18 +1250,18 @@ def test_comment(self): self.client.drop_database(self.db) self.db.command("profile", 2) # Profile ALL commands. try: - self.db.test.find().comment("foo").to_list() + self.db.coll.find().comment("foo").to_list() count = self.db.system.profile.count_documents( - {"ns": "pymongo_test.test", "op": "query", "command.comment": "foo"} + {"ns": "db.coll", "op": "query", "command.comment": "foo"} ) self.assertEqual(count, 1) - self.db.test.find().comment("foo").distinct("type") + self.db.coll.find().comment("foo").distinct("type") count = self.db.system.profile.count_documents( { - "ns": "pymongo_test.test", + "ns": "db.coll", "op": "command", - "command.distinct": "test", + "command.distinct": "coll", "command.comment": "foo", } ) @@ -1270,16 +1270,16 @@ def test_comment(self): self.db.command("profile", 0) # Turn off profiling. self.db.system.profile.drop() - self.db.test.insert_many([{}, {}]) - cursor = self.db.test.find() + self.db.coll.insert_many([{}, {}]) + cursor = self.db.coll.find() next(cursor) self.assertRaises(InvalidOperation, cursor.comment, "hello") def test_alive(self): - self.db.test.delete_many({}) - self.db.test.insert_many([{} for _ in range(3)]) - self.addCleanup(self.db.test.delete_many, {}) - cursor = self.db.test.find().batch_size(2) + self.db.coll.delete_many({}) + self.db.coll.insert_many([{} for _ in range(3)]) + self.addCleanup(self.db.coll.delete_many, {}) + cursor = self.db.coll.find().batch_size(2) n = 0 while True: cursor.next() @@ -1394,7 +1394,7 @@ def test_getMore_does_not_send_readPreference(self): client = self.rs_or_single_client(event_listeners=[listener]) # We never send primary read preference so override the default. coll = client[self.db.name].get_collection( - "test", read_preference=ReadPreference.PRIMARY_PREFERRED + "coll", read_preference=ReadPreference.PRIMARY_PREFERRED ) coll.delete_many({}) @@ -1434,7 +1434,7 @@ def test_to_list_empty(self): self.assertEqual([], docs) def test_to_list_length(self): - coll = self.db.test + coll = self.db.coll coll.insert_many([{} for _ in range(5)]) self.addCleanup(coll.drop) c = coll.find() @@ -1462,7 +1462,7 @@ def test_to_list_csot_applied(self): @client_context.require_change_streams def test_command_cursor_to_list(self): # Set maxAwaitTimeMS=1 to speed up the test. - c = self.db.test.aggregate([{"$changeStream": {}}], maxAwaitTimeMS=1) + c = self.db.coll.aggregate([{"$changeStream": {}}], maxAwaitTimeMS=1) self.addCleanup(c.close) docs = c.to_list() self.assertGreaterEqual(len(docs), 0) @@ -1478,14 +1478,14 @@ def test_command_cursor_to_list_empty(self): @client_context.require_change_streams def test_command_cursor_to_list_length(self): db = self.db - db.drop_collection("test") - db.test.insert_many([{"foo": 1}, {"foo": 2}]) + db.drop_collection("coll") + db.coll.insert_many([{"foo": 1}, {"foo": 2}]) pipeline = {"$project": {"_id": False, "foo": True}} - result = db.test.aggregate([pipeline]) + result = db.coll.aggregate([pipeline]) self.assertEqual(len(result.to_list()), 2) - result = db.test.aggregate([pipeline]) + result = db.coll.aggregate([pipeline]) self.assertEqual(len(result.to_list(1)), 1) @client_context.require_failCommand_blockConnection @@ -1511,10 +1511,10 @@ def test_command_cursor_to_list_csot_applied(self): class TestRawBatchCursor(IntegrationTest): def setUp(self): super().setUp() - self.db.test.drop() + self.db.coll.drop() def test_find_raw(self): - c = self.db.test + c = self.db.coll docs = [{"_id": i, "x": 3.0 * i} for i in range(10)] c.insert_many(docs) batches = c.find_raw_batches().sort("_id").to_list() @@ -1523,7 +1523,7 @@ def test_find_raw(self): @client_context.require_transactions def test_find_raw_transaction(self): - c = self.db.test + c = self.db.coll docs = [{"_id": i, "x": 3.0 * i} for i in range(10)] c.insert_many(docs) @@ -1552,7 +1552,7 @@ def test_find_raw_transaction(self): @client_context.require_sessions @client_context.require_failCommand_fail_point def test_find_raw_retryable_reads(self): - c = self.db.test + c = self.db.coll docs = [{"_id": i, "x": 3.0 * i} for i in range(10)] c.insert_many(docs) @@ -1572,7 +1572,7 @@ def test_find_raw_retryable_reads(self): @client_context.require_version_min(5, 0, 0) @client_context.require_no_standalone def test_find_raw_snapshot_reads(self): - c = self.db.get_collection("test", write_concern=WriteConcern(w="majority")) + c = self.db.get_collection("coll", write_concern=WriteConcern(w="majority")) docs = [{"_id": i, "x": 3.0 * i} for i in range(10)] c.insert_many(docs) @@ -1580,8 +1580,8 @@ def test_find_raw_snapshot_reads(self): client = self.rs_or_single_client(event_listeners=[listener], retryReads=True) db = client[self.db.name] with client.start_session(snapshot=True) as session: - db.test.distinct("x", {}, session=session) - batches = db.test.find_raw_batches(session=session).sort("_id").to_list() + db.coll.distinct("x", {}, session=session) + batches = db.coll.find_raw_batches(session=session).sort("_id").to_list() self.assertEqual(1, len(batches)) self.assertEqual(docs, decode_all(batches[0])) @@ -1590,53 +1590,53 @@ def test_find_raw_snapshot_reads(self): self.assertIsNotNone(find_cmd["readConcern"]["atClusterTime"]) def test_explain(self): - c = self.db.test + c = self.db.coll explanation = c.find_raw_batches().explain() self.assertIsInstance(explanation, dict) def test_empty(self): - cursor = self.db.test.find_raw_batches() + cursor = self.db.coll.find_raw_batches() with self.assertRaises(StopIteration): next(cursor) def test_clone(self): - self.db.test.insert_one({}) - cursor = self.db.test.find_raw_batches() + self.db.coll.insert_one({}) + cursor = self.db.coll.find_raw_batches() # Copy of a RawBatchCursor is also a RawBatchCursor, not a Cursor. self.assertIsInstance(next(cursor.clone()), bytes) self.assertIsInstance(next(copy.copy(cursor)), bytes) @client_context.require_no_mongos def test_exhaust(self): - c = self.db.test + c = self.db.coll c.insert_many({"_id": i} for i in range(200)) result = b"".join(c.find_raw_batches(cursor_type=CursorType.EXHAUST).to_list()) self.assertEqual([{"_id": i} for i in range(200)], decode_all(result)) def test_server_error(self): with self.assertRaises(OperationFailure) as exc: - next(self.db.test.find_raw_batches({"x": {"$bad": 1}})) + next(self.db.coll.find_raw_batches({"x": {"$bad": 1}})) # The server response was decoded, not left raw. self.assertIsInstance(exc.exception.details, dict) def test_get_item(self): with self.assertRaises(InvalidOperation): - self.db.test.find_raw_batches()[0] + self.db.coll.find_raw_batches()[0] def test_collation(self): - self.db.test.insert_one({}) - next(self.db.test.find_raw_batches(collation=Collation("en_US"))) + self.db.coll.insert_one({}) + next(self.db.coll.find_raw_batches(collation=Collation("en_US"))) def test_read_concern(self): - self.db.get_collection("test", write_concern=WriteConcern(w="majority")).insert_one({}) - c = self.db.get_collection("test", read_concern=ReadConcern("majority")) + self.db.get_collection("coll", write_concern=WriteConcern(w="majority")).insert_one({}) + c = self.db.get_collection("coll", read_concern=ReadConcern("majority")) next(c.find_raw_batches()) def test_monitoring(self): listener = OvertCommandListener() client = self.rs_or_single_client(event_listeners=[listener]) - c = client.pymongo_test.test + c = client.db.coll c.insert_many([{"_id": i} for i in range(10)]) listener.reset() @@ -1649,10 +1649,10 @@ def test_monitoring(self): succeeded = listener.succeeded_events[0] self.assertEqual(0, len(listener.failed_events)) self.assertEqual("find", started.command_name) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertEqual("find", succeeded.command_name) csr = succeeded.reply["cursor"] - self.assertEqual(csr["ns"], "pymongo_test.test") + self.assertEqual(csr["ns"], "db.coll") # The batch is a list of one raw bytes object. self.assertEqual(len(csr["firstBatch"]), 1) @@ -1667,10 +1667,10 @@ def test_monitoring(self): succeeded = listener.succeeded_events[0] self.assertEqual(0, len(listener.failed_events)) self.assertEqual("getMore", started.command_name) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertEqual("getMore", succeeded.command_name) csr = succeeded.reply["cursor"] - self.assertEqual(csr["ns"], "pymongo_test.test") + self.assertEqual(csr["ns"], "db.coll") self.assertEqual(len(csr["nextBatch"]), 1) self.assertEqual(decode_all(csr["nextBatch"][0]), [{"_id": i} for i in range(4, 8)]) finally: @@ -1680,7 +1680,7 @@ def test_monitoring(self): class TestRawBatchCommandCursor(IntegrationTest): def test_aggregate_raw(self): - c = self.db.test + c = self.db.coll c.drop() docs = [{"_id": i, "x": 3.0 * i} for i in range(10)] c.insert_many(docs) @@ -1690,7 +1690,7 @@ def test_aggregate_raw(self): @client_context.require_transactions def test_aggregate_raw_transaction(self): - c = self.db.test + c = self.db.coll c.drop() docs = [{"_id": i, "x": 3.0 * i} for i in range(10)] c.insert_many(docs) @@ -1721,7 +1721,7 @@ def test_aggregate_raw_transaction(self): @client_context.require_sessions @client_context.require_failCommand_fail_point def test_aggregate_raw_retryable_reads(self): - c = self.db.test + c = self.db.coll c.drop() docs = [{"_id": i, "x": 3.0 * i} for i in range(10)] c.insert_many(docs) @@ -1745,7 +1745,7 @@ def test_aggregate_raw_retryable_reads(self): @client_context.require_version_min(5, 0, -1) @client_context.require_no_standalone def test_aggregate_raw_snapshot_reads(self): - c = self.db.get_collection("test", write_concern=WriteConcern(w="majority")) + c = self.db.get_collection("coll", write_concern=WriteConcern(w="majority")) c.drop() docs = [{"_id": i, "x": 3.0 * i} for i in range(10)] c.insert_many(docs) @@ -1754,9 +1754,9 @@ def test_aggregate_raw_snapshot_reads(self): client = self.rs_or_single_client(event_listeners=[listener], retryReads=True) db = client[self.db.name] with client.start_session(snapshot=True) as session: - db.test.distinct("x", {}, session=session) + db.coll.distinct("x", {}, session=session) batches = ( - db.test.aggregate_raw_batches([{"$sort": {"_id": 1}}], session=session) + db.coll.aggregate_raw_batches([{"$sort": {"_id": 1}}], session=session) ).to_list() self.assertEqual(1, len(batches)) self.assertEqual(docs, decode_all(batches[0])) @@ -1766,7 +1766,7 @@ def test_aggregate_raw_snapshot_reads(self): self.assertIsNotNone(find_cmd["readConcern"]["atClusterTime"]) def test_server_error(self): - c = self.db.test + c = self.db.coll c.drop() docs = [{"_id": i, "x": 3.0 * i} for i in range(10)] c.insert_many(docs) @@ -1774,7 +1774,7 @@ def test_server_error(self): with self.assertRaises(OperationFailure) as exc: ( - self.db.test.aggregate_raw_batches( + self.db.coll.aggregate_raw_batches( [ { "$sort": {"_id": 1}, @@ -1790,15 +1790,15 @@ def test_server_error(self): def test_get_item(self): with self.assertRaises(InvalidOperation): - (self.db.test.aggregate_raw_batches([]))[0] + (self.db.coll.aggregate_raw_batches([]))[0] def test_collation(self): - next(self.db.test.aggregate_raw_batches([], collation=Collation("en_US"))) + next(self.db.coll.aggregate_raw_batches([], collation=Collation("en_US"))) def test_monitoring(self): listener = OvertCommandListener() client = self.rs_or_single_client(event_listeners=[listener]) - c = client.pymongo_test.test + c = client.db.coll c.drop() c.insert_many([{"_id": i} for i in range(10)]) @@ -1810,10 +1810,10 @@ def test_monitoring(self): succeeded = listener.succeeded_events[0] self.assertEqual(0, len(listener.failed_events)) self.assertEqual("aggregate", started.command_name) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertEqual("aggregate", succeeded.command_name) csr = succeeded.reply["cursor"] - self.assertEqual(csr["ns"], "pymongo_test.test") + self.assertEqual(csr["ns"], "db.coll") # First batch is empty. self.assertEqual(len(csr["firstBatch"]), 0) @@ -1826,10 +1826,10 @@ def test_monitoring(self): succeeded = listener.succeeded_events[0] self.assertEqual(0, len(listener.failed_events)) self.assertEqual("getMore", started.command_name) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertEqual("getMore", succeeded.command_name) csr = succeeded.reply["cursor"] - self.assertEqual(csr["ns"], "pymongo_test.test") + self.assertEqual(csr["ns"], "db.coll") self.assertEqual(len(csr["nextBatch"]), 1) self.assertEqual(csr["nextBatch"][0], batch) self.assertEqual(decode_all(batch), [{"_id": i} for i in range(n, min(n + 4, 10))]) @@ -1843,7 +1843,7 @@ def test_monitoring(self): def test_exhaust_cursor_db_set(self): listener = OvertCommandListener() client = self.rs_or_single_client(event_listeners=[listener]) - c = client.pymongo_test.test + c = client.db.coll c.delete_many({}) c.insert_many([{"_id": i} for i in range(3)]) @@ -1857,7 +1857,7 @@ def test_exhaust_cursor_db_set(self): listener.started_command_names(), ["find", "getMore", "getMore", "getMore"] ) for cmd in listener.started_events: - self.assertEqual(cmd.command["$db"], "pymongo_test") + self.assertEqual(cmd.command["$db"], "db") if __name__ == "__main__": diff --git a/test/test_custom_types.py b/test/test_custom_types.py index aba6b55119..543c416632 100644 --- a/test/test_custom_types.py +++ b/test/test_custom_types.py @@ -625,15 +625,15 @@ class MyType(pytype): # type: ignore class TestCollectionWCustomType(IntegrationTest): def setUp(self): super().setUp() - self.db.test.drop() + self.db.coll.drop() def tearDown(self): - self.db.test.drop() + self.db.coll.drop() def test_overflow_int_w_custom_decoder(self): type_registry = TypeRegistry(fallback_encoder=lambda val: str(val)) codec_options = CodecOptions(type_registry=type_registry) - collection = self.db.get_collection("test", codec_options=codec_options) + collection = self.db.get_collection("coll", codec_options=codec_options) collection.insert_one({"_id": 1, "data": 2**520}) ret = collection.find_one() @@ -642,7 +642,7 @@ def test_overflow_int_w_custom_decoder(self): def test_command_errors_w_custom_type_decoder(self): db = self.db test_doc = {"_id": 1, "data": "a"} - test = db.get_collection("test", codec_options=UNINT_DECODER_CODECOPTS) + test = db.get_collection("coll", codec_options=UNINT_DECODER_CODECOPTS) result = test.insert_one(test_doc) self.assertEqual(result.inserted_id, test_doc["_id"]) @@ -653,9 +653,9 @@ def test_find_w_custom_type_decoder(self): db = self.db input_docs = [{"x": Int64(k)} for k in [1, 2, 3]] for doc in input_docs: - db.test.insert_one(doc) + db.coll.insert_one(doc) - test = db.get_collection("test", codec_options=UNINT_DECODER_CODECOPTS) + test = db.get_collection("coll", codec_options=UNINT_DECODER_CODECOPTS) for doc in test.find({}, batch_size=1): self.assertIsInstance(doc["x"], UndecipherableInt64Type) @@ -664,10 +664,10 @@ def run_test(doc_cls): db = self.db input_docs = [{"x": Int64(k)} for k in [1, 2, 3]] for doc in input_docs: - db.test.insert_one(doc) + db.coll.insert_one(doc) test = db.get_collection( - "test", + "coll", codec_options=CodecOptions( type_registry=TypeRegistry([UndecipherableIntDecoder()]), document_class=doc_cls ), @@ -681,7 +681,7 @@ def run_test(doc_cls): def test_aggregate_w_custom_type_decoder(self): db = self.db - db.test.insert_many( + db.coll.insert_many( [ {"status": "in progress", "qty": Int64(1)}, {"status": "complete", "qty": Int64(10)}, @@ -690,7 +690,7 @@ def test_aggregate_w_custom_type_decoder(self): {"status": "in progress", "qty": Int64(1)}, ] ) - test = db.get_collection("test", codec_options=UNINT_DECODER_CODECOPTS) + test = db.get_collection("coll", codec_options=UNINT_DECODER_CODECOPTS) pipeline: list = [ {"$match": {"status": "complete"}}, @@ -704,9 +704,9 @@ def test_aggregate_w_custom_type_decoder(self): self.assertEqual(res["total_qty"].value, 20) def test_distinct_w_custom_type(self): - self.db.drop_collection("test") + self.db.drop_collection("coll") - test = self.db.get_collection("test", codec_options=UNINT_CODECOPTS) + test = self.db.get_collection("coll", codec_options=UNINT_CODECOPTS) values = [ UndecipherableInt64Type(1), UndecipherableInt64Type(2), @@ -719,7 +719,7 @@ def test_distinct_w_custom_type(self): def test_find_one_and__w_custom_type_decoder(self): db = self.db - c = db.get_collection("test", codec_options=UNINT_DECODER_CODECOPTS) + c = db.get_collection("coll", codec_options=UNINT_DECODER_CODECOPTS) c.insert_one({"_id": 1, "x": Int64(1)}) doc = c.find_one_and_update( @@ -866,7 +866,7 @@ def test_break_resume_token(self): # Get one document from a change stream to determine resumeToken type. self.create_targets() change_stream = self.change_stream() - self.input_target.insert_one({"data": "test"}) + self.input_target.insert_one({"data": "coll"}) change = next(change_stream) resume_token_decoder = type_obfuscating_decoder_factory(type(change["_id"]["_data"])) @@ -914,13 +914,13 @@ class TestCollectionChangeStreamsWCustomTypes(IntegrationTest, ChangeStreamsWCus @client_context.require_change_streams def setUp(self): super().setUp() - self.db.test.delete_many({}) + self.db.coll.delete_many({}) def tearDown(self): self.input_target.drop() def create_targets(self, *args, **kwargs): - self.watched_target = self.db.get_collection("test", *args, **kwargs) + self.watched_target = self.db.get_collection("coll", *args, **kwargs) self.input_target = self.watched_target # Ensure the collection exists and is empty. self.input_target.insert_one({}) @@ -932,7 +932,7 @@ class TestDatabaseChangeStreamsWCustomTypes(IntegrationTest, ChangeStreamsWCusto @client_context.require_change_streams def setUp(self): super().setUp() - self.db.test.delete_many({}) + self.db.coll.delete_many({}) def tearDown(self): self.input_target.drop() @@ -940,7 +940,7 @@ def tearDown(self): def create_targets(self, *args, **kwargs): self.watched_target = self.client.get_database(self.db.name, *args, **kwargs) - self.input_target = self.watched_target.test + self.input_target = self.watched_target.coll # Insert a record to ensure db, coll are created. self.input_target.insert_one({"data": "dummy"}) @@ -950,7 +950,7 @@ class TestClusterChangeStreamsWCustomTypes(IntegrationTest, ChangeStreamsWCustom @client_context.require_change_streams def setUp(self): super().setUp() - self.db.test.delete_many({}) + self.db.coll.delete_many({}) def tearDown(self): self.input_target.drop() @@ -962,7 +962,7 @@ def create_targets(self, *args, **kwargs): kwargs["type_registry"] = codec_options.type_registry kwargs["document_class"] = codec_options.document_class self.watched_target = self.rs_client(*args, **kwargs) - self.input_target = self.watched_target[self.db.name].test + self.input_target = self.watched_target[self.db.name].coll # Insert a record to ensure db, coll are created. self.input_target.insert_one({"data": "dummy"}) diff --git a/test/test_database.py b/test/test_database.py index 2f6c312f50..6c9cfe7afa 100644 --- a/test/test_database.py +++ b/test/test_database.py @@ -79,7 +79,7 @@ def test_get_collection(self): codec_options = CodecOptions(tz_aware=True) write_concern = WriteConcern(w=2, j=True) read_concern = ReadConcern("majority") - coll = self.client.pymongo_test.get_collection( + coll = self.client.db.get_collection( "foo", codec_options, ReadPreference.SECONDARY, write_concern, read_concern ) self.assertEqual("foo", coll.name) @@ -89,7 +89,7 @@ def test_get_collection(self): self.assertEqual(read_concern, coll.read_concern) def test_getattr(self): - db = self.client.pymongo_test + db = self.client.db self.assertIsInstance(db["_does_not_exist"], Collection) with self.assertRaises(AttributeError) as context: @@ -101,7 +101,7 @@ def test_getattr(self): self.assertIn("has no attribute '_does_not_exist'", str(context.exception)) def test_iteration(self): - db = self.client.pymongo_test + db = self.client.db msg = "'Database' object is not iterable" # Iteration fails with self.assertRaisesRegex(TypeError, msg): @@ -132,27 +132,27 @@ def test_hashable(self): self.assertIn(self.client.test, {Database(self.client, "test")}) def test_get_coll(self): - db = Database(self.client, "pymongo_test") - self.assertEqual(db.test, db["test"]) - self.assertEqual(db.test, Collection(db, "test")) - self.assertNotEqual(db.test, Collection(db, "mike")) - self.assertEqual(db.test.mike, db["test.mike"]) + db = Database(self.client, "db") + self.assertEqual(db.coll, db["test"]) + self.assertEqual(db.coll, Collection(db, "test")) + self.assertNotEqual(db.coll, Collection(db, "mike")) + self.assertEqual(db.coll.mike, db["test.mike"]) def test_repr(self): name = "Database" self.assertEqual( - repr(Database(self.client, "pymongo_test")), - "{}({!r}, {})".format(name, self.client, repr("pymongo_test")), + repr(Database(self.client, "db")), + "{}({!r}, {})".format(name, self.client, repr("db")), ) def test_create_collection(self): - db = Database(self.client, "pymongo_test") + db = Database(self.client, "db") - db.test.insert_one({"hello": "world"}) + db.coll.insert_one({"hello": "world"}) with self.assertRaises(CollectionInvalid): - db.create_collection("test") + db.create_collection("coll") - db.drop_collection("test") + db.drop_collection("coll") with self.assertRaises(TypeError): db.create_collection(5) # type: ignore[arg-type] @@ -161,10 +161,10 @@ def test_create_collection(self): with self.assertRaises(InvalidName): db.create_collection("coll..ection") # type: ignore[arg-type] - test = db.create_collection("test") + test = db.create_collection("coll") self.assertIn("test", db.list_collection_names()) test.insert_one({"hello": "world"}) - self.assertEqual((db.test.find_one())["hello"], "world") + self.assertEqual((db.coll.find_one())["hello"], "world") db.drop_collection("test.foo") db.create_collection("test.foo") @@ -173,9 +173,9 @@ def test_create_collection(self): db.create_collection("test.foo") def test_list_collection_names(self): - db = Database(self.client, "pymongo_test") - db.test.insert_one({"dummy": "object"}) - db.test.mike.insert_one({"dummy": "object"}) + db = Database(self.client, "db") + db.coll.insert_one({"dummy": "object"}) + db.coll.mike.insert_one({"dummy": "object"}) colls = db.list_collection_names() self.assertIn("test", colls) @@ -242,10 +242,10 @@ def test_check_exists(self): self.assertNotIn("listCollections", listener.started_command_names()) def test_list_collections(self): - self.client.drop_database("pymongo_test") - db = Database(self.client, "pymongo_test") - db.test.insert_one({"dummy": "object"}) - db.test.mike.insert_one({"dummy": "object"}) + self.client.drop_database("db") + db = Database(self.client, "db") + db.coll.insert_one({"dummy": "object"}) + db.coll.mike.insert_one({"dummy": "object"}) results = db.list_collections() colls = [result["name"] for result in results] @@ -278,9 +278,9 @@ def test_list_collections(self): colls = (db.list_collections(filter={"name": {"$regex": "^test.mike$"}})).to_list() self.assertEqual(1, len(colls)) - db.drop_collection("test") + db.drop_collection("coll") - db.create_collection("test", capped=True, size=4096) + db.create_collection("coll", capped=True, size=4096) results = db.list_collections(filter={"options.capped": True}) colls = [result["name"] for result in results] @@ -306,7 +306,7 @@ def test_list_collections(self): # Check if there are any collections which don't exist. self.assertLessEqual(set(colls), {"test", "system.indexes"}) - self.client.drop_database("pymongo_test") + self.client.drop_database("db") def test_list_collection_names_single_socket(self): client = self.rs_or_single_client(maxPoolSize=1) @@ -319,69 +319,69 @@ def test_list_collection_names_single_socket(self): client.drop_database("test_collection_names_single_socket") def test_drop_collection(self): - db = Database(self.client, "pymongo_test") + db = Database(self.client, "db") with self.assertRaises(TypeError): db.drop_collection(5) # type: ignore[arg-type] with self.assertRaises(TypeError): db.drop_collection(None) # type: ignore[arg-type] - db.test.insert_one({"dummy": "object"}) + db.coll.insert_one({"dummy": "object"}) self.assertIn("test", db.list_collection_names()) - db.drop_collection("test") + db.drop_collection("coll") self.assertNotIn("test", db.list_collection_names()) - db.test.insert_one({"dummy": "object"}) + db.coll.insert_one({"dummy": "object"}) self.assertIn("test", db.list_collection_names()) - db.drop_collection("test") + db.drop_collection("coll") self.assertNotIn("test", db.list_collection_names()) - db.test.insert_one({"dummy": "object"}) + db.coll.insert_one({"dummy": "object"}) self.assertIn("test", db.list_collection_names()) - db.drop_collection(db.test) + db.drop_collection(db.coll) self.assertNotIn("test", db.list_collection_names()) - db.test.insert_one({"dummy": "object"}) + db.coll.insert_one({"dummy": "object"}) self.assertIn("test", db.list_collection_names()) - db.test.drop() + db.coll.drop() self.assertNotIn("test", db.list_collection_names()) - db.test.drop() + db.coll.drop() - db.drop_collection(db.test.doesnotexist) + db.drop_collection(db.coll.doesnotexist) if client_context.is_rs: - db_wc = Database(self.client, "pymongo_test", write_concern=IMPOSSIBLE_WRITE_CONCERN) + db_wc = Database(self.client, "db", write_concern=IMPOSSIBLE_WRITE_CONCERN) with self.assertRaises(WriteConcernError): - db_wc.drop_collection("test") + db_wc.drop_collection("coll") def test_validate_collection(self): - db = self.client.pymongo_test + db = self.client.db with self.assertRaises(TypeError): db.validate_collection(5) # type: ignore[arg-type] with self.assertRaises(TypeError): db.validate_collection(None) # type: ignore[arg-type] - db.test.insert_one({"dummy": "object"}) + db.coll.insert_one({"dummy": "object"}) with self.assertRaises(OperationFailure): db.validate_collection("test.doesnotexist") with self.assertRaises(OperationFailure): - db.validate_collection(db.test.doesnotexist) + db.validate_collection(db.coll.doesnotexist) - self.assertTrue(db.validate_collection("test")) - self.assertTrue(db.validate_collection(db.test)) - self.assertTrue(db.validate_collection(db.test, full=True)) - self.assertTrue(db.validate_collection(db.test, scandata=True)) - self.assertTrue(db.validate_collection(db.test, scandata=True, full=True)) - self.assertTrue(db.validate_collection(db.test, True, True)) + self.assertTrue(db.validate_collection("coll")) + self.assertTrue(db.validate_collection(db.coll)) + self.assertTrue(db.validate_collection(db.coll, full=True)) + self.assertTrue(db.validate_collection(db.coll, scandata=True)) + self.assertTrue(db.validate_collection(db.coll, scandata=True, full=True)) + self.assertTrue(db.validate_collection(db.coll, True, True)) @client_context.require_version_min(4, 3, 3) @client_context.require_no_standalone def test_validate_collection_background(self): - db = self.client.pymongo_test.with_options(write_concern=WriteConcern(w="majority")) - db.test.insert_one({"dummy": "object"}) - coll = db.test + db = self.client.db.with_options(write_concern=WriteConcern(w="majority")) + db.coll.insert_one({"dummy": "object"}) + coll = db.coll self.assertTrue(db.validate_collection(coll, background=False)) # The inMemory storage engine does not support background=True. if client_context.storage_engine != "inMemory": @@ -407,10 +407,10 @@ def test_command(self): # We use 'aggregate' as our example command, since it's an easy way to # retrieve a BSON regex from a collection using a command. def test_command_with_regex(self): - db = self.client.pymongo_test - db.test.drop() - db.test.insert_one({"r": re.compile(".*")}) - db.test.insert_one({"r": Regex(".*")}) + db = self.client.db + db.coll.drop() + db.coll.insert_one({"r": re.compile(".*")}) + db.coll.insert_one({"r": Regex(".*")}) result = db.command("aggregate", "test", pipeline=[], cursor={}) for doc in result["cursor"]["firstBatch"]: @@ -422,21 +422,21 @@ def test_command_bulkWrite(self): self.client.admin.command( { "bulkWrite": 1, - "nsInfo": [{"ns": self.db.test.full_name}], + "nsInfo": [{"ns": self.db.coll.full_name}], "ops": [{"insert": 0, "document": {}}], } ) self.db.command({"insert": "test", "documents": [{}]}) self.db.command({"update": "test", "updates": [{"q": {}, "u": {"$set": {"x": 1}}}]}) self.db.command({"delete": "test", "deletes": [{"q": {}, "limit": 1}]}) - self.db.test.drop() + self.db.coll.drop() def test_cursor_command(self): - db = self.client.pymongo_test - db.test.drop() + db = self.client.db + db.coll.drop() docs = [{"_id": i, "doc": i} for i in range(3)] - db.test.insert_many(docs) + db.coll.insert_many(docs) cursor = db.cursor_command("find", "test") @@ -473,22 +473,22 @@ def test_id_ordering(self): # guarantee any particular order. This will never # work right in any Python or environment # with hash randomization enabled (e.g. tox). - db = self.client.pymongo_test - db.test.drop() - db.test.insert_one(SON([("hello", "world"), ("_id", 5)])) + db = self.client.db + db.coll.drop() + db.coll.insert_one(SON([("hello", "world"), ("_id", 5)])) db = self.client.get_database( - "pymongo_test", codec_options=CodecOptions(document_class=SON[str, Any]) + "db", codec_options=CodecOptions(document_class=SON[str, Any]) ) - cursor = db.test.find() + cursor = db.coll.find() for x in cursor: for k, _v in x.items(): self.assertEqual(k, "_id") break def test_deref(self): - db = self.client.pymongo_test - db.test.drop() + db = self.client.db + db.coll.drop() with self.assertRaises(TypeError): db.dereference(5) # type: ignore[arg-type] @@ -499,24 +499,24 @@ def test_deref(self): self.assertEqual(None, db.dereference(DBRef("test", ObjectId()))) obj: dict[str, Any] = {"x": True} - key = (db.test.insert_one(obj)).inserted_id + key = (db.coll.insert_one(obj)).inserted_id self.assertEqual(obj, db.dereference(DBRef("test", key))) - self.assertEqual(obj, db.dereference(DBRef("test", key, "pymongo_test"))) + self.assertEqual(obj, db.dereference(DBRef("test", key, "db"))) with self.assertRaises(ValueError): db.dereference(DBRef("test", key, "foo")) self.assertEqual(None, db.dereference(DBRef("test", 4))) obj = {"_id": 4} - db.test.insert_one(obj) + db.coll.insert_one(obj) self.assertEqual(obj, db.dereference(DBRef("test", 4))) def test_deref_kwargs(self): - db = self.client.pymongo_test - db.test.drop() + db = self.client.db + db.coll.drop() - db.test.insert_one({"_id": 4, "foo": "bar"}) + db.coll.insert_one({"_id": 4, "foo": "bar"}) db = self.client.get_database( - "pymongo_test", codec_options=CodecOptions(document_class=SON[str, Any]) + "db", codec_options=CodecOptions(document_class=SON[str, Any]) ) self.assertEqual( SON([("foo", "bar")]), db.dereference(DBRef("test", 4), projection={"_id": False}) @@ -524,79 +524,79 @@ def test_deref_kwargs(self): # TODO some of these tests belong in the collection level testing. def test_insert_find_one(self): - db = self.client.pymongo_test - db.test.drop() + db = self.client.db + db.coll.drop() a_doc = SON({"hello": "world"}) - a_key = (db.test.insert_one(a_doc)).inserted_id + a_key = (db.coll.insert_one(a_doc)).inserted_id self.assertIsInstance(a_doc["_id"], ObjectId) self.assertEqual(a_doc["_id"], a_key) - self.assertEqual(a_doc, db.test.find_one({"_id": a_doc["_id"]})) - self.assertEqual(a_doc, db.test.find_one(a_key)) - self.assertEqual(None, db.test.find_one(ObjectId())) - self.assertEqual(a_doc, db.test.find_one({"hello": "world"})) - self.assertEqual(None, db.test.find_one({"hello": "test"})) + self.assertEqual(a_doc, db.coll.find_one({"_id": a_doc["_id"]})) + self.assertEqual(a_doc, db.coll.find_one(a_key)) + self.assertEqual(None, db.coll.find_one(ObjectId())) + self.assertEqual(a_doc, db.coll.find_one({"hello": "world"})) + self.assertEqual(None, db.coll.find_one({"hello": "test"})) - b = db.test.find_one() + b = db.coll.find_one() assert b is not None b["hello"] = "mike" - db.test.replace_one({"_id": b["_id"]}, b) + db.coll.replace_one({"_id": b["_id"]}, b) - self.assertNotEqual(a_doc, db.test.find_one(a_key)) - self.assertEqual(b, db.test.find_one(a_key)) - self.assertEqual(b, db.test.find_one()) + self.assertNotEqual(a_doc, db.coll.find_one(a_key)) + self.assertEqual(b, db.coll.find_one(a_key)) + self.assertEqual(b, db.coll.find_one()) count = 0 - for _ in db.test.find(): + for _ in db.coll.find(): count += 1 self.assertEqual(count, 1) def test_long(self): - db = self.client.pymongo_test - db.test.drop() - db.test.insert_one({"x": 9223372036854775807}) - retrieved = (db.test.find_one())["x"] + db = self.client.db + db.coll.drop() + db.coll.insert_one({"x": 9223372036854775807}) + retrieved = (db.coll.find_one())["x"] self.assertEqual(Int64(9223372036854775807), retrieved) self.assertIsInstance(retrieved, Int64) - db.test.delete_many({}) - db.test.insert_one({"x": Int64(1)}) - retrieved = (db.test.find_one())["x"] + db.coll.delete_many({}) + db.coll.insert_one({"x": Int64(1)}) + retrieved = (db.coll.find_one())["x"] self.assertEqual(Int64(1), retrieved) self.assertIsInstance(retrieved, Int64) def test_delete(self): - db = self.client.pymongo_test - db.test.drop() + db = self.client.db + db.coll.drop() - db.test.insert_one({"x": 1}) - db.test.insert_one({"x": 2}) - db.test.insert_one({"x": 3}) + db.coll.insert_one({"x": 1}) + db.coll.insert_one({"x": 2}) + db.coll.insert_one({"x": 3}) length = 0 - for _ in db.test.find(): + for _ in db.coll.find(): length += 1 self.assertEqual(length, 3) - db.test.delete_one({"x": 1}) + db.coll.delete_one({"x": 1}) length = 0 - for _ in db.test.find(): + for _ in db.coll.find(): length += 1 self.assertEqual(length, 2) - db.test.delete_one(db.test.find_one()) # type: ignore[arg-type] - db.test.delete_one(db.test.find_one()) # type: ignore[arg-type] - self.assertEqual(db.test.find_one(), None) + db.coll.delete_one(db.coll.find_one()) # type: ignore[arg-type] + db.coll.delete_one(db.coll.find_one()) # type: ignore[arg-type] + self.assertEqual(db.coll.find_one(), None) - db.test.insert_one({"x": 1}) - db.test.insert_one({"x": 2}) - db.test.insert_one({"x": 3}) + db.coll.insert_one({"x": 1}) + db.coll.insert_one({"x": 2}) + db.coll.insert_one({"x": 3}) - self.assertTrue(db.test.find_one({"x": 2})) - db.test.delete_one({"x": 2}) - self.assertFalse(db.test.find_one({"x": 2})) + self.assertTrue(db.coll.find_one({"x": 2})) + db.coll.delete_one({"x": 2}) + self.assertFalse(db.coll.find_one({"x": 2})) - self.assertTrue(db.test.find_one()) - db.test.delete_many({}) - self.assertFalse(db.test.find_one()) + self.assertTrue(db.coll.find_one()) + db.coll.delete_many({}) + self.assertFalse(db.coll.find_one()) def test_command_response_without_ok(self): # Sometimes (SERVER-10891) the server's response to a badly-formatted @@ -617,7 +617,7 @@ def test_command_response_without_ok(self): def test_command_max_time_ms(self): self.client.admin.command("configureFailPoint", "maxTimeAlwaysTimeOut", mode="alwaysOn") try: - db = self.client.pymongo_test + db = self.client.db db.command("count", "test") with self.assertRaises(ExecutionTimeout): db.command("count", "test", maxTimeMS=1) @@ -633,9 +633,9 @@ def test_command_max_time_ms(self): maxTimeMS=1, ) # Collection helper. - db.test.aggregate(pipeline=pipeline) + db.coll.aggregate(pipeline=pipeline) with self.assertRaises(ExecutionTimeout): - db.test.aggregate(pipeline, maxTimeMS=1) + db.coll.aggregate(pipeline, maxTimeMS=1) finally: self.client.admin.command("configureFailPoint", "maxTimeAlwaysTimeOut", mode="off") @@ -707,7 +707,7 @@ def test_database_aggregation_fake_cursor(self): else: # SERVER-43287 disallows writing with $out to the admin db, use # $merge instead. - db_name = "pymongo_test" + db_name = "db" write_stage = {"$merge": {"into": {"db": db_name, "coll": coll_name}}} output_coll = self.client[db_name][coll_name] output_coll.drop() diff --git a/test/test_decimal128.py b/test/test_decimal128.py index 46819dd587..b0a896c2f1 100644 --- a/test/test_decimal128.py +++ b/test/test_decimal128.py @@ -29,7 +29,7 @@ class TestDecimal128(unittest.TestCase): @client_context.require_connection def test_round_trip(self): - coll = client_context.client.pymongo_test.test + coll = client_context.client.db.coll coll.drop() dec128 = Decimal128.from_bid(b"\x00@cR\xbf\xc6\x01\x00\x00\x00\x00\x00\x00\x00\x1c0") diff --git a/test/test_discovery_and_monitoring.py b/test/test_discovery_and_monitoring.py index f3ba10fa39..8513771f87 100644 --- a/test/test_discovery_and_monitoring.py +++ b/test/test_discovery_and_monitoring.py @@ -331,7 +331,7 @@ def mock_command(*args, **kwargs): def insert_command(i): try: - client.test.command("insert", "test", documents=[{"i": i}]) + client.coll.command("insert", "coll", documents=[{"i": i}]) except AutoReconnect: pass @@ -402,7 +402,7 @@ def test_connection_close_does_not_block_other_operations(self): "pool initialized with 10 connections", ) - client.db.test.insert_one({"x": 1}) + client.db.coll.insert_one({"x": 1}) close_delay = 0.1 latencies = [] should_exit = [] @@ -410,7 +410,7 @@ def test_connection_close_does_not_block_other_operations(self): def run_task(): while True: start_time = time.monotonic() - client.db.test.find_one({}) + client.db.coll.find_one({}) elapsed = time.monotonic() - start_time latencies.append(elapsed) if should_exit: @@ -483,13 +483,13 @@ def teardown(): self.addCleanup(teardown) # Make sure the collection has at least one document. - client.test.test.delete_many({}) - client.test.test.insert_one({}) + client.db.coll.delete_many({}) + client.db.coll.insert_one({}) # Run a slow operation to tie up the connection. def target(): try: - client.test.test.find_one({"$where": delay(0.1)}) + client.db.coll.find_one({"$where": delay(0.1)}) except ConnectionFailure: pass diff --git a/test/test_encryption.py b/test/test_encryption.py index 7df9e7ac38..262a693729 100644 --- a/test/test_encryption.py +++ b/test/test_encryption.py @@ -316,7 +316,7 @@ def _test_auto_encrypt(self, opts): {"_id": 4, "ssn": "444"}, {"_id": 5, "ssn": "555"}, ] - encrypted_coll = client.pymongo_test.test + encrypted_coll = client.db.coll encrypted_coll.insert_one(docs[0]) encrypted_coll.insert_many(docs[1:3]) unack = encrypted_coll.with_options(write_concern=WriteConcern(w=0)) @@ -324,12 +324,12 @@ def _test_auto_encrypt(self, opts): unack.insert_many(docs[4:], ordered=False) def count_documents(): - return self.db.test.count_documents({}) == len(docs) + return self.db.coll.count_documents({}) == len(docs) wait_until(count_documents, "insert documents with w=0") # Database.command auto decrypts. - res = client.pymongo_test.command("find", "test", filter={"ssn": "000"}) + res = client.db.command("find", "test", filter={"ssn": "000"}) decrypted_docs = res["cursor"]["firstBatch"] self.assertEqual(decrypted_docs, [{"_id": 0, "ssn": "000"}]) @@ -354,7 +354,7 @@ def count_documents(): self.assertEqual(set(decrypted_ssns), {d["ssn"] for d in docs}) # Make sure the field is actually encrypted. - for encrypted_doc in self.db.test.find(): + for encrypted_doc in self.db.coll.find(): self.assertIsInstance(encrypted_doc["_id"], int) self.assertEncrypted(encrypted_doc["ssn"]) @@ -365,15 +365,15 @@ def count_documents(): def test_auto_encrypt(self): # Configure the encrypted field via jsonSchema. json_schema = json_data("custom", "schema.json") - create_with_schema(self.db.test, json_schema) - self.addCleanup(self.db.test.drop) + create_with_schema(self.db.coll, json_schema) + self.addCleanup(self.db.coll.drop) opts = AutoEncryptionOpts(KMS_PROVIDERS, "keyvault.datakeys") self._test_auto_encrypt(opts) def test_auto_encrypt_local_schema_map(self): # Configure the encrypted field via the local schema_map option. - schemas = {"pymongo_test.test": json_data("custom", "schema.json")} + schemas = {"db.coll": json_data("custom", "schema.json")} opts = AutoEncryptionOpts(KMS_PROVIDERS, "keyvault.datakeys", schema_map=schemas) self._test_auto_encrypt(opts) @@ -416,7 +416,7 @@ def test_upsert_uuid_standard_encrypt(self): client = self.rs_or_single_client(auto_encryption_opts=opts) options = CodecOptions(uuid_representation=UuidRepresentation.STANDARD) - encrypted_coll = client.pymongo_test.test + encrypted_coll = client.db.coll coll = encrypted_coll.with_options(codec_options=options) uuids = [uuid.uuid4() for _ in range(3)] result = coll.bulk_write( @@ -454,18 +454,18 @@ def test_raise_unsupported_error(self): client = self.rs_or_single_client(auto_encryption_opts=opts) msg = "find_raw_batches does not support auto encryption" with self.assertRaisesRegex(InvalidOperation, msg): - client.test.test.find_raw_batches({}) + client.db.coll.find_raw_batches({}) msg = "aggregate_raw_batches does not support auto encryption" with self.assertRaisesRegex(InvalidOperation, msg): - client.test.test.aggregate_raw_batches([]) + client.db.coll.aggregate_raw_batches([]) if client_context.is_mongos: msg = "Exhaust cursors are not supported by mongos" else: msg = "exhaust cursors do not support auto encryption" with self.assertRaisesRegex(InvalidOperation, msg): - next(client.test.test.find(cursor_type=CursorType.EXHAUST)) + next(client.db.coll.find(cursor_type=CursorType.EXHAUST)) class TestExplicitSimple(EncryptionIntegrationTest): @@ -3582,12 +3582,12 @@ def setUp(self) -> None: def test_implicit_session_ignored_when_unsupported(self): self.listener.reset() with self.assertRaises(OperationFailure): - self.mongocryptd_client.db.test.find_one() + self.mongocryptd_client.db.coll.find_one() self.assertNotIn("lsid", self.listener.started_events[0].command) with self.assertRaises(OperationFailure): - self.mongocryptd_client.db.test.insert_one({"x": 1}) + self.mongocryptd_client.db.coll.insert_one({"x": 1}) self.assertNotIn("lsid", self.listener.started_events[1].command) @@ -3599,11 +3599,11 @@ def test_explicit_session_errors_when_unsupported(self): with self.assertRaisesRegex( ConfigurationError, r"Sessions are not supported by this MongoDB deployment" ): - self.mongocryptd_client.db.test.find_one(session=s) + self.mongocryptd_client.db.coll.find_one(session=s) with self.assertRaisesRegex( ConfigurationError, r"Sessions are not supported by this MongoDB deployment" ): - self.mongocryptd_client.db.test.insert_one({"x": 1}, session=s) + self.mongocryptd_client.db.coll.insert_one({"x": 1}, session=s) self.mongocryptd_client.close() diff --git a/test/test_examples.py b/test/test_examples.py index 13f0c94c56..9f9ffabb3f 100644 --- a/test/test_examples.py +++ b/test/test_examples.py @@ -47,7 +47,7 @@ def setUp(self): def tearDown(self): # Run after every test. self.db.inventory.drop() - self.client.drop_database("pymongo_test") + self.client.drop_database("db") def test_first_three_examples(self): db = self.db @@ -923,11 +923,11 @@ def test_index_management(self): def test_misc(self): # Marketing examples client = self.client - self.addCleanup(client.drop_database, "test") - self.addCleanup(client.drop_database, "my_database") + self.addCleanup(client.drop_database, "db") + self.addCleanup(client.drop_database, "db2") # 2. Tunable consistency controls - collection = client.my_database.my_collection + collection = client.db2.coll with client.start_session() as session: collection.insert_one({"_id": 1}, session=session) collection.update_one({"_id": 1}, {"$set": {"a": 1}}, session=session) @@ -935,7 +935,7 @@ def test_misc(self): pass # 3. Exploiting the power of arrays - collection = client.test.array_updates_test + collection = client.db.array_updates_test collection.update_one({"_id": 1}, {"$set": {"a.$[i].b": 2}}, array_filters=[{"i.b": 0}]) @@ -1163,9 +1163,9 @@ class TestCausalConsistencyExamples(IntegrationTest): def test_causal_consistency(self): # Causal consistency examples client = self.client - self.addCleanup(client.drop_database, "test") - client.test.drop_collection("items") - client.test.items.insert_one( + self.addCleanup(client.drop_database, "db") + client.db.drop_collection("items") + client.db.items.insert_one( {"sku": "111", "name": "Peanuts", "start": datetime.datetime.today()} ) @@ -1173,7 +1173,7 @@ def test_causal_consistency(self): with client.start_session(causal_consistency=True) as s1: current_date = datetime.datetime.today() items = client.get_database( - "test", + "db", read_concern=ReadConcern("majority"), write_concern=WriteConcern("majority", wtimeout=1000), ).items @@ -1194,7 +1194,7 @@ def test_causal_consistency(self): s2.advance_operation_time(s1.operation_time) items = client.get_database( - "test", + "db", read_preference=ReadPreference.SECONDARY, read_concern=ReadConcern("majority"), write_concern=WriteConcern("majority", wtimeout=1000), diff --git a/test/test_grid_file.py b/test/test_grid_file.py index 6fe209f438..7d6b47e493 100644 --- a/test/test_grid_file.py +++ b/test/test_grid_file.py @@ -61,7 +61,7 @@ class TestGridFileNoConnect(UnitTest): @classmethod def setUpClass(cls): - cls.db = MongoClient(connect=False).pymongo_test + cls.db = MongoClient(connect=False).db def test_grid_in_custom_opts(self): self.assertRaises(TypeError, GridIn, "foo") @@ -802,7 +802,7 @@ def test_grid_in_lazy_connect(self): def test_unacknowledged(self): # w=0 is prohibited. with self.assertRaises(ConfigurationError): - GridIn((self.rs_or_single_client(w=0)).pymongo_test.fs) + GridIn((self.rs_or_single_client(w=0)).db.fs) def test_survive_cursor_not_found(self): # By default the find command returns 101 documents in the first batch. @@ -811,7 +811,7 @@ def test_survive_cursor_not_found(self): data = b"d" * (102 * chunk_size) listener = OvertCommandListener() client = self.rs_or_single_client(event_listeners=[listener]) - db = client.pymongo_test + db = client.db with GridIn(db.fs, chunk_size=chunk_size) as infile: infile.write(data) diff --git a/test/test_gridfs.py b/test/test_gridfs.py index 8bda041447..f4af001b57 100644 --- a/test/test_gridfs.py +++ b/test/test_gridfs.py @@ -82,7 +82,7 @@ class TestGridfsNoConnect(unittest.TestCase): def setUp(self): super().setUp() - self.db = MongoClient(connect=False).pymongo_test + self.db = MongoClient(connect=False).db def test_gridfs(self): self.assertRaises(TypeError, gridfs.GridFS, "foo") @@ -519,7 +519,7 @@ def test_grid_in_non_int_chunksize(self): def test_unacknowledged(self): # w=0 is prohibited. with self.assertRaises(ConfigurationError): - gridfs.GridFS((self.rs_or_single_client(w=0)).pymongo_test) + gridfs.GridFS((self.rs_or_single_client(w=0)).db) def test_md5(self): gin = self.fs.new_file() diff --git a/test/test_gridfs_bucket.py b/test/test_gridfs_bucket.py index 9dbb082ee9..ec3370a39d 100644 --- a/test/test_gridfs_bucket.py +++ b/test/test_gridfs_bucket.py @@ -411,7 +411,7 @@ def test_grid_in_non_int_chunksize(self): def test_unacknowledged(self): # w=0 is prohibited. with self.assertRaises(ConfigurationError): - gridfs.GridFSBucket((self.rs_or_single_client(w=0)).pymongo_test) + gridfs.GridFSBucket((self.rs_or_single_client(w=0)).db) def test_rename(self): _id = self.fs.upload_from_stream("first_name", b"testing") diff --git a/test/test_index_management.py b/test/test_index_management.py index 7451fb8833..eedd2a321c 100644 --- a/test/test_index_management.py +++ b/test/test_index_management.py @@ -47,7 +47,7 @@ class TestCreateSearchIndex(IntegrationTest): def test_inputs(self): listener = AllowListEventListener("createSearchIndexes") client = self.simple_client(event_listeners=[listener]) - coll = client.test.test + coll = client.db.coll coll.drop() definition = dict(mappings=dict(dynamic=True)) model_kwarg_list: list[Mapping[str, Any]] = [ diff --git a/test/test_json_util_integration.py b/test/test_json_util_integration.py index 4ef5f10fe2..7d36a3b4f0 100644 --- a/test/test_json_util_integration.py +++ b/test/test_json_util_integration.py @@ -13,7 +13,7 @@ class TestJsonUtilRoundtrip(IntegrationTest): def test_cursor(self): db = self.db - db.drop_collection("test") + db.drop_collection("coll") docs: List[MutableMapping[str, Any]] = [ {"foo": [1, 2]}, {"bar": {"hello": "world"}}, @@ -22,7 +22,7 @@ def test_cursor(self): {"dbref": {"_ref": DBRef("simple", ObjectId("509b8db456c02c5ab7e63c34"))}}, ] - db.test.insert_many(docs) - reloaded_docs = json_util.loads(json_util.dumps((db.test.find()).to_list())) + db.coll.insert_many(docs) + reloaded_docs = json_util.loads(json_util.dumps((db.coll.find()).to_list())) for doc in docs: self.assertIn(doc, reloaded_docs) diff --git a/test/test_load_balancer.py b/test/test_load_balancer.py index a4e09fce68..6134a78af1 100644 --- a/test/test_load_balancer.py +++ b/test/test_load_balancer.py @@ -52,12 +52,12 @@ class TestLB(IntegrationTest): def test_connections_are_only_returned_once(self): pool = get_pool(self.client) n_conns = len(pool.conns) - self.db.test.find_one({}) + self.db.coll.find_one({}) # On PyPy it can take a few rounds to collect the cursor. for _ in range(3): gc.collect() self.assertEqual(len(pool.conns), n_conns) - (self.db.test.aggregate([{"$limit": 1}])).to_list() + (self.db.coll.aggregate([{"$limit": 1}])).to_list() # On PyPy it can take a few rounds to collect the cursor. for _ in range(3): gc.collect() @@ -67,7 +67,7 @@ def test_connections_are_only_returned_once(self): def test_unpin_committed_transaction(self): client = self.rs_client() pool = get_pool(client) - coll = client[self.db.name].test + coll = client[self.db.name].coll with client.start_session() as session: with session.start_transaction(): self.assertEqual(pool.active_sockets, 0) @@ -97,7 +97,7 @@ def create_resource(coll): def _test_no_gc_deadlock(self, create_resource): client = self.rs_client() pool = get_pool(client) - coll = client[self.db.name].test + coll = client[self.db.name].coll coll.insert_many([{} for _ in range(10)]) self.assertEqual(pool.active_sockets, 0) # Cause the initial find attempt to fail to induce a reference cycle. @@ -137,7 +137,7 @@ def test_session_gc(self): pool = get_pool(client) session = client.start_session() session.start_transaction() - client.test_session_gc.test.find_one({}, session=session) + client.test_session_gc.coll.find_one({}, session=session) # Cleanup the transaction left open on the server self.addCleanup(self.client.admin.command, "killSessions", [session.session_id]) if client_context.load_balancer: @@ -159,7 +159,7 @@ def test_session_gc(self): wait_until(lambda: pool.active_sockets == 0, "return socket") # Run another operation to ensure the socket still works. - client[self.db.name].test.delete_many({}) + client[self.db.name].coll.delete_many({}) class PoolLocker(ExceptionCatchingTask): diff --git a/test/test_logger.py b/test/test_logger.py index a7d97927fa..8e996c8094 100644 --- a/test/test_logger.py +++ b/test/test_logger.py @@ -33,7 +33,7 @@ def test_default_truncation_limit(self): with patch.dict("os.environ"): os.environ.pop("MONGOB_LOG_MAX_DOCUMENT_LENGTH", None) with self.assertLogs("pymongo.command", level="DEBUG") as cm: - db.test.insert_many(docs) + db.coll.insert_many(docs) cmd_started_log = json_util.loads(cm.records[0].getMessage()) self.assertEqual(len(cmd_started_log["command"]), _DEFAULT_DOCUMENT_LENGTH + 3) @@ -42,7 +42,7 @@ def test_default_truncation_limit(self): self.assertLessEqual(len(cmd_succeeded_log["reply"]), _DEFAULT_DOCUMENT_LENGTH + 3) with self.assertLogs("pymongo.command", level="DEBUG") as cm: - db.test.find({}).to_list() + db.coll.find({}).to_list() cmd_succeeded_log = json_util.loads(cm.records[1].getMessage()) self.assertEqual(len(cmd_succeeded_log["reply"]), _DEFAULT_DOCUMENT_LENGTH + 3) @@ -75,7 +75,7 @@ def test_truncation_multi_byte_codepoints(self): for length in document_lengths: with patch.dict("os.environ", {"MONGOB_LOG_MAX_DOCUMENT_LENGTH": length}): with self.assertLogs("pymongo.command", level="DEBUG") as cm: - self.db.test.insert_one({"x": multi_byte_char_str}) + self.db.coll.insert_one({"x": multi_byte_char_str}) cmd_started_log = json_util.loads(cm.records[0].getMessage())["command"] cmd_started_log = cmd_started_log[:-3] @@ -87,18 +87,18 @@ def test_logging_without_listeners(self): c = self.single_client() self.assertEqual(len(c._event_listeners.event_listeners()), 0) with self.assertLogs("pymongo.connection", level="DEBUG") as cm: - c.db.test.insert_one({"x": "1"}) + c.db.coll.insert_one({"x": "1"}) self.assertGreater(len(cm.records), 0) with self.assertLogs("pymongo.command", level="DEBUG") as cm: - c.db.test.insert_one({"x": "1"}) + c.db.coll.insert_one({"x": "1"}) self.assertGreater(len(cm.records), 0) with self.assertLogs("pymongo.serverSelection", level="DEBUG") as cm: - c.db.test.insert_one({"x": "1"}) + c.db.coll.insert_one({"x": "1"}) self.assertGreater(len(cm.records), 0) @client_context.require_failCommand_fail_point def test_logging_retry_read_attempts(self): - self.db.test.insert_one({"x": "1"}) + self.db.coll.insert_one({"x": "1"}) with self.fail_point( { @@ -111,7 +111,7 @@ def test_logging_retry_read_attempts(self): } ): with self.assertLogs("pymongo.command", level="DEBUG") as cm: - self.db.test.find_one({"x": "1"}) + self.db.coll.find_one({"x": "1"}) retry_messages = [ r.getMessage() for r in cm.records if "Retrying read attempt" in r.getMessage() @@ -132,7 +132,7 @@ def test_logging_retry_write_attempts(self): } ): with self.assertLogs("pymongo.command", level="DEBUG") as cm: - self.db.test.insert_one({"x": "1"}) + self.db.coll.insert_one({"x": "1"}) retry_messages = [ r.getMessage() for r in cm.records if "Retrying write attempt" in r.getMessage() diff --git a/test/test_max_staleness.py b/test/test_max_staleness.py index 56e047fd4b..79b0d9076b 100644 --- a/test/test_max_staleness.py +++ b/test/test_max_staleness.py @@ -124,7 +124,7 @@ def test_max_staleness_zero(self): def test_last_write_date(self): # From max-staleness-tests.rst, "Parse lastWriteDate". client = self.rs_or_single_client(heartbeatFrequencyMS=500) - client.pymongo_test.test.insert_one({}) + client.db.coll.insert_one({}) # Wait for the server description to be updated. time.sleep(1) server = client._topology.select_server(writable_server_selector, _Op.TEST) @@ -133,7 +133,7 @@ def test_last_write_date(self): # The first last_write_date may correspond to a internal server write, # sleep so that the next write does not occur within the same second. time.sleep(1) - client.pymongo_test.test.insert_one({}) + client.db.coll.insert_one({}) # Wait for the server description to be updated. time.sleep(1) server = client._topology.select_server(writable_server_selector, _Op.TEST) diff --git a/test/test_monitoring.py b/test/test_monitoring.py index 7cb93adf81..c933b75c7b 100644 --- a/test/test_monitoring.py +++ b/test/test_monitoring.py @@ -62,7 +62,7 @@ def setUp(self) -> None: self.client = self.rs_or_single_client(event_listeners=[self.listener], retryWrites=False) def test_started_simple(self): - self.client.pymongo_test.command("ping") + self.client.db.command("ping") started = self.listener.started_events[0] succeeded = self.listener.succeeded_events[0] self.assertEqual(0, len(self.listener.failed_events)) @@ -71,11 +71,11 @@ def test_started_simple(self): self.assertEqualCommand(SON([("ping", 1)]), started.command) self.assertEqual("ping", started.command_name) self.assertEqual(self.client.address, started.connection_id) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertIsInstance(started.request_id, int) def test_succeeded_simple(self): - self.client.pymongo_test.command("ping") + self.client.db.command("ping") started = self.listener.started_events[0] succeeded = self.listener.succeeded_events[0] self.assertEqual(0, len(self.listener.failed_events)) @@ -89,7 +89,7 @@ def test_succeeded_simple(self): def test_failed_simple(self): try: - self.client.pymongo_test.command("oops!") + self.client.db.command("oops!") except OperationFailure: pass started = self.listener.started_events[0] @@ -104,7 +104,7 @@ def test_failed_simple(self): self.assertIsInstance(failed.duration_micros, int) def test_find_one(self): - self.client.pymongo_test.test.find_one() + self.client.db.coll.find_one() started = self.listener.started_events[0] succeeded = self.listener.succeeded_events[0] self.assertEqual(0, len(self.listener.failed_events)) @@ -116,14 +116,14 @@ def test_find_one(self): ) self.assertEqual("find", started.command_name) self.assertEqual(self.client.address, started.connection_id) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertIsInstance(started.request_id, int) def test_find_and_get_more(self): - self.client.pymongo_test.test.drop() - self.client.pymongo_test.test.insert_many([{} for _ in range(10)]) + self.client.db.coll.drop() + self.client.db.coll.insert_many([{} for _ in range(10)]) self.listener.reset() - cursor = self.client.pymongo_test.test.find(projection={"_id": False}, batch_size=4) + cursor = self.client.db.coll.find(projection={"_id": False}, batch_size=4) for _ in range(4): next(cursor) cursor_id = cursor.cursor_id @@ -139,7 +139,7 @@ def test_find_and_get_more(self): ) self.assertEqual("find", started.command_name) self.assertEqual(self.client.address, started.connection_id) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertIsInstance(started.request_id, int) self.assertIsInstance(succeeded, monitoring.CommandSucceededEvent) self.assertIsInstance(succeeded.duration_micros, int) @@ -148,7 +148,7 @@ def test_find_and_get_more(self): self.assertEqual(cursor.address, succeeded.connection_id) csr = succeeded.reply["cursor"] self.assertEqual(csr["id"], cursor_id) - self.assertEqual(csr["ns"], "pymongo_test.test") + self.assertEqual(csr["ns"], "db.coll") self.assertEqual(csr["firstBatch"], [{} for _ in range(4)]) self.listener.reset() @@ -161,12 +161,12 @@ def test_find_and_get_more(self): self.assertEqual(0, len(self.listener.failed_events)) self.assertIsInstance(started, monitoring.CommandStartedEvent) self.assertEqualCommand( - SON([("getMore", cursor_id), ("collection", "test"), ("batchSize", 4)]), + SON([("getMore", cursor_id), ("collection", "db.coll"), ("batchSize", 4)]), started.command, ) self.assertEqual("getMore", started.command_name) self.assertEqual(self.client.address, started.connection_id) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertIsInstance(started.request_id, int) self.assertIsInstance(succeeded, monitoring.CommandSucceededEvent) self.assertIsInstance(succeeded.duration_micros, int) @@ -175,7 +175,7 @@ def test_find_and_get_more(self): self.assertEqual(cursor.address, succeeded.connection_id) csr = succeeded.reply["cursor"] self.assertEqual(csr["id"], cursor_id) - self.assertEqual(csr["ns"], "pymongo_test.test") + self.assertEqual(csr["ns"], "db.coll") self.assertEqual(csr["nextBatch"], [{} for _ in range(4)]) finally: # Exhaust the cursor to avoid kill cursors. @@ -183,10 +183,10 @@ def test_find_and_get_more(self): def test_find_with_explain(self): cmd = SON([("explain", SON([("find", "test"), ("filter", {})]))]) - self.client.pymongo_test.test.drop() - self.client.pymongo_test.test.insert_one({}) + self.client.db.coll.drop() + self.client.db.coll.insert_one({}) self.listener.reset() - coll = self.client.pymongo_test.test + coll = self.client.db.coll # Test that we publish the unwrapped command. if self.client.is_mongos: coll = coll.with_options(read_preference=ReadPreference.PRIMARY_PREFERRED) @@ -198,7 +198,7 @@ def test_find_with_explain(self): self.assertEqualCommand(cmd, started.command) self.assertEqual("explain", started.command_name) self.assertEqual(self.client.address, started.connection_id) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertIsInstance(started.request_id, int) self.assertIsInstance(succeeded, monitoring.CommandSucceededEvent) self.assertIsInstance(succeeded.duration_micros, int) @@ -208,7 +208,7 @@ def test_find_with_explain(self): self.assertEqual(res, succeeded.reply) def _test_find_options(self, query, expected_cmd): - coll = self.client.pymongo_test.test + coll = self.client.db.coll coll.drop() coll.create_index("x") coll.insert_many([{"x": i} for i in range(5)]) @@ -229,7 +229,7 @@ def _test_find_options(self, query, expected_cmd): self.assertEqualCommand(expected_cmd, started.command) self.assertEqual("find", started.command_name) self.assertEqual(self.client.address, started.connection_id) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertIsInstance(started.request_id, int) self.assertIsInstance(succeeded, monitoring.CommandSucceededEvent) self.assertIsInstance(succeeded.duration_micros, int) @@ -292,10 +292,10 @@ def test_find_snapshot(self): self._test_find_options(query, cmd) def test_command_and_get_more(self): - self.client.pymongo_test.test.drop() - self.client.pymongo_test.test.insert_many([{"x": 1} for _ in range(10)]) + self.client.db.coll.drop() + self.client.db.coll.insert_many([{"x": 1} for _ in range(10)]) self.listener.reset() - coll = self.client.pymongo_test.test + coll = self.client.db.coll # Test that we publish the unwrapped command. if self.client.is_mongos: coll = coll.with_options(read_preference=ReadPreference.PRIMARY_PREFERRED) @@ -319,7 +319,7 @@ def test_command_and_get_more(self): ) self.assertEqual("aggregate", started.command_name) self.assertEqual(self.client.address, started.connection_id) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertIsInstance(started.request_id, int) self.assertIsInstance(succeeded, monitoring.CommandSucceededEvent) self.assertIsInstance(succeeded.duration_micros, int) @@ -328,7 +328,7 @@ def test_command_and_get_more(self): self.assertEqual(cursor.address, succeeded.connection_id) expected_cursor = { "id": cursor_id, - "ns": "pymongo_test.test", + "ns": "db.coll", "firstBatch": [{"x": 1} for _ in range(4)], } self.assertEqualCommand(expected_cursor, succeeded.reply.get("cursor")) @@ -341,12 +341,12 @@ def test_command_and_get_more(self): self.assertEqual(0, len(self.listener.failed_events)) self.assertIsInstance(started, monitoring.CommandStartedEvent) self.assertEqualCommand( - SON([("getMore", cursor_id), ("collection", "test"), ("batchSize", 4)]), + SON([("getMore", cursor_id), ("collection", "db.coll"), ("batchSize", 4)]), started.command, ) self.assertEqual("getMore", started.command_name) self.assertEqual(self.client.address, started.connection_id) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertIsInstance(started.request_id, int) self.assertIsInstance(succeeded, monitoring.CommandSucceededEvent) self.assertIsInstance(succeeded.duration_micros, int) @@ -356,7 +356,7 @@ def test_command_and_get_more(self): expected_result = { "cursor": { "id": cursor_id, - "ns": "pymongo_test.test", + "ns": "db.coll", "nextBatch": [{"x": 1} for _ in range(4)], }, "ok": 1.0, @@ -368,7 +368,7 @@ def test_command_and_get_more(self): def test_get_more_failure(self): address = self.client.address - coll = self.client.pymongo_test.test + coll = self.client.db.coll cursor_id = Int64(12345) cursor_doc = {"id": cursor_id, "firstBatch": [], "ns": coll.full_name} cursor = CommandCursor(coll, cursor_doc, address) @@ -381,11 +381,11 @@ def test_get_more_failure(self): failed = self.listener.failed_events[0] self.assertIsInstance(started, monitoring.CommandStartedEvent) self.assertEqualCommand( - SON([("getMore", cursor_id), ("collection", "test")]), started.command + SON([("getMore", cursor_id), ("collection", "db.coll")]), started.command ) self.assertEqual("getMore", started.command_name) self.assertEqual(self.client.address, started.connection_id) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertIsInstance(started.request_id, int) self.assertIsInstance(failed, monitoring.CommandFailedEvent) self.assertIsInstance(failed.duration_micros, int) @@ -404,7 +404,7 @@ def test_not_primary_error(self): self.listener.reset() error = None try: - client.pymongo_test.test.find_one_and_delete({}) + client.db.coll.find_one_and_delete({}) except NotPrimaryError as exc: error = exc.errors started = self.listener.started_events[0] @@ -421,10 +421,10 @@ def test_not_primary_error(self): @client_context.require_no_mongos def test_exhaust(self): - self.client.pymongo_test.test.drop() - self.client.pymongo_test.test.insert_many([{} for _ in range(11)]) + self.client.db.coll.drop() + self.client.db.coll.insert_many([{} for _ in range(11)]) self.listener.reset() - cursor = self.client.pymongo_test.test.find( + cursor = self.client.db.coll.find( projection={"_id": False}, batch_size=5, cursor_type=CursorType.EXHAUST ) next(cursor) @@ -441,7 +441,7 @@ def test_exhaust(self): ) self.assertEqual("find", started.command_name) self.assertEqual(cursor.address, started.connection_id) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertIsInstance(started.request_id, int) self.assertIsInstance(succeeded, monitoring.CommandSucceededEvent) self.assertIsInstance(succeeded.duration_micros, int) @@ -451,7 +451,7 @@ def test_exhaust(self): expected_result = { "cursor": { "id": cursor_id, - "ns": "pymongo_test.test", + "ns": "db.coll", "firstBatch": [{} for _ in range(5)], }, "ok": 1, @@ -464,12 +464,12 @@ def test_exhaust(self): for event in self.listener.started_events: self.assertIsInstance(event, monitoring.CommandStartedEvent) self.assertEqualCommand( - SON([("getMore", cursor_id), ("collection", "test"), ("batchSize", 5)]), + SON([("getMore", cursor_id), ("collection", "db.coll"), ("batchSize", 5)]), event.command, ) self.assertEqual("getMore", event.command_name) self.assertEqual(cursor.address, event.connection_id) - self.assertEqual("pymongo_test", event.database_name) + self.assertEqual("db", event.database_name) self.assertIsInstance(event.request_id, int) for event in self.listener.succeeded_events: self.assertIsInstance(event, monitoring.CommandSucceededEvent) @@ -482,9 +482,9 @@ def test_exhaust(self): def test_kill_cursors(self): with client_knobs(kill_cursor_frequency=0.01): - self.client.pymongo_test.test.drop() - self.client.pymongo_test.test.insert_many([{} for _ in range(10)]) - cursor = self.client.pymongo_test.test.find().batch_size(5) + self.client.db.coll.drop() + self.client.db.coll.insert_many([{} for _ in range(10)]) + cursor = self.client.db.coll.find().batch_size(5) next(cursor) cursor_id = cursor.cursor_id self.listener.reset() @@ -500,7 +500,7 @@ def test_kill_cursors(self): self.assertEqual("killCursors", started.command_name) self.assertIs(type(started.connection_id), tuple) self.assertEqual(cursor.address, started.connection_id) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertIsInstance(started.request_id, int) self.assertIsInstance(succeeded, monitoring.CommandSucceededEvent) self.assertIsInstance(succeeded.duration_micros, int) @@ -515,7 +515,7 @@ def test_kill_cursors(self): ) def test_non_bulk_writes(self): - coll = self.client.pymongo_test.test + coll = self.client.db.coll coll.drop() self.listener.reset() @@ -533,7 +533,7 @@ def test_non_bulk_writes(self): ] ) self.assertEqualCommand(expected, started.command) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertEqual("insert", started.command_name) self.assertIsInstance(started.request_id, int) self.assertEqual(self.client.address, started.connection_id) @@ -563,7 +563,7 @@ def test_non_bulk_writes(self): ] ) self.assertEqualCommand(expected, started.command) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertEqual("insert", started.command_name) self.assertIsInstance(started.request_id, int) self.assertEqual(self.client.address, started.connection_id) @@ -591,7 +591,7 @@ def test_non_bulk_writes(self): ] ) self.assertEqualCommand(expected, started.command) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertEqual("insert", started.command_name) self.assertIsInstance(started.request_id, int) self.assertEqual(self.client.address, started.connection_id) @@ -620,7 +620,7 @@ def test_non_bulk_writes(self): ] ) self.assertEqualCommand(expected, started.command) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertEqual("delete", started.command_name) self.assertIsInstance(started.request_id, int) self.assertEqual(self.client.address, started.connection_id) @@ -662,7 +662,7 @@ def test_non_bulk_writes(self): ] ) self.assertEqualCommand(expected, started.command) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertEqual("update", started.command_name) self.assertIsInstance(started.request_id, int) self.assertEqual(self.client.address, started.connection_id) @@ -704,7 +704,7 @@ def test_non_bulk_writes(self): ] ) self.assertEqualCommand(expected, started.command) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertEqual("update", started.command_name) self.assertIsInstance(started.request_id, int) self.assertEqual(self.client.address, started.connection_id) @@ -745,7 +745,7 @@ def test_non_bulk_writes(self): ] ) self.assertEqualCommand(expected, started.command) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertEqual("update", started.command_name) self.assertIsInstance(started.request_id, int) self.assertEqual(self.client.address, started.connection_id) @@ -774,7 +774,7 @@ def test_non_bulk_writes(self): ] ) self.assertEqualCommand(expected, started.command) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertEqual("delete", started.command_name) self.assertIsInstance(started.request_id, int) self.assertEqual(self.client.address, started.connection_id) @@ -809,7 +809,7 @@ def test_non_bulk_writes(self): ] ) self.assertEqualCommand(expected, started.command) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertEqual("insert", started.command_name) self.assertIsInstance(started.request_id, int) self.assertEqual(self.client.address, started.connection_id) @@ -830,7 +830,7 @@ def test_non_bulk_writes(self): def test_insert_many(self): # This always uses the bulk API. - coll = self.client.pymongo_test.test + coll = self.client.db.coll coll.drop() self.listener.reset() @@ -851,7 +851,7 @@ def test_insert_many(self): self.assertEqual(coll.name, cmd["insert"]) self.assertIs(True, cmd["ordered"]) documents.extend(cmd["documents"]) - self.assertEqual("pymongo_test", start.database_name) + self.assertEqual("db", start.database_name) self.assertEqual("insert", start.command_name) self.assertIsInstance(start.request_id, int) self.assertEqual(self.client.address, start.connection_id) @@ -869,7 +869,7 @@ def test_insert_many(self): self.assertEqual(6, count) def test_insert_many_unacknowledged(self): - coll = self.client.pymongo_test.test + coll = self.client.db.coll coll.drop() unack_coll = coll.with_options(write_concern=WriteConcern(w=0)) self.listener.reset() @@ -892,7 +892,7 @@ def test_insert_many_unacknowledged(self): self.assertEqual(coll.name, cmd["insert"]) self.assertIs(True, cmd["ordered"]) documents.extend(cmd["documents"]) - self.assertEqual("pymongo_test", start.database_name) + self.assertEqual("db", start.database_name) self.assertEqual("insert", start.command_name) self.assertIsInstance(start.request_id, int) self.assertEqual(self.client.address, start.connection_id) @@ -912,7 +912,7 @@ def check(): wait_until(check, "insert documents with w=0") def test_bulk_write(self): - coll = self.client.pymongo_test.test + coll = self.client.db.coll coll.drop() self.listener.reset() @@ -931,7 +931,7 @@ def test_bulk_write(self): self.assertEqual(3, len(pairs)) for start, succeed in pairs: self.assertIsInstance(start, monitoring.CommandStartedEvent) - self.assertEqual("pymongo_test", start.database_name) + self.assertEqual("db", start.database_name) self.assertIsInstance(start.request_id, int) self.assertEqual(self.client.address, start.connection_id) self.assertIsInstance(succeed, monitoring.CommandSucceededEvent) @@ -975,7 +975,7 @@ def test_bulk_write(self): @client_context.require_failCommand_fail_point def test_bulk_write_command_network_error(self): - coll = self.client.pymongo_test.test + coll = self.client.db.coll self.listener.reset() insert_network_error = { @@ -999,7 +999,7 @@ def test_bulk_write_command_network_error(self): @client_context.require_failCommand_fail_point def test_bulk_write_command_error(self): - coll = self.client.pymongo_test.test + coll = self.client.db.coll self.listener.reset() insert_command_error = { @@ -1023,7 +1023,7 @@ def test_bulk_write_command_error(self): self.assertTrue(event.failure["errmsg"]) def test_write_errors(self): - coll = self.client.pymongo_test.test + coll = self.client.db.coll coll.drop() self.listener.reset() @@ -1047,7 +1047,7 @@ def test_write_errors(self): errors = [] for start, succeed in pairs: self.assertIsInstance(start, monitoring.CommandStartedEvent) - self.assertEqual("pymongo_test", start.database_name) + self.assertEqual("db", start.database_name) self.assertIsInstance(start.request_id, int) self.assertEqual(self.client.address, start.connection_id) self.assertIsInstance(succeed, monitoring.CommandSucceededEvent) @@ -1069,14 +1069,14 @@ def test_first_batch_helper(self): # Regardless of server version and use of helpers._first_batch # this test should still pass. self.listener.reset() - tuple((self.client.pymongo_test.test.list_indexes()).to_list()) + tuple((self.client.db.coll.list_indexes()).to_list()) started = self.listener.started_events[0] succeeded = self.listener.succeeded_events[0] self.assertEqual(0, len(self.listener.failed_events)) self.assertIsInstance(started, monitoring.CommandStartedEvent) expected = SON([("listIndexes", "test"), ("cursor", {})]) self.assertEqualCommand(expected, started.command) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertEqual("listIndexes", started.command_name) self.assertIsInstance(started.request_id, int) self.assertEqual(self.client.address, started.connection_id) @@ -1098,7 +1098,7 @@ def test_sensitive_commands(self): listener.reset() cmd = SON([("getnonce", 1)]) - listeners.publish_command_start(cmd, "pymongo_test", 12345, client.address, None) # type: ignore[arg-type] + listeners.publish_command_start(cmd, "db", 12345, client.address, None) # type: ignore[arg-type] delta = datetime.timedelta(milliseconds=100) listeners.publish_command_success( delta, @@ -1107,14 +1107,14 @@ def test_sensitive_commands(self): 12345, self.client.address, # type: ignore[arg-type] None, - database_name="pymongo_test", + database_name="db", ) started = listener.started_events[0] succeeded = listener.succeeded_events[0] self.assertEqual(0, len(listener.failed_events)) self.assertIsInstance(started, monitoring.CommandStartedEvent) self.assertEqual({}, started.command) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertEqual("getnonce", started.command_name) self.assertIsInstance(started.request_id, int) self.assertEqual(client.address, started.connection_id) @@ -1143,14 +1143,14 @@ def setUp(self): self.listener.reset() self.client = self.single_client() # Get one (authenticated) socket in the pool. - self.client.pymongo_test.command("ping") + self.client.db.command("ping") @classmethod def tearDownClass(cls): monitoring._LISTENERS = cls.saved_listeners def test_simple(self): - self.client.pymongo_test.command("ping") + self.client.db.command("ping") started = self.listener.started_events[0] succeeded = self.listener.succeeded_events[0] self.assertEqual(0, len(self.listener.failed_events)) @@ -1159,7 +1159,7 @@ def test_simple(self): self.assertEqualCommand(SON([("ping", 1)]), started.command) self.assertEqual("ping", started.command_name) self.assertEqual(self.client.address, started.connection_id) - self.assertEqual("pymongo_test", started.database_name) + self.assertEqual("db", started.database_name) self.assertIsInstance(started.request_id, int) diff --git a/test/test_pooling.py b/test/test_pooling.py index 60b41b44f4..e768feb74d 100644 --- a/test/test_pooling.py +++ b/test/test_pooling.py @@ -160,9 +160,9 @@ def setUp(self): self.c = self.rs_or_single_client() db = self.c[DB] db.unique.drop() - db.test.drop() + db.coll.drop() db.unique.insert_one({"_id": "jesse"}) - db.test.insert_many([{} for _ in range(10)]) + db.coll.insert_many([{} for _ in range(10)]) def create_pool(self, pair=None, *args, **kwargs): if pair is None: @@ -396,14 +396,14 @@ def test_checkout_more_than_max_pool_size(self): def test_maxConnecting(self): client = self.rs_or_single_client() - self.client.test.test.insert_one({}) - self.addCleanup(self.client.test.test.delete_many, {}) + self.client.db.coll.insert_one({}) + self.addCleanup(self.client.db.coll.delete_many, {}) pool = get_pool(client) docs = [] # Run 50 short running operations def find_one(): - docs.append(client.test.test.find_one({})) + docs.append(client.db.coll.find_one({})) tasks = [ConcurrentRunner(target=find_one) for _ in range(50)] for task in tasks: @@ -444,12 +444,12 @@ def test_csot_timeout_message(self): }, } - client.db.t.insert_one({"x": 1}) + client.db.coll.insert_one({"x": 1}) with self.fail_point(mock_connection_timeout): with self.assertRaises(Exception) as error: with timeout(0.5): - client.db.t.find_one({"$where": delay(2)}) + client.db.coll.find_one({"$where": delay(2)}) self.assertIn("(configured timeouts: timeoutMS: 500.0ms", str(error.exception)) @@ -468,11 +468,11 @@ def test_socket_timeout_message(self): }, } - client.db.t.insert_one({"x": 1}) + client.db.coll.insert_one({"x": 1}) with self.fail_point(mock_connection_timeout): with self.assertRaises(Exception) as error: - client.db.t.find_one({"$where": delay(2)}) + client.db.coll.find_one({"$where": delay(2)}) self.assertIn( "(configured timeouts: socketTimeoutMS: 500.0ms, connectTimeoutMS: 20000.0ms)", @@ -514,7 +514,7 @@ def test_connection_timeout_message(self): @client_context.require_failCommand_appName def test_pool_backpressure_preserves_existing_connections(self): client = self.rs_or_single_client() - coll = client.pymongo_test.t + coll = client.db.coll pool = get_pool(client) coll.insert_many([{"x": 1} for _ in range(10)]) t = SocketGetter(self.c, pool) @@ -553,7 +553,7 @@ class TestPoolMaxSize(_TestPoolingBase): def test_max_pool_size(self): max_pool_size = 4 c = self.rs_or_single_client(maxPoolSize=max_pool_size) - collection = c[DB].test + collection = c[DB].coll # Need one document. collection.drop() @@ -592,7 +592,7 @@ def f(): ) def test_max_pool_size_none(self): c = self.rs_or_single_client(maxPoolSize=None) - collection = c[DB].test + collection = c[DB].coll # Need one document. collection.drop() diff --git a/test/test_raw_bson.py b/test/test_raw_bson.py index 4d9a3ceb05..fb0f771620 100644 --- a/test/test_raw_bson.py +++ b/test/test_raw_bson.py @@ -44,7 +44,7 @@ class TestRawBSONDocument(IntegrationTest): def tearDown(self): if client_context.connected: - self.client.pymongo_test.test_raw.drop() + self.db.coll.drop() def test_decode(self): self.assertEqual("Sherlock", self.document["name"]) @@ -73,17 +73,17 @@ def test_invalid_bson_eoo(self): @client_context.require_connection def test_round_trip(self): db = self.client.get_database( - "pymongo_test", codec_options=CodecOptions(document_class=RawBSONDocument) + "db", codec_options=CodecOptions(document_class=RawBSONDocument) ) - db.test_raw.insert_one(self.document) - result = db.test_raw.find_one(self.document["_id"]) + db.coll.insert_one(self.document) + result = db.coll.find_one(self.document["_id"]) assert result is not None self.assertIsInstance(result, RawBSONDocument) self.assertEqual(dict(self.document.items()), dict(result.items())) @client_context.require_connection def test_round_trip_raw_uuid(self): - coll = self.client.get_database("pymongo_test").test_raw + coll = self.client.get_database("db").test_raw uid = uuid.uuid4() doc = {"_id": 1, "bin4": Binary(uid.bytes, 4), "bin3": Binary(uid.bytes, 3)} raw = RawBSONDocument(encode(doc)) @@ -126,7 +126,7 @@ def test_round_trip_codec_options(self): "date": datetime.datetime(2015, 6, 3, 18, 40, 50, 826000), "_id": uuid.UUID("026fab8f-975f-4965-9fbf-85ad874c60ff"), } - db = self.client.pymongo_test + db = self.client.db coll = db.get_collection( "test_raw", codec_options=CodecOptions(uuid_representation=JAVA_LEGACY) ) @@ -142,9 +142,9 @@ def test_round_trip_codec_options(self): @client_context.require_connection def test_raw_bson_document_embedded(self): doc = {"embedded": self.document} - db = self.client.pymongo_test - db.test_raw.insert_one(doc) - result = db.test_raw.find_one() + db = self.client.db + db.coll.insert_one(doc) + result = db.coll.find_one() assert result is not None self.assertEqual(decode(self.document.raw), result["embedded"]) @@ -167,8 +167,8 @@ def test_raw_bson_document_embedded(self): ), ) - db.test_raw.drop() - db.test_raw.insert_one(rbd) + db.coll.drop() + db.coll.insert_one(rbd) result = db.get_collection( "test_raw", codec_options=CodecOptions(uuid_representation=JAVA_LEGACY) ).find_one() @@ -178,7 +178,7 @@ def test_raw_bson_document_embedded(self): @client_context.require_connection def test_write_response_raw_bson(self): coll = self.client.get_database( - "pymongo_test", codec_options=CodecOptions(document_class=RawBSONDocument) + "db", codec_options=CodecOptions(document_class=RawBSONDocument) ).test_raw # No Exceptions raised while handling write response. @@ -207,11 +207,11 @@ def test_contains_code_with_scope(self): self.assertEqual(doc["value"].scope, RawBSONDocument(encode({}))) def test_contains_dbref(self): - doc = RawBSONDocument(encode({"value": DBRef("test", "id")})) - raw = {"$ref": "test", "$id": "id"} + doc = RawBSONDocument(encode({"value": DBRef("coll", "id")})) + raw = {"$ref": "coll", "$id": "id"} raw_encoded = encode(decode(encode(raw))) - self.assertEqual(decode(encode(doc)), {"value": DBRef("test", "id")}) + self.assertEqual(decode(encode(doc)), {"value": DBRef("coll", "id")}) self.assertEqual(doc["value"].raw, raw_encoded) diff --git a/test/test_read_concern.py b/test/test_read_concern.py index 62b2491475..036d7a82cb 100644 --- a/test/test_read_concern.py +++ b/test/test_read_concern.py @@ -38,11 +38,11 @@ def setUp(self): super().setUp() self.listener = OvertCommandListener() self.client = self.rs_or_single_client(event_listeners=[self.listener]) - self.db = self.client.pymongo_test - client_context.client.pymongo_test.create_collection("coll") + self.db = self.client.db + client_context.client.db.create_collection("coll") def tearDown(self): - client_context.client.pymongo_test.drop_collection("coll") + client_context.client.db.drop_collection("coll") def test_read_concern(self): rc = ReadConcern() diff --git a/test/test_read_preferences.py b/test/test_read_preferences.py index afde01723d..e4da2dd89c 100644 --- a/test/test_read_preferences.py +++ b/test/test_read_preferences.py @@ -105,16 +105,16 @@ class TestReadPreferencesBase(IntegrationTest): def setUp(self): super().setUp() # Insert some data so we can use cursors in read_from_which_host - self.client.pymongo_test.test.drop() + self.client.db.coll.drop() self.client.get_database( - "pymongo_test", write_concern=WriteConcern(w=client_context.w) - ).test.insert_many([{"_id": i} for i in range(10)]) + "db", write_concern=WriteConcern(w=client_context.w) + ).coll.insert_many([{"_id": i} for i in range(10)]) - self.addCleanup(self.client.pymongo_test.test.drop) + self.addCleanup(self.client.db.coll.drop) def read_from_which_host(self, client): """Do a find() on the client and return which host was used""" - cursor = client.pymongo_test.test.find() + cursor = client.db.coll.find() next(cursor) return cursor.address @@ -157,8 +157,8 @@ def test_reads_from_secondary(self): # See server-selection.rst#topology-type-single. self.assertEqual(client.read_preference, ReadPreference.PRIMARY) - db = client.pymongo_test - coll = db.test + db = client.db + coll = db.coll # Test find and find_one. self.assertIsNotNone(coll.find_one()) @@ -166,7 +166,7 @@ def test_reads_from_secondary(self): # Test some database helpers. self.assertIsNotNone(db.list_collection_names()) - self.assertIsNotNone(db.validate_collection("test")) + self.assertIsNotNone(db.validate_collection("coll")) self.assertIsNotNone(db.command("ping")) # Test some collection helpers. @@ -347,13 +347,11 @@ def setUp(self): ) self.client_version = Version.from_client(self.c) # mapReduce fails if the collection does not exist. - coll = self.c.pymongo_test.get_collection( - "test", write_concern=WriteConcern(w=client_context.w) - ) + coll = self.c.db.get_collection("coll", write_concern=WriteConcern(w=client_context.w)) coll.insert_one({}) def tearDown(self): - self.c.drop_database("pymongo_test") + self.c.drop_database("db") self.c.close() def executed_on_which_server(self, client, fn, *args, **kwargs): @@ -409,7 +407,7 @@ def test_command(self): for mode, server_type in _PREF_MAP: def func(): - return self.c.pymongo_test.command("dbStats", read_preference=mode()) + return self.c.db.command("dbStats", read_preference=mode()) self._test_fn(server_type, func) @@ -417,32 +415,28 @@ def test_create_collection(self): # create_collection runs listCollections on the primary to check if # the collection already exists. def func(): - return self.c.pymongo_test.create_collection( - "some_collection%s" % random.randint(0, sys.maxsize) - ) + return self.c.db.create_collection("some_collection%s" % random.randint(0, sys.maxsize)) self._test_primary_helper(func) def test_count_documents(self): - self._test_coll_helper(True, self.c.pymongo_test.test, "count_documents", {}) + self._test_coll_helper(True, self.c.db.coll, "count_documents", {}) def test_estimated_document_count(self): - self._test_coll_helper(True, self.c.pymongo_test.test, "estimated_document_count") + self._test_coll_helper(True, self.c.db.coll, "estimated_document_count") def test_distinct(self): - self._test_coll_helper(True, self.c.pymongo_test.test, "distinct", "a") + self._test_coll_helper(True, self.c.db.coll, "distinct", "a") def test_aggregate(self): - self._test_coll_helper( - True, self.c.pymongo_test.test, "aggregate", [{"$project": {"_id": 1}}] - ) + self._test_coll_helper(True, self.c.db.coll, "aggregate", [{"$project": {"_id": 1}}]) def test_aggregate_write(self): # 5.0 servers support $out on secondaries. secondary_ok = client_context.version.at_least(5, 0) self._test_coll_helper( secondary_ok, - self.c.pymongo_test.test, + self.c.db.coll, "aggregate", [{"$project": {"_id": 1}}, {"$out": "agg_write_test"}], ) @@ -576,7 +570,7 @@ def test_send_hedge(self): for _mode, cls in cases.items(): with _ignore_deprecations(): pref = cls(hedge={"enabled": True}) - coll = client.test.get_collection("test", read_preference=pref) + coll = client.coll.get_collection("coll", read_preference=pref) listener.reset() coll.find_one() started = listener.started_events @@ -660,8 +654,8 @@ def test_mongos(self): num_members = shard.count(",") + 1 if num_members == 1: raise SkipTest("Need a replica set shard to test.") - coll = client_context.client.pymongo_test.get_collection( - "test", write_concern=WriteConcern(w=num_members) + coll = client_context.client.db.get_collection( + "coll", write_concern=WriteConcern(w=num_members) ) coll.drop() res = coll.insert_many([{} for _ in range(5)]) @@ -682,14 +676,14 @@ def test_mongos(self): @client_context.require_mongos def test_mongos_max_staleness(self): # Sanity check that we're sending maxStalenessSeconds - coll = client_context.client.pymongo_test.get_collection( - "test", read_preference=SecondaryPreferred(max_staleness=120) + coll = client_context.client.db.get_collection( + "coll", read_preference=SecondaryPreferred(max_staleness=120) ) # No error coll.find_one() - coll = client_context.client.pymongo_test.get_collection( - "test", read_preference=SecondaryPreferred(max_staleness=10) + coll = client_context.client.db.get_collection( + "coll", read_preference=SecondaryPreferred(max_staleness=10) ) try: coll.find_one() @@ -700,13 +694,13 @@ def test_mongos_max_staleness(self): coll = ( self.single_client(readPreference="secondaryPreferred", maxStalenessSeconds=120) - ).pymongo_test.test + ).db.coll # No error coll.find_one() coll = ( self.single_client(readPreference="secondaryPreferred", maxStalenessSeconds=10) - ).pymongo_test.test + ).db.coll try: coll.find_one() except OperationFailure as exc: diff --git a/test/test_read_write_concern_spec.py b/test/test_read_write_concern_spec.py index 54946c3ea0..1766d8bb32 100644 --- a/test/test_read_write_concern_spec.py +++ b/test/test_read_write_concern_spec.py @@ -50,36 +50,34 @@ def test_omit_default_read_write_concern(self): listener = OvertCommandListener() # Client with default readConcern and writeConcern client = self.rs_or_single_client(event_listeners=[listener]) - collection = client.pymongo_test.collection + coll = client.db.coll # Prepare for tests of find() and aggregate(). - collection.insert_many([{} for _ in range(10)]) - self.addCleanup(collection.drop) - self.addCleanup(client.pymongo_test.collection2.drop) + coll.insert_many([{} for _ in range(10)]) + self.addCleanup(coll.drop) + self.addCleanup(client.db.coll2.drop) # Commands MUST NOT send the default read/write concern to the server. def rename_and_drop(): - # Ensure collection exists. - collection.insert_one({}) - collection.rename("collection2") - client.pymongo_test.collection2.drop() + # Ensure coll exists. + coll.insert_one({}) + coll.rename("coll2") + client.db.coll2.drop() def insert_command_default_write_concern(): - collection.database.command( - "insert", "collection", documents=[{}], write_concern=WriteConcern() - ) + coll.database.command("insert", "coll", documents=[{}], write_concern=WriteConcern()) def aggregate_op(): - (collection.aggregate([])).to_list() + (coll.aggregate([])).to_list() ops = [ ("aggregate", aggregate_op), - ("find", lambda: collection.find().to_list()), - ("insert_one", lambda: collection.insert_one({})), - ("update_one", lambda: collection.update_one({}, {"$set": {"x": 1}})), - ("update_many", lambda: collection.update_many({}, {"$set": {"x": 1}})), - ("delete_one", lambda: collection.delete_one({})), - ("delete_many", lambda: collection.delete_many({})), - ("bulk_write", lambda: collection.bulk_write([InsertOne({})])), + ("find", lambda: coll.find().to_list()), + ("insert_one", lambda: coll.insert_one({})), + ("update_one", lambda: coll.update_one({}, {"$set": {"x": 1}})), + ("update_many", lambda: coll.update_many({}, {"$set": {"x": 1}})), + ("delete_one", lambda: coll.delete_one({})), + ("delete_many", lambda: coll.delete_many({})), + ("bulk_write", lambda: coll.bulk_write([InsertOne({})])), ("rename_and_drop", rename_and_drop), ("command", insert_command_default_write_concern), ] @@ -107,8 +105,8 @@ def assertWriteOpsRaise(self, write_concern, expected_exception): client = self.rs_or_single_client( w=wc["w"], wTimeoutMS=wc["wtimeout"], socketTimeoutMS=30000 ) - db = client.get_database("pymongo_test") - coll = db.test + db = client.get_database("db") + coll = db.coll def insert_command(): coll.database.command( @@ -159,7 +157,7 @@ def insert_command(): @client_context.require_replica_set def test_raise_write_concern_error(self): - self.addCleanup(client_context.client.drop_database, "pymongo_test") + self.addCleanup(client_context.client.drop_database, "db") assert client_context.w is not None self.assertWriteOpsRaise( WriteConcern(w=client_context.w + 1, wtimeout=1), WriteConcernError @@ -168,7 +166,7 @@ def test_raise_write_concern_error(self): @client_context.require_secondaries_count(1) @client_context.require_test_commands def test_raise_wtimeout(self): - self.addCleanup(client_context.client.drop_database, "pymongo_test") + self.addCleanup(client_context.client.drop_database, "db") self.addCleanup(self.enable_replication, client_context.client) # Disable replication to guarantee a wtimeout error. self.disable_replication(client_context.client) @@ -192,12 +190,12 @@ def test_error_includes_errInfo(self): with self.fail_point(cause_wce): # Write concern error on insert includes errInfo. with self.assertRaises(WriteConcernError) as ctx: - self.db.test.insert_one({}) + self.db.coll.insert_one({}) self.assertEqual(ctx.exception.details, expected_wce) # Test bulk_write as well. with self.assertRaises(BulkWriteError) as ctx: - self.db.test.bulk_write([InsertOne({})]) + self.db.coll.bulk_write([InsertOne({})]) expected_details = { "writeErrors": [], "writeConcernErrors": [expected_wce], @@ -219,9 +217,9 @@ def test_write_error_details_exposes_errinfo(self): db = client.errinfotest self.addCleanup(client.drop_database, "errinfotest") validator = {"x": {"$type": "string"}} - db.create_collection("test", validator=validator) + db.create_collection("coll", validator=validator) with self.assertRaises(WriteError) as ctx: - db.test.insert_one({"x": 1}) + db.coll.insert_one({"x": 1}) self.assertEqual(ctx.exception.code, 121) self.assertIsNotNone(ctx.exception.details) assert ctx.exception.details is not None diff --git a/test/test_replica_set_reconfig.py b/test/test_replica_set_reconfig.py index 3371543f27..a1b1be7bc3 100644 --- a/test/test_replica_set_reconfig.py +++ b/test/test_replica_set_reconfig.py @@ -133,7 +133,7 @@ def test_socket_error_marks_member_down(self): c.mock_down_hosts.append("b:2") self.assertRaises( ConnectionFailure, - c.db.collection.with_options(read_preference=ReadPreference.SECONDARY).find_one, + c.db.coll.with_options(read_preference=ReadPreference.SECONDARY).find_one, ) self.assertEqual(1, len(c.nodes)) diff --git a/test/test_retryable_reads.py b/test/test_retryable_reads.py index 4545d7ff7e..8c4a2174b0 100644 --- a/test/test_retryable_reads.py +++ b/test/test_retryable_reads.py @@ -97,7 +97,7 @@ def test_pool_paused_error_is_retryable(self): for _ in range(10): cmap_listener.reset() cmd_listener.reset() - threads = [FindThread(client.pymongo_test.test) for _ in range(2)] + threads = [FindThread(client.db.coll) for _ in range(2)] fail_command = { "mode": {"times": 1}, "data": { @@ -183,7 +183,7 @@ def test_retryable_reads_are_retried_on_a_different_mongos_when_one_is_available ) with self.assertRaises(OperationFailure): - client.t.t.find_one({}) + client.db.coll.find_one({}) # Disable failpoints on each mongos for client in mongos_clients: @@ -217,7 +217,7 @@ def test_retryable_reads_are_retried_on_the_same_mongos_when_no_others_are_avail retryReads=True, ) - client.t.t.find_one({}) + client.db.coll.find_one({}) # Disable failpoint. fail_command["mode"] = "off" @@ -239,17 +239,17 @@ def test_retryable_reads_are_retried_on_the_same_implicit_session(self): retryReads=True, ) - client.t.t.insert_one({"x": 1}) + client.db.coll.insert_one({"x": 1}) commands = [ - ("aggregate", lambda: client.t.t.count_documents({})), - ("aggregate", lambda: client.t.t.aggregate([{"$match": {}}])), - ("count", lambda: client.t.t.estimated_document_count()), - ("distinct", lambda: client.t.t.distinct("x")), - ("find", lambda: client.t.t.find_one({})), + ("aggregate", lambda: client.db.coll.count_documents({})), + ("aggregate", lambda: client.db.coll.aggregate([{"$match": {}}])), + ("count", lambda: client.db.coll.estimated_document_count()), + ("distinct", lambda: client.db.coll.distinct("x")), + ("find", lambda: client.db.coll.find_one({})), ("listDatabases", lambda: client.list_databases()), - ("listCollections", lambda: client.t.list_collections()), - ("listIndexes", lambda: client.t.t.list_indexes()), + ("listCollections", lambda: client.db.list_collections()), + ("listIndexes", lambda: client.db.coll.list_indexes()), ] for command_name, operation in commands: @@ -309,7 +309,7 @@ def test_03_01_retryable_reads_caused_by_overload_errors_are_retried_on_a_differ listener.reset() # 4. Execute a `find` command with `client`. - client.t.t.find_one({}) + client.db.coll.find_one({}) # 5. Assert that one failed command event and one successful command event occurred. self.assertEqual(len(listener.failed_events), 1) @@ -351,7 +351,7 @@ def test_03_02_retryable_reads_caused_by_non_overload_errors_are_retried_on_the_ listener.reset() # 4. Execute a `find` command with `client`. - client.t.t.find_one({}) + client.db.coll.find_one({}) # 5. Assert that one failed command event and one successful command event occurred. self.assertEqual(len(listener.failed_events), 1) @@ -395,7 +395,7 @@ def test_03_03_retryable_reads_caused_by_overload_errors_are_retried_on_the_same listener.reset() # 4. Execute a `find` command with `client`. - client.t.t.find_one({}) + client.db.coll.find_one({}) # 5. Assert that one failed command event and one successful command event occurred. self.assertEqual(len(listener.failed_events), 1) @@ -445,13 +445,13 @@ def failed(event: CommandFailedEvent) -> None: listener.failed = failed client = self.rs_client(event_listeners=[listener]) - client.test.test.insert_one({}) + client.db.coll.insert_one({}) self.configure_fail_point_sync(overload_fail_point) self.addCleanup(self.configure_fail_point_sync, {}, off=True) with self.assertRaises(PyMongoError): - client.test.test.find_one() + client.db.coll.find_one() started_finds = [e for e in listener.started_events if e.command_name == "find"] self.assertEqual(len(started_finds), MAX_ADAPTIVE_RETRIES + 1) @@ -502,7 +502,7 @@ def failed(event: CommandFailedEvent) -> None: listener.failed = failed client = self.rs_client(event_listeners=[listener]) - client.test.test.insert_one({}) + client.db.coll.insert_one({}) self.configure_fail_point_sync(overload_fail_point) self.addCleanup(self.configure_fail_point_sync, {}, off=True) @@ -510,7 +510,7 @@ def failed(event: CommandFailedEvent) -> None: # Perform a findOne operation with coll. Expect the operation to fail. with mock.patch(mock_target, return_value=0) as mock_backoff: with self.assertRaises(PyMongoError): - client.test.test.find_one() + client.db.coll.find_one() # Assert that backoff was applied only once for the initial overload error and not for the subsequent non-overload retryable errors. self.assertEqual(mock_backoff.call_count, 1) diff --git a/test/test_retryable_writes.py b/test/test_retryable_writes.py index 46ca3a43b8..cd4454e7eb 100644 --- a/test/test_retryable_writes.py +++ b/test/test_retryable_writes.py @@ -157,7 +157,7 @@ def setUp(self) -> None: self.knobs.enable() self.listener = OvertCommandListener() self.client = self.rs_or_single_client(retryWrites=True, event_listeners=[self.listener]) - self.db = self.client.pymongo_test + self.db = self.client.db if client_context.is_rs and client_context.test_commands_enabled: self.client.admin.command( @@ -383,7 +383,7 @@ def test_retryable_writes_in_sharded_cluster_multiple_available(self): ) with self.assertRaises(AutoReconnect): - client.t.t.insert_one({"x": 1}) + client.db.coll.insert_one({"x": 1}) # Disable failpoints on each mongos for client in mongos_clients: @@ -418,11 +418,11 @@ def test_RetryableWriteError_error_label(self): client = self.rs_or_single_client(retryWrites=True, event_listeners=[listener]) # Ensure collection exists. - client.pymongo_test.testcoll.insert_one({}) + client.db.coll.insert_one({}) with self.fail_point(self.fail_insert): with self.assertRaises(WriteConcernError) as cm: - client.pymongo_test.testcoll.insert_one({}) + client.db.coll.insert_one({}) self.assertTrue(cm.exception.has_error_label("RetryableWriteError")) if client_context.version >= Version(4, 4): @@ -435,9 +435,9 @@ def test_RetryableWriteError_error_label_RawBSONDocument(self): with self.fail_point(self.fail_insert): with self.client.start_session() as s: s._start_retryable_write() - result = self.client.pymongo_test.command( + result = self.client.db.command( "insert", - "testcoll", + "coll", documents=[{"_id": 1}], txnNumber=s._transaction_id, session=s, @@ -480,7 +480,7 @@ def test_pool_paused_error_is_retryable(self): for _ in range(10): cmap_listener.reset() cmd_listener.reset() - threads = [InsertThread(client.pymongo_test.test) for _ in range(2)] + threads = [InsertThread(client.db.coll) for _ in range(2)] fail_command = { "mode": {"times": 1}, "data": { @@ -539,7 +539,7 @@ def test_returns_original_error_code( ): cmd_listener = InsertEventListener() client = self.rs_or_single_client(retryWrites=True, event_listeners=[cmd_listener]) - client.test.test.drop() + client.db.coll.drop() cmd_listener.reset() client.admin.command( { @@ -555,7 +555,7 @@ def test_returns_original_error_code( } ) with self.assertRaises(WriteConcernError) as exc: - client.test.test.insert_one({"_id": 1}) + client.db.coll.insert_one({"_id": 1}) self.assertEqual(exc.exception.code, 91) client.admin.command( { @@ -669,7 +669,7 @@ def failed(event: CommandFailedEvent) -> None: # Attempt an insertOne operation on any record for any database and collection. # Expect the insertOne to fail with a server error. with self.assertRaises(NotPrimaryError) as exc: - client.test.test.insert_one({}) + client.db.coll.insert_one({}) # Assert that the error code of the server error is 10107. assert exc.exception.errors["code"] == 10107 # type:ignore[call-overload] @@ -722,7 +722,7 @@ def failed(event: CommandFailedEvent) -> None: # Attempt an insertOne operation on any record for any database and collection. # Expect the insertOne to fail with a server error. with self.assertRaises(NotPrimaryError) as exc: - client.test.test.insert_one({}) + client.db.coll.insert_one({}) # Assert that the error code of the server error is 91. assert exc.exception.errors["code"] == 91 # type:ignore[call-overload] @@ -776,7 +776,7 @@ def failed(event: CommandFailedEvent) -> None: # Attempt an insertOne operation on any record for any database and collection. # Expect the insertOne to fail with a server error. with self.assertRaises(PyMongoError) as exc: - client.test.test.insert_one({}) + client.db.coll.insert_one({}) # Assert that the error code of the server error is 91. assert exc.exception.errors["code"] == 91 @@ -827,7 +827,7 @@ def failed(event: CommandFailedEvent) -> None: self.addCleanup(self.configure_fail_point_sync, {}, off=True) with self.assertRaises(PyMongoError): - client.test.test.insert_one({"x": 1}) + client.db.coll.insert_one({"x": 1}) started_inserts = [e for e in listener.started_events if e.command_name == "insert"] self.assertEqual(len(started_inserts), MAX_ADAPTIVE_RETRIES + 1) @@ -883,7 +883,7 @@ def failed(event: CommandFailedEvent) -> None: # Perform a findOne operation with coll. Expect the operation to fail. with mock.patch(mock_target, return_value=0) as mock_backoff: with self.assertRaises(PyMongoError): - client.test.test.insert_one({}) + client.db.coll.insert_one({}) # Assert that backoff was applied only once for the initial overload error and not for the subsequent non-overload retryable errors. self.assertEqual(mock_backoff.call_count, 1) diff --git a/test/test_server_selection.py b/test/test_server_selection.py index d94e9ed0a1..6993763bce 100644 --- a/test/test_server_selection.py +++ b/test/test_server_selection.py @@ -129,14 +129,14 @@ def test_selector_called(self): # Client setup. mongo_client = self.rs_or_single_client(server_selector=selector) - test_collection = mongo_client.testdb.test_collection - self.addCleanup(mongo_client.drop_database, "testdb") + coll = mongo_client.db.coll + self.addCleanup(mongo_client.drop_database, "db") # Do N operations and test selector is called at least N-1 times due to fast path. - test_collection.insert_one({"age": 20, "name": "John"}) - test_collection.insert_one({"age": 31, "name": "Jane"}) - test_collection.update_one({"name": "Jane"}, {"$set": {"age": 21}}) - test_collection.find_one({"name": "Roe"}) + coll.insert_one({"age": 20, "name": "John"}) + coll.insert_one({"age": 31, "name": "Jane"}) + coll.update_one({"name": "Jane"}, {"$set": {"age": 21}}) + coll.find_one({"name": "Roe"}) self.assertGreaterEqual(selector.call_count, 3) @client_context.require_replica_set @@ -214,7 +214,7 @@ def test_server_selection_getMore_blocks(self): client = self.rs_client( event_listeners=[hb_listener], heartbeatFrequencyMS=500, appName="heartbeatFailedClient" ) - coll = client.db.test + coll = client.db.coll coll.drop() docs = [{"x": 1} for _ in range(5)] coll.insert_many(docs) diff --git a/test/test_server_selection_in_window.py b/test/test_server_selection_in_window.py index 71183a276c..e994736047 100644 --- a/test/test_server_selection_in_window.py +++ b/test/test_server_selection_in_window.py @@ -116,7 +116,7 @@ def run(self): class TestProse(IntegrationTest): def frequencies(self, client, listener, n_finds=10): - coll = client.test.test + coll = client.db.coll N_TASKS = 10 tasks = [FinderTask(coll, n_finds) for _ in range(N_TASKS)] for task in tasks: @@ -169,7 +169,7 @@ def test_load_balancing(self): "appName": "loadBalancingTest", }, } - coll = client.test.test + coll = client.db.coll N_TASKS = 10 with self.fail_point(delay_finds): nodes = client_context.client.nodes diff --git a/test/test_session.py b/test/test_session.py index 0ed27fa95f..0f2dde76b7 100644 --- a/test/test_session.py +++ b/test/test_session.py @@ -98,12 +98,12 @@ def setUp(self): self.client = self.rs_or_single_client( event_listeners=[self.listener, self.session_checker_listener] ) - self.db = self.client.pymongo_test + self.db = self.client.db self.initial_lsids = {s["id"] for s in session_ids(self.client)} def tearDown(self): monitoring._SENSITIVE_COMMANDS.update(self.sensitive_commands) - self.client.drop_database("pymongo_test") + self.client.drop_database("db") used_lsids = self.initial_lsids.copy() for event in self.session_checker_listener.started_events: if "lsid" in event.command: @@ -242,17 +242,17 @@ def test_implicit_sessions_checkout(self): # Retry up to 10 times because there is a known race condition that can cause multiple # sessions to be used: connection check in happens before session check in for _ in range(10): - cursor = client.db.test.find({}) + cursor = client.db.coll.find({}) ops: List[Tuple[Callable, List[Any]]] = [ - (client.db.test.find_one, [{"_id": 1}]), - (client.db.test.delete_one, [{}]), - (client.db.test.update_one, [{}, {"$set": {"x": 2}}]), - (client.db.test.bulk_write, [[UpdateOne({}, {"$set": {"x": 2}})]]), - (client.db.test.find_one_and_delete, [{}]), - (client.db.test.find_one_and_update, [{}, {"$set": {"x": 1}}]), - (client.db.test.find_one_and_replace, [{}, {}]), - (client.db.test.aggregate, [[{"$limit": 1}]]), - (client.db.test.find, []), + (client.db.coll.find_one, [{"_id": 1}]), + (client.db.coll.delete_one, [{}]), + (client.db.coll.update_one, [{}, {"$set": {"x": 2}}]), + (client.db.coll.bulk_write, [[UpdateOne({}, {"$set": {"x": 2}})]]), + (client.db.coll.find_one_and_delete, [{}]), + (client.db.coll.find_one_and_update, [{}, {"$set": {"x": 1}}]), + (client.db.coll.find_one_and_replace, [{}, {}]), + (client.db.coll.aggregate, [[{"$limit": 1}]]), + (client.db.coll.find, []), (client.server_info, []), (client.db.aggregate, [[{"$listLocalSessions": {}}, {"$limit": 1}]]), (cursor.distinct, ["_id"]), @@ -349,26 +349,26 @@ def test_client(self): ops: list = [ (client.server_info, [], {}), (client.list_database_names, [], {}), - (client.drop_database, ["pymongo_test"], {}), + (client.drop_database, ["db"], {}), ] self._test_ops(client, *ops) def test_database(self): client = self.client - db = client.pymongo_test + db = client.db ops: list = [ (db.command, ["ping"], {}), - (db.create_collection, ["collection"], {}), + (db.create_coll, ["collection"], {}), (db.list_collection_names, [], {}), - (db.validate_collection, ["collection"], {}), - (db.drop_collection, ["collection"], {}), + (db.validate_collection, ["coll"], {}), + (db.drop_collection, ["coll"], {}), (db.dereference, [DBRef("collection", 1)], {}), ] self._test_ops(client, *ops) @staticmethod - def collection_write_ops(coll): + def test_write_ops(coll): """Generate database write ops for tests.""" return [ (coll.drop, [], {}), @@ -383,9 +383,9 @@ def collection_write_ops(coll): (coll.find_one_and_replace, [{}, {}], {}), (coll.find_one_and_update, [{}, {"$set": {"a": 1}}], {}), (coll.find_one_and_delete, [{}, {}], {}), - (coll.rename, ["collection2"], {}), - # Drop collection2 between tests of "rename", above. - (coll.database.drop_collection, ["collection2"], {}), + (coll.rename, ["coll2"], {}), + # Drop coll2 between tests of "rename", above. + (coll.database.drop_collection, ["coll2"], {}), (coll.create_indexes, [[IndexModel("a")]], {}), (coll.create_index, ["a"], {}), (coll.drop_index, ["a_1"], {}), @@ -395,7 +395,7 @@ def collection_write_ops(coll): def test_collection(self): client = self.client - coll = client.pymongo_test.collection + coll = client.db.coll # Test some collection methods - the rest are in test_cursor. ops = self.collection_write_ops(coll) @@ -414,7 +414,7 @@ def test_collection(self): self._test_ops(client, *ops) def test_cursor_clone(self): - coll = self.client.pymongo_test.collection + coll = self.client.db.coll # Ensure some batches. coll.insert_many({} for _ in range(10)) self.addCleanup(coll.drop) @@ -442,7 +442,7 @@ def test_cursor_clone(self): def test_cursor(self): listener = self.listener client = self.client - coll = client.pymongo_test.collection + coll = client.db.coll coll.insert_many([{} for _ in range(1000)]) # Test all cursor methods. @@ -504,7 +504,7 @@ def test_cursor(self): def test_gridfs(self): client = self.client - fs = GridFS(client.pymongo_test) + fs = GridFS(client.db) def new_file(session=None): grid_file = fs.new_file(_id=1, filename="f", session=session) @@ -546,7 +546,7 @@ def find_list(session=None): def test_gridfs_bucket(self): client = self.client - bucket = GridFSBucket(client.pymongo_test) + bucket = GridFSBucket(client.db) def upload(session=None): stream = bucket.open_upload_stream("f", session=session) @@ -593,7 +593,7 @@ def find(session=None): def test_gridfsbucket_cursor(self): client = self.client - bucket = GridFSBucket(client.pymongo_test) + bucket = GridFSBucket(client.db) for file_id in 1, 2: stream = bucket.open_upload_stream_with_id(file_id, str(file_id)) @@ -644,7 +644,7 @@ def test_gridfsbucket_cursor(self): def test_aggregate(self): client = self.client - coll = client.pymongo_test.collection + coll = client.db.coll def agg(session=None): (coll.aggregate([], batchSize=2, session=session)).to_list() @@ -659,7 +659,7 @@ def agg(session=None): def test_killcursors(self): client = self.client - coll = client.pymongo_test.collection + coll = client.db.coll coll.insert_many([{} for _ in range(10)]) def explicit_close(session=None): @@ -672,7 +672,7 @@ def explicit_close(session=None): def test_aggregate_error(self): listener = self.listener client = self.client - coll = client.pymongo_test.collection + coll = client.db.coll # 3.6.0 mongos only validates the aggregate pipeline when the # database exists. coll.database.create_collection(coll.name) @@ -688,7 +688,7 @@ def test_aggregate_error(self): self.assertIn(lsid, session_ids(client)) def _test_cursor_helper(self, create_cursor, close_cursor): - coll = self.client.pymongo_test.collection + coll = self.client.db.coll coll.insert_many([{} for _ in range(1000)]) cursor = create_cursor(coll, None) @@ -827,14 +827,14 @@ def _test_unacknowledged_ops(self, client, *ops): def test_unacknowledged_writes(self): # Ensure the collection exists. - self.client.pymongo_test.create_collection("test_unacked_writes") + self.client.db.create_collection("test_unacked_writes") client = self.rs_or_single_client(w=0, event_listeners=[self.listener]) - db = client.pymongo_test + db = client.db coll = db.test_unacked_writes ops: list = [ (client.drop_database, [db.name], {}), - (db.create_collection, ["collection"], {}), - (db.drop_collection, ["collection"], {}), + (db.create_collection, ["coll"], {}), + (db.drop_collection, ["coll"], {}), ] ops.extend(self.collection_write_ops(coll)) self._test_unacknowledged_ops(client, *ops) @@ -869,7 +869,7 @@ def test_session_not_copyable(self): self.assertRaises(TypeError, lambda: copy.copy(s)) def test_nested_session_binding(self): - coll = self.client.pymongo_test.test + coll = self.client.db.coll coll.insert_one({"x": 1}) session1 = self.client.start_session() @@ -920,7 +920,7 @@ def test_nested_session_binding(self): session2.end_session() def test_session_binding_end_session(self): - coll = self.client.pymongo_test.test + coll = self.client.db.coll coll.insert_one({"x": 1}) with self.client.start_session().bind() as s1: @@ -938,7 +938,7 @@ def test_session_binding_end_session(self): def test_getmore_preserves_lsid_after_session_support_lost(self): listener = OvertCommandListener() client = self.rs_or_single_client(event_listeners=[listener], maxPoolSize=1) - coll = client.pymongo_test.test + coll = client.db.coll coll.drop() coll.insert_many([{"x": i} for i in range(10)]) self.addCleanup(coll.drop) @@ -978,8 +978,8 @@ def setUp(self): super().setUp() self.listener = SessionTestListener() self.client = self.rs_or_single_client(event_listeners=[self.listener]) - self.client.pymongo_test.drop_collection("test") - self.client.pymongo_test.create_collection("test") + self.client.db.drop_collection("coll") + self.client.db.create_collection("coll") @client_context.require_no_standalone def test_core(self): @@ -987,7 +987,7 @@ def test_core(self): self.assertIsNone(sess.cluster_time) self.assertIsNone(sess.operation_time) self.listener.reset() - self.client.pymongo_test.test.find_one(session=sess) + self.client.db.coll.find_one(session=sess) started = self.listener.started_events[0] cmd = started.command self.assertIsNone(cmd.get("readConcern")) @@ -998,11 +998,11 @@ def test_core(self): self.assertEqual(op_time, reply.get("operationTime")) # No explicit session - self.client.pymongo_test.test.insert_one({}) + self.client.db.coll.insert_one({}) self.assertEqual(sess.operation_time, op_time) self.listener.reset() try: - self.client.pymongo_test.command("doesntexist", session=sess) + self.client.db.command("doesntexist", session=sess) except: pass failed = self.listener.failed_events[0] @@ -1030,7 +1030,7 @@ def test_core(self): self.assertEqual(sess.operation_time, sess2.operation_time) def _test_reads(self, op, exception=None): - coll = self.client.pymongo_test.test + coll = self.client.db.coll with self.client.start_session() as sess: coll.find_one({}, session=sess) operation_time = sess.operation_time @@ -1071,7 +1071,7 @@ def find_raw(coll, session): self._test_reads(lambda coll, session: coll.estimated_document_count(session=session)) def _test_writes(self, op): - coll = self.client.pymongo_test.test + coll = self.client.db.coll with self.client.start_session() as sess: op(coll, sess) operation_time = sess.operation_time @@ -1122,7 +1122,7 @@ def test_writes(self): self._test_writes(lambda coll, session: coll.drop_indexes(session=session)) def _test_no_read_concern(self, op): - coll = self.client.pymongo_test.test + coll = self.client.db.coll with self.client.start_session() as sess: coll.find_one({}, session=sess) operation_time = sess.operation_time @@ -1138,7 +1138,7 @@ def test_explain_does_not_include_read_concern(self): @client_context.require_no_standalone def test_get_more_does_not_include_read_concern(self): - coll = self.client.pymongo_test.test + coll = self.client.db.coll with self.client.start_session() as sess: coll.find_one({}, session=sess) operation_time = sess.operation_time @@ -1154,9 +1154,9 @@ def test_get_more_does_not_include_read_concern(self): def test_session_not_causal(self): with self.client.start_session(causal_consistency=False) as s: - self.client.pymongo_test.test.insert_one({}, session=s) + self.client.db.coll.insert_one({}, session=s) self.listener.reset() - self.client.pymongo_test.test.find_one({}, session=s) + self.client.db.coll.find_one({}, session=s) act = ( self.listener.started_events[0] .command.get("readConcern", {}) @@ -1167,9 +1167,9 @@ def test_session_not_causal(self): @client_context.require_standalone def test_server_not_causal(self): with self.client.start_session(causal_consistency=True) as s: - self.client.pymongo_test.test.insert_one({}, session=s) + self.client.db.coll.insert_one({}, session=s) self.listener.reset() - self.client.pymongo_test.test.find_one({}, session=s) + self.client.db.coll.find_one({}, session=s) act = ( self.listener.started_events[0] .command.get("readConcern", {}) @@ -1180,7 +1180,7 @@ def test_server_not_causal(self): @client_context.require_no_standalone def test_read_concern(self): with self.client.start_session(causal_consistency=True) as s: - coll = self.client.pymongo_test.test + coll = self.client.db.coll coll.insert_one({}, session=s) self.listener.reset() coll.find_one({}, session=s) @@ -1200,14 +1200,14 @@ def test_read_concern(self): @client_context.require_no_standalone def test_cluster_time_with_server_support(self): self.listener.reset() - self.client.pymongo_test.test.find_one({}) + self.client.db.coll.find_one({}) after_cluster_time = self.listener.started_events[0].command.get("$clusterTime") self.assertIsNotNone(after_cluster_time) @client_context.require_standalone def test_cluster_time_no_server_support(self): self.listener.reset() - self.client.pymongo_test.test.find_one({}) + self.client.db.coll.find_one({}) after_cluster_time = self.listener.started_events[0].command.get("$clusterTime") self.assertIsNone(after_cluster_time) @@ -1222,53 +1222,53 @@ def setUp(self): def test_cluster_time(self): listener = SessionTestListener() client = self.rs_or_single_client(event_listeners=[listener]) - collection = client.pymongo_test.collection + coll = client.db.coll # Prepare for tests of find() and aggregate(). - collection.insert_many([{} for _ in range(10)]) - self.addCleanup(collection.drop) - self.addCleanup(client.pymongo_test.collection2.drop) + coll.insert_many([{} for _ in range(10)]) + self.addCleanup(coll.drop) + self.addCleanup(client.db.coll2.drop) def rename_and_drop(): - # Ensure collection exists. - collection.insert_one({}) - collection.rename("collection2") - client.pymongo_test.collection2.drop() + # Ensure coll exists. + coll.insert_one({}) + coll.rename("coll2") + client.db.coll2.drop() def insert_and_find(): - cursor = collection.find().batch_size(1) + cursor = coll.find().batch_size(1) for _ in range(10): # Advance the cluster time. - collection.insert_one({}) + coll.insert_one({}) next(cursor) cursor.close() def insert_and_aggregate(): - cursor = (collection.aggregate([], batchSize=1)).batch_size(1) + cursor = (coll.aggregate([], batchSize=1)).batch_size(1) for _ in range(5): # Advance the cluster time. - collection.insert_one({}) + coll.insert_one({}) next(cursor) cursor.close() def aggregate(): - (collection.aggregate([])).to_list() + (coll.aggregate([])).to_list() ops = [ # Tests from Driver Sessions Spec. ("ping", lambda: client.admin.command("ping")), ("aggregate", lambda: aggregate()), - ("find", lambda: collection.find().to_list()), - ("insert_one", lambda: collection.insert_one({})), + ("find", lambda: coll.find().to_list()), + ("insert_one", lambda: coll.insert_one({})), # Additional PyMongo tests. ("insert_and_find", insert_and_find), ("insert_and_aggregate", insert_and_aggregate), - ("update_one", lambda: collection.update_one({}, {"$set": {"x": 1}})), - ("update_many", lambda: collection.update_many({}, {"$set": {"x": 1}})), - ("delete_one", lambda: collection.delete_one({})), - ("delete_many", lambda: collection.delete_many({})), - ("bulk_write", lambda: collection.bulk_write([InsertOne({})])), + ("update_one", lambda: coll.update_one({}, {"$set": {"x": 1}})), + ("update_many", lambda: coll.update_many({}, {"$set": {"x": 1}})), + ("delete_one", lambda: coll.delete_one({})), + ("delete_many", lambda: coll.delete_many({})), + ("bulk_write", lambda: coll.bulk_write([InsertOne({})])), ("rename_and_drop", rename_and_drop), ] @@ -1277,7 +1277,7 @@ def aggregate(): # Call f() twice, insert to advance clusterTime, call f() again. f() f() - collection.insert_one({}) + coll.insert_one({}) f() self.assertGreaterEqual(len(listener.started_events), 1) @@ -1314,7 +1314,7 @@ def test_cluster_time_not_used_by_sdam(self): self.assertEqual(c1._topology.max_cluster_time(), cluster_time) # Advance the server's $clusterTime by performing an insert via another client. - self.db.test.insert_one({"advance": "$clusterTime"}) + self.db.coll.insert_one({"advance": "$clusterTime"}) # Wait until the client C1 processes the next pair of SDAM heartbeat started + succeeded events. heartbeat_listener.reset() diff --git a/test/test_ssl.py b/test/test_ssl.py index 77bb086ecb..01775591ae 100644 --- a/test/test_ssl.py +++ b/test/test_ssl.py @@ -133,9 +133,7 @@ class TestSSL(IntegrationTest): saved_port: int def assertClientWorks(self, client): - coll = client.pymongo_test.ssl_test.with_options( - write_concern=WriteConcern(w=client_context.w) - ) + coll = client.db.ssl_test.with_options(write_concern=WriteConcern(w=client_context.w)) coll.drop() coll.insert_one({"ssl": True}) self.assertTrue((coll.find_one())["ssl"]) @@ -559,7 +557,7 @@ def test_mongodb_x509_auth(self): ) with self.assertRaises(OperationFailure): - noauth.pymongo_test.test.find_one() + noauth.db.coll.find_one() listener = EventListener() auth = self.simple_client( @@ -572,7 +570,7 @@ def test_mongodb_x509_auth(self): ) # No error - auth.pymongo_test.test.find_one() + auth.db.coll.find_one() names = listener.started_command_names() if client_context.version.at_least(4, 4, -1): # Speculative auth skips the authenticate command. @@ -589,14 +587,14 @@ def test_mongodb_x509_auth(self): uri, ssl=True, tlsAllowInvalidCertificates=True, tlsCertificateKeyFile=CLIENT_PEM ) # No error - client.pymongo_test.test.find_one() + client.db.coll.find_one() uri = "mongodb://%s:%d/?authMechanism=MONGODB-X509" % (host, port) client = self.simple_client( uri, ssl=True, tlsAllowInvalidCertificates=True, tlsCertificateKeyFile=CLIENT_PEM ) # No error - client.pymongo_test.test.find_one() + client.db.coll.find_one() # Auth should fail if username and certificate do not match uri = "mongodb://%s@%s:%d/?authMechanism=MONGODB-X509" % ( quote_plus("not the username"), @@ -609,7 +607,7 @@ def test_mongodb_x509_auth(self): ) with self.assertRaises(OperationFailure): - bad_client.pymongo_test.test.find_one() + bad_client.db.coll.find_one() bad_client = self.simple_client( client_context.pair, @@ -621,7 +619,7 @@ def test_mongodb_x509_auth(self): ) with self.assertRaises(OperationFailure): - bad_client.pymongo_test.test.find_one() + bad_client.db.coll.find_one() # Invalid certificate (using CA certificate as client certificate) uri = "mongodb://%s@%s:%d/?authMechanism=MONGODB-X509" % ( diff --git a/test/test_threads.py b/test/test_threads.py index 3e469e28fe..28cfaa6856 100644 --- a/test/test_threads.py +++ b/test/test_threads.py @@ -106,15 +106,15 @@ def run(self): class TestThreads(IntegrationTest): def setUp(self): super().setUp() - self.db = self.client.pymongo_test + self.db = self.client.db def test_threading(self): - self.db.drop_collection("test") - self.db.test.insert_many([{"x": i} for i in range(1000)]) + self.db.drop_collection("coll") + self.db.coll.insert_many([{"x": i} for i in range(1000)]) threads = [] for _i in range(10): - t = SaveAndFind(self.db.test) + t = SaveAndFind(self.db.coll) t.start() threads.append(t) @@ -122,15 +122,15 @@ def test_threading(self): def test_safe_insert(self): self.db.drop_collection("test1") - self.db.test1.insert_one({"test": "insert"}) + self.db.coll1.insert_one({"test": "insert"}) self.db.drop_collection("test2") - self.db.test2.insert_one({"test": "insert"}) + self.db.coll2.insert_one({"test": "insert"}) - self.db.test2.create_index("test", unique=True) - self.db.test2.find_one() + self.db.coll2.create_index("test", unique=True) + self.db.coll2.find_one() - okay = Insert(self.db.test1, 2000, False) - error = Insert(self.db.test2, 2000, True) + okay = Insert(self.db.coll1, 2000, False) + error = Insert(self.db.coll2, 2000, True) error.start() okay.start() @@ -140,17 +140,17 @@ def test_safe_insert(self): def test_safe_update(self): self.db.drop_collection("test1") - self.db.test1.insert_one({"test": "update"}) - self.db.test1.insert_one({"test": "unique"}) + self.db.coll1.insert_one({"test": "update"}) + self.db.coll1.insert_one({"test": "unique"}) self.db.drop_collection("test2") - self.db.test2.insert_one({"test": "update"}) - self.db.test2.insert_one({"test": "unique"}) + self.db.coll2.insert_one({"test": "update"}) + self.db.coll2.insert_one({"test": "unique"}) - self.db.test2.create_index("test", unique=True) - self.db.test2.find_one() + self.db.coll2.create_index("test", unique=True) + self.db.coll2.find_one() - okay = Update(self.db.test1, 2000, False) - error = Update(self.db.test2, 2000, True) + okay = Update(self.db.coll1, 2000, False) + error = Update(self.db.coll2, 2000, True) error.start() okay.start() diff --git a/test/test_transactions.py b/test/test_transactions.py index a509f3336f..897286c847 100644 --- a/test/test_transactions.py +++ b/test/test_transactions.py @@ -105,8 +105,8 @@ def test_transaction_options_validation(self): def test_transaction_write_concern_override(self): """Test txn overrides Client/Database/Collection write_concern.""" client = self.rs_client(w=0) - db = client.test - coll = db.test + db = client.db + coll = db.coll coll.insert_one({}) with client.start_session() as s: with s.start_transaction(write_concern=WriteConcern(w=1)): @@ -159,7 +159,7 @@ def test_unpin_for_next_transaction(self): # to avoid false positives. client = self.rs_client(client_context.mongos_seeds(), localThresholdMS=1000) wait_until(lambda: len(client.nodes) > 1, "discover both mongoses") - coll = client.test.test + coll = client.db.coll # Create the collection. coll.insert_one({}) with client.start_session() as s: @@ -186,7 +186,7 @@ def test_unpin_for_non_transaction_operation(self): # to avoid false positives. client = self.rs_client(client_context.mongos_seeds(), localThresholdMS=1000) wait_until(lambda: len(client.nodes) > 1, "discover both mongoses") - coll = client.test.test + coll = client.db.coll # Create the collection. coll.insert_one({}) with client.start_session() as s: @@ -209,8 +209,8 @@ def test_unpin_for_non_transaction_operation(self): @client_context.require_version_min(4, 3, 4) def test_create_collection(self): client = client_context.client - db = client.pymongo_test - coll = db.test_create_collection + db = client.db + coll = db.coll self.addCleanup(coll.drop) # Use with_transaction to avoid StaleConfig errors on sharded clusters. @@ -236,7 +236,7 @@ def create_and_insert(session): @client_context.require_transactions def test_gridfs_does_not_support_transactions(self): client = client_context.client - db = client.pymongo_test + db = client.db gfs = GridFS(db) bucket = GridFSBucket(db) @@ -321,7 +321,7 @@ def test_transaction_starts_with_batched_write(self): # split. listener = OvertCommandListener() client = self.rs_client(event_listeners=[listener]) - coll = client[self.db.name].test + coll = client[self.db.name].coll coll.delete_many({}) listener.reset() self.addCleanup(coll.drop) @@ -349,7 +349,7 @@ def test_transaction_starts_with_batched_write(self): @client_context.require_transactions def test_transaction_direct_connection(self): client = self.single_client() - coll = client.pymongo_test.test + coll = client.db.coll # Make sure the collection exists. coll.insert_one({}) @@ -395,7 +395,7 @@ def test_transaction_pool_cleared_error_labelled_transient(self): with self.assertRaises(AutoReconnect) as context: with c.start_session() as session: with session.start_transaction(): - server = c._select_server(writable_server_selector, session, "test") + server = c._select_server(writable_server_selector, session, "coll") # Pause the server's pool, causing it to fail connection checkout. server.pool.state = PoolState.PAUSED with c._checkout(server, session): @@ -453,10 +453,10 @@ def callback(_): with self.client.start_session() as s: self.assertEqual(s.with_transaction(callback), "Foo") - self.db.test.insert_one({}) + self.db.list_collection_names.insert_one({}) def callback2(session): - self.db.test.insert_one({}, session=session) + self.db.coll.insert_one({}, session=session) return "Foo" with self.client.start_session() as s: @@ -477,7 +477,7 @@ def callback(_): def test_3_1_callback_not_retried_after_timeout(self): listener = OvertCommandListener() client = self.rs_client(event_listeners=[listener]) - coll = client[self.db.name].test + coll = client[self.db.name].coll def callback(session): coll.insert_one({}, session=session) @@ -507,7 +507,7 @@ def callback(session): def test_3_2_callback_not_retried_after_commit_timeout(self): listener = OvertCommandListener() client = self.rs_client(event_listeners=[listener]) - coll = client[self.db.name].test + coll = client[self.db.name].coll def callback(session): coll.insert_one({}, session=session) @@ -541,7 +541,7 @@ def callback(session): def test_3_3_commit_not_retried_after_timeout(self): listener = OvertCommandListener() client = self.rs_client(event_listeners=[listener]) - coll = client[self.db.name].test + coll = client[self.db.name].coll def callback(session): coll.insert_one({}, session=session) @@ -579,7 +579,7 @@ def callback(session): def test_callback_not_retried_after_csot_timeout(self): listener = OvertCommandListener() client = self.rs_client(event_listeners=[listener]) - coll = client[self.db.name].test + coll = client[self.db.name].coll def callback(session): coll.insert_one({}, session=session) @@ -611,7 +611,7 @@ def callback(session): @client_context.require_transactions def test_in_transaction_property(self): client = client_context.client - coll = client.test.testcollection + coll = client.db.collcollection coll.insert_one({}) self.addCleanup(coll.drop) @@ -648,7 +648,7 @@ def callback(session): @client_context.require_transactions def test_4_retry_backoff_is_enforced(self): client = client_context.client - coll = client[self.db.name].test + coll = client[self.db.name].coll end = start = no_backoff_time = 0 # Make random.random always return 0 (no backoff) @@ -709,7 +709,7 @@ def test_case_1(self): # Write concern not inherited from collection object inside transaction # Create a MongoClient running against a configured sharded/replica set/load balanced cluster. client = client_context.client - coll = client[self.db.name].test + coll = client[self.db.name].coll coll.delete_many({}) # Start a new session on the client. with client.start_session() as s: diff --git a/test/test_typing.py b/test/test_typing.py index 17dc21b4e0..8d186814e9 100644 --- a/test/test_typing.py +++ b/test/test_typing.py @@ -118,11 +118,11 @@ class TestPymongo(IntegrationTest): def setUp(self): super().setUp() - self.coll = self.client.test.test + self.coll = self.client.db.coll def test_insert_find(self) -> None: doc = {"my": "doc"} - coll2 = self.client.test.test2 + coll2 = self.client.db.coll2 result = self.coll.insert_one(doc) self.assertEqual(result.inserted_id, doc["_id"]) retrieved = self.coll.find_one({"_id": doc["_id"]}) @@ -219,7 +219,7 @@ def test_list_databases(self) -> None: def test_default_document_type(self) -> None: client = self.rs_or_single_client() self.addCleanup(client.close) - coll = client.test.test + coll = client.db.coll doc = {"my": "doc"} coll.insert_one(doc) retrieved = coll.find_one({"_id": doc["_id"]}) @@ -227,7 +227,7 @@ def test_default_document_type(self) -> None: retrieved["a"] = 1 def test_aggregate_pipeline(self) -> None: - coll3 = self.client.test.test3 + coll3 = self.client.db.coll3 coll3.insert_many( [ {"x": 1, "tags": ["dog", "cat"]}, @@ -406,7 +406,7 @@ class TestDocumentType(PyMongoTestCase): @only_type_check def test_default(self) -> None: client: MongoClient = MongoClient() - coll = client.test.test + coll = client.db.coll retrieved = coll.find_one({"_id": "foo"}) assert retrieved is not None retrieved["a"] = 1 @@ -414,7 +414,7 @@ def test_default(self) -> None: @only_type_check def test_explicit_document_type(self) -> None: client: MongoClient[Dict[str, Any]] = MongoClient() - coll = client.test.test + coll = client.db.coll retrieved = coll.find_one({"_id": "foo"}) assert retrieved is not None retrieved["a"] = 1 @@ -422,7 +422,7 @@ def test_explicit_document_type(self) -> None: @only_type_check def test_typeddict_document_type(self) -> None: client: MongoClient[Movie] = MongoClient() - coll = client.test.test + coll = client.db.coll retrieved = coll.find_one({"_id": "foo"}) assert retrieved is not None assert retrieved["year"] == 1 @@ -431,7 +431,7 @@ def test_typeddict_document_type(self) -> None: @only_type_check def test_typeddict_document_type_insertion(self) -> None: client: MongoClient[Movie] = MongoClient() - coll = client.test.test + coll = client.db.coll mov = {"name": "THX-1138", "year": 1971} movie = Movie(name="THX-1138", year=1971) coll.insert_one(mov) # type: ignore[arg-type] @@ -453,7 +453,7 @@ def test_typeddict_document_type_insertion(self) -> None: @only_type_check def test_bulk_write_document_type_insertion(self): client: MongoClient[MovieWithId] = MongoClient() - coll: Collection[MovieWithId] = client.test.test + coll: Collection[MovieWithId] = client.db.coll coll.bulk_write( [InsertOne(Movie({"name": "THX-1138", "year": 1971}))] # type:ignore[arg-type] ) @@ -470,7 +470,7 @@ def test_bulk_write_document_type_insertion(self): @only_type_check def test_bulk_write_document_type_replacement(self): client: MongoClient[MovieWithId] = MongoClient() - coll: Collection[MovieWithId] = client.test.test + coll: Collection[MovieWithId] = client.db.coll coll.bulk_write( [ReplaceOne({}, Movie({"name": "THX-1138", "year": 1971}))] # type:ignore[arg-type] ) @@ -517,7 +517,7 @@ def test_typeddict_find_notrequired(self): if NotRequired is None or ImplicitMovie is None: raise unittest.SkipTest("Python 3.11+ is required to use NotRequired.") client: MongoClient[ImplicitMovie] = self.rs_or_single_client() - coll = client.test.test + coll = client.db.coll coll.insert_one(ImplicitMovie(name="THX-1138", year=1971)) out = coll.find_one({}) assert out is not None @@ -527,7 +527,7 @@ def test_typeddict_find_notrequired(self): @only_type_check def test_raw_bson_document_type(self) -> None: client = MongoClient(document_class=RawBSONDocument) - coll = client.test.test + coll = client.db.coll retrieved = coll.find_one({"_id": "foo"}) assert retrieved is not None assert len(retrieved.raw) > 0 @@ -535,7 +535,7 @@ def test_raw_bson_document_type(self) -> None: @only_type_check def test_son_document_type(self) -> None: client = MongoClient(document_class=SON[str, Any]) - coll = client.test.test + coll = client.db.coll retrieved = coll.find_one({"_id": "foo"}) assert retrieved is not None retrieved["a"] = 1 @@ -546,9 +546,9 @@ def test_son_document_type_runtime(self) -> None: @only_type_check def test_create_index(self) -> None: client: MongoClient[Dict[str, str]] = MongoClient("test") - db = client.test + db = client.db with client.start_session() as session: - index = db.test.create_index([("user_id", ASCENDING)], unique=True, session=session) + index = db.coll.create_index([("user_id", ASCENDING)], unique=True, session=session) assert isinstance(index, str) diff --git a/test/test_unified_format.py b/test/test_unified_format.py index a55f810473..92dcbea07f 100644 --- a/test/test_unified_format.py +++ b/test/test_unified_format.py @@ -82,13 +82,13 @@ def test_type(self): self.match_evaluator.match_result( { "operationType": "insert", - "ns": {"db": "change-stream-tests", "coll": "test"}, + "ns": {"db": "change-stream-tests", "coll": "coll"}, "fullDocument": {"_id": {"$$type": "objectId"}, "x": 1}, }, { "operationType": "insert", "fullDocument": {"_id": ObjectId("5fc93511ac93941052098f0c"), "x": 1}, - "ns": {"db": "change-stream-tests", "coll": "test"}, + "ns": {"db": "change-stream-tests", "coll": "coll"}, }, ) diff --git a/test/test_versioned_api_integration.py b/test/test_versioned_api_integration.py index c4ee7856f3..62529dae6b 100644 --- a/test/test_versioned_api_integration.py +++ b/test/test_versioned_api_integration.py @@ -46,7 +46,7 @@ def assertServerApiInAllCommands(self, events): def test_command_options(self): listener = OvertCommandListener() client = self.rs_or_single_client(server_api=ServerApi("1"), event_listeners=[listener]) - coll = client.test.test + coll = client.db.coll coll.insert_many([{} for _ in range(100)]) self.addCleanup(coll.delete_many, {}) coll.find(batch_size=25).to_list() @@ -58,7 +58,7 @@ def test_command_options(self): def test_command_options_txn(self): listener = OvertCommandListener() client = self.rs_or_single_client(server_api=ServerApi("1"), event_listeners=[listener]) - coll = client.test.test + coll = client.db.coll coll.insert_many([{} for _ in range(100)]) self.addCleanup(coll.delete_many, {}) @@ -66,7 +66,7 @@ def test_command_options_txn(self): with client.start_session() as s, s.start_transaction(): coll.insert_many([{} for _ in range(100)], session=s) coll.find(batch_size=25, session=s).to_list() - client.test.command("find", "test", session=s) + client.db.command("find", "db", session=s) self.assertServerApiInAllCommands(listener.started_events) diff --git a/test/transactions-convenient-api/unified/callback-aborts.json b/test/transactions-convenient-api/unified/callback-aborts.json index dc8f7fb5a4..6083061e30 100644 --- a/test/transactions-convenient-api/unified/callback-aborts.json +++ b/test/transactions-convenient-api/unified/callback-aborts.json @@ -37,7 +37,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -49,7 +49,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "withTransaction-tests", "documents": [] } @@ -151,7 +151,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "withTransaction-tests", "documents": [] } @@ -181,7 +181,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "withTransaction-tests", "documents": [] } @@ -332,7 +332,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "withTransaction-tests", "documents": [ { diff --git a/test/transactions-convenient-api/unified/callback-commits.json b/test/transactions-convenient-api/unified/callback-commits.json index edda386418..b6e6f6661b 100644 --- a/test/transactions-convenient-api/unified/callback-commits.json +++ b/test/transactions-convenient-api/unified/callback-commits.json @@ -37,7 +37,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -49,7 +49,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "withTransaction-tests", "documents": [] } @@ -199,7 +199,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "withTransaction-tests", "documents": [ { @@ -405,7 +405,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "withTransaction-tests", "documents": [ { diff --git a/test/transactions-convenient-api/unified/callback-retry.json b/test/transactions-convenient-api/unified/callback-retry.json index 277dfa18ed..1c6e34b4de 100644 --- a/test/transactions-convenient-api/unified/callback-retry.json +++ b/test/transactions-convenient-api/unified/callback-retry.json @@ -37,7 +37,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -66,7 +66,7 @@ "collection": { "id": "collection1", "database": "database1", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -78,7 +78,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "withTransaction-tests", "documents": [] } @@ -306,7 +306,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "withTransaction-tests", "documents": [ { @@ -462,7 +462,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "withTransaction-tests", "documents": [] } diff --git a/test/transactions-convenient-api/unified/commit-retry-errorLabels.json b/test/transactions-convenient-api/unified/commit-retry-errorLabels.json index c6a4e44d62..c3e315ebf6 100644 --- a/test/transactions-convenient-api/unified/commit-retry-errorLabels.json +++ b/test/transactions-convenient-api/unified/commit-retry-errorLabels.json @@ -32,7 +32,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -44,7 +44,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "withTransaction-tests", "documents": [] } @@ -217,7 +217,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "withTransaction-tests", "documents": [ { diff --git a/test/transactions-convenient-api/unified/commit-retry.json b/test/transactions-convenient-api/unified/commit-retry.json index 928f0167e4..018a644c50 100644 --- a/test/transactions-convenient-api/unified/commit-retry.json +++ b/test/transactions-convenient-api/unified/commit-retry.json @@ -37,7 +37,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -49,7 +49,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "withTransaction-tests", "documents": [] } @@ -223,7 +223,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "withTransaction-tests", "documents": [ { @@ -410,7 +410,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "withTransaction-tests", "documents": [ { @@ -542,7 +542,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "withTransaction-tests", "documents": [] } diff --git a/test/transactions-convenient-api/unified/commit-transienttransactionerror-4.2.json b/test/transactions-convenient-api/unified/commit-transienttransactionerror-4.2.json index 0f5a782452..2da2a71047 100644 --- a/test/transactions-convenient-api/unified/commit-transienttransactionerror-4.2.json +++ b/test/transactions-convenient-api/unified/commit-transienttransactionerror-4.2.json @@ -38,7 +38,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -50,7 +50,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "withTransaction-tests", "documents": [] } @@ -280,7 +280,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "withTransaction-tests", "documents": [ { diff --git a/test/transactions-convenient-api/unified/commit-transienttransactionerror.json b/test/transactions-convenient-api/unified/commit-transienttransactionerror.json index dd5158d813..cc642e2c83 100644 --- a/test/transactions-convenient-api/unified/commit-transienttransactionerror.json +++ b/test/transactions-convenient-api/unified/commit-transienttransactionerror.json @@ -38,7 +38,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -50,7 +50,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "withTransaction-tests", "documents": [] } @@ -280,7 +280,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "withTransaction-tests", "documents": [ { @@ -514,7 +514,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "withTransaction-tests", "documents": [ { @@ -748,7 +748,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "withTransaction-tests", "documents": [ { @@ -982,7 +982,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "withTransaction-tests", "documents": [ { diff --git a/test/transactions-convenient-api/unified/commit-writeconcernerror.json b/test/transactions-convenient-api/unified/commit-writeconcernerror.json index 568f7ede42..6bfbc7f0de 100644 --- a/test/transactions-convenient-api/unified/commit-writeconcernerror.json +++ b/test/transactions-convenient-api/unified/commit-writeconcernerror.json @@ -37,7 +37,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -49,7 +49,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "withTransaction-tests", "documents": [] } @@ -224,7 +224,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "withTransaction-tests", "documents": [ { @@ -400,7 +400,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "withTransaction-tests", "documents": [ { @@ -532,7 +532,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "withTransaction-tests", "documents": [ { @@ -664,7 +664,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "withTransaction-tests", "documents": [ { @@ -798,7 +798,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "withTransaction-tests", "documents": [ { diff --git a/test/transactions-convenient-api/unified/commit.json b/test/transactions-convenient-api/unified/commit.json index 5684d5ee89..e4f6609001 100644 --- a/test/transactions-convenient-api/unified/commit.json +++ b/test/transactions-convenient-api/unified/commit.json @@ -37,7 +37,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -49,7 +49,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "withTransaction-tests", "documents": [] } @@ -195,7 +195,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "withTransaction-tests", "documents": [ { @@ -381,7 +381,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "withTransaction-tests", "documents": [ { diff --git a/test/transactions-convenient-api/unified/transaction-options.json b/test/transactions-convenient-api/unified/transaction-options.json index b1a74c5fd1..33341eadfe 100644 --- a/test/transactions-convenient-api/unified/transaction-options.json +++ b/test/transactions-convenient-api/unified/transaction-options.json @@ -37,7 +37,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -49,7 +49,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "withTransaction-tests", "documents": [] } @@ -147,7 +147,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "withTransaction-tests", "documents": [ { @@ -189,7 +189,7 @@ "collection": { "id": "collection1", "database": "database1", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -290,7 +290,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "withTransaction-tests", "documents": [ { @@ -416,7 +416,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "withTransaction-tests", "documents": [ { @@ -524,7 +524,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "withTransaction-tests", "documents": [ { @@ -656,7 +656,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "withTransaction-tests", "documents": [ { @@ -698,7 +698,7 @@ "collection": { "id": "collection1", "database": "database1", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -805,7 +805,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "withTransaction-tests", "documents": [ { diff --git a/test/transactions/unified/abort.json b/test/transactions/unified/abort.json index c151a7d0c6..5cdfbf6936 100644 --- a/test/transactions/unified/abort.json +++ b/test/transactions/unified/abort.json @@ -37,7 +37,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -49,7 +49,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -222,7 +222,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -317,7 +317,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -419,7 +419,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -444,7 +444,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -477,7 +477,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -579,7 +579,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -776,7 +776,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -818,7 +818,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } diff --git a/test/transactions/unified/backpressure-retryable-abort.json b/test/transactions/unified/backpressure-retryable-abort.json index 3a2a3b4368..9e6e26b924 100644 --- a/test/transactions/unified/backpressure-retryable-abort.json +++ b/test/transactions/unified/backpressure-retryable-abort.json @@ -32,7 +32,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -44,7 +44,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -206,7 +206,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -332,7 +332,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } diff --git a/test/transactions/unified/backpressure-retryable-commit.json b/test/transactions/unified/backpressure-retryable-commit.json index 844ed25ab4..d1ff9b3f60 100644 --- a/test/transactions/unified/backpressure-retryable-commit.json +++ b/test/transactions/unified/backpressure-retryable-commit.json @@ -32,7 +32,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -44,7 +44,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -211,7 +211,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -349,7 +349,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } diff --git a/test/transactions/unified/backpressure-retryable-reads.json b/test/transactions/unified/backpressure-retryable-reads.json index a859ec4bda..0afe8ea8cb 100644 --- a/test/transactions/unified/backpressure-retryable-reads.json +++ b/test/transactions/unified/backpressure-retryable-reads.json @@ -32,7 +32,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -44,7 +44,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } diff --git a/test/transactions/unified/backpressure-retryable-writes.json b/test/transactions/unified/backpressure-retryable-writes.json index 6cbf450e5f..e0712e025a 100644 --- a/test/transactions/unified/backpressure-retryable-writes.json +++ b/test/transactions/unified/backpressure-retryable-writes.json @@ -32,7 +32,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -44,7 +44,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -230,7 +230,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -340,7 +340,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -429,7 +429,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } diff --git a/test/transactions/unified/bulk.json b/test/transactions/unified/bulk.json index ece162518f..95a1756cfb 100644 --- a/test/transactions/unified/bulk.json +++ b/test/transactions/unified/bulk.json @@ -37,7 +37,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -49,7 +49,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -628,7 +628,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { diff --git a/test/transactions/unified/causal-consistency.json b/test/transactions/unified/causal-consistency.json index 52a6cb8180..8de044d3cf 100644 --- a/test/transactions/unified/causal-consistency.json +++ b/test/transactions/unified/causal-consistency.json @@ -40,7 +40,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -61,7 +61,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -245,7 +245,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -408,7 +408,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { diff --git a/test/transactions/unified/commit.json b/test/transactions/unified/commit.json index f033906940..0cfca0bdc3 100644 --- a/test/transactions/unified/commit.json +++ b/test/transactions/unified/commit.json @@ -37,7 +37,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -69,7 +69,7 @@ "collection": { "id": "collection1", "database": "database1", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -81,7 +81,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -254,7 +254,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -368,7 +368,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -521,7 +521,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -573,7 +573,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -602,7 +602,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -635,7 +635,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -915,7 +915,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -1066,7 +1066,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -1224,7 +1224,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { diff --git a/test/transactions/unified/count.json b/test/transactions/unified/count.json index 404b06beb6..b7087ec7cf 100644 --- a/test/transactions/unified/count.json +++ b/test/transactions/unified/count.json @@ -37,7 +37,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -49,7 +49,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -154,7 +154,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { diff --git a/test/transactions/unified/create-collection.json b/test/transactions/unified/create-collection.json index e190088b3b..5e6789aae6 100644 --- a/test/transactions/unified/create-collection.json +++ b/test/transactions/unified/create-collection.json @@ -32,7 +32,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -44,7 +44,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -57,7 +57,7 @@ "object": "database0", "name": "dropCollection", "arguments": { - "collection": "test" + "collection": "coll" } }, { @@ -69,7 +69,7 @@ "name": "createCollection", "arguments": { "session": "session0", - "collection": "test" + "collection": "coll" } }, { @@ -77,7 +77,7 @@ "name": "assertCollectionNotExists", "arguments": { "databaseName": "transaction-tests", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -89,7 +89,7 @@ "name": "assertCollectionExists", "arguments": { "databaseName": "transaction-tests", - "collectionName": "test" + "collectionName": "coll" } } ], @@ -100,7 +100,7 @@ { "commandStartedEvent": { "command": { - "drop": "test", + "drop": "coll", "writeConcern": { "$$exists": false } @@ -112,7 +112,7 @@ { "commandStartedEvent": { "command": { - "create": "test", + "create": "coll", "lsid": { "$$sessionLsid": "session0" }, @@ -162,7 +162,7 @@ "object": "database0", "name": "dropCollection", "arguments": { - "collection": "test" + "collection": "coll" } }, { @@ -191,7 +191,7 @@ "name": "assertCollectionNotExists", "arguments": { "databaseName": "transaction-tests", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -203,7 +203,7 @@ "name": "assertCollectionExists", "arguments": { "databaseName": "transaction-tests", - "collectionName": "test" + "collectionName": "coll" } } ], @@ -214,7 +214,7 @@ { "commandStartedEvent": { "command": { - "drop": "test", + "drop": "coll", "writeConcern": { "$$exists": false } @@ -226,7 +226,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 diff --git a/test/transactions/unified/create-index.json b/test/transactions/unified/create-index.json index 98d6e11547..f129d34b19 100644 --- a/test/transactions/unified/create-index.json +++ b/test/transactions/unified/create-index.json @@ -32,7 +32,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -44,7 +44,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -57,7 +57,7 @@ "object": "database0", "name": "dropCollection", "arguments": { - "collection": "test" + "collection": "coll" } }, { @@ -80,7 +80,7 @@ "name": "assertIndexNotExists", "arguments": { "databaseName": "transaction-tests", - "collectionName": "test", + "collectionName": "coll", "indexName": "t_1" } }, @@ -93,7 +93,7 @@ "name": "assertIndexExists", "arguments": { "databaseName": "transaction-tests", - "collectionName": "test", + "collectionName": "coll", "indexName": "t_1" } } @@ -175,7 +175,7 @@ "object": "database0", "name": "dropCollection", "arguments": { - "collection": "test" + "collection": "coll" } }, { @@ -187,7 +187,7 @@ "name": "createCollection", "arguments": { "session": "session0", - "collection": "test" + "collection": "coll" } }, { @@ -206,7 +206,7 @@ "name": "assertIndexNotExists", "arguments": { "databaseName": "transaction-tests", - "collectionName": "test", + "collectionName": "coll", "indexName": "t_1" } }, @@ -219,7 +219,7 @@ "name": "assertIndexExists", "arguments": { "databaseName": "transaction-tests", - "collectionName": "test", + "collectionName": "coll", "indexName": "t_1" } } diff --git a/test/transactions/unified/delete.json b/test/transactions/unified/delete.json index 4c1cae0a4e..6586707e73 100644 --- a/test/transactions/unified/delete.json +++ b/test/transactions/unified/delete.json @@ -37,7 +37,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -49,7 +49,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -251,7 +251,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -273,7 +273,7 @@ "collection": { "id": "collection_wc_majority", "database": "database0", - "collectionName": "test", + "collectionName": "coll", "collectionOptions": { "writeConcern": { "w": "majority" diff --git a/test/transactions/unified/error-labels-blockConnection.json b/test/transactions/unified/error-labels-blockConnection.json index 8da04d1005..0e92a50d4b 100644 --- a/test/transactions/unified/error-labels-blockConnection.json +++ b/test/transactions/unified/error-labels-blockConnection.json @@ -35,7 +35,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -47,7 +47,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -221,7 +221,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { diff --git a/test/transactions/unified/error-labels-errorLabels.json b/test/transactions/unified/error-labels-errorLabels.json index 1f95ad3419..3daa9fa09b 100644 --- a/test/transactions/unified/error-labels-errorLabels.json +++ b/test/transactions/unified/error-labels-errorLabels.json @@ -33,7 +33,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -45,7 +45,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -221,7 +221,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -409,7 +409,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { diff --git a/test/transactions/unified/error-labels.json b/test/transactions/unified/error-labels.json index 74ed750b07..b37ad2e60b 100644 --- a/test/transactions/unified/error-labels.json +++ b/test/transactions/unified/error-labels.json @@ -38,7 +38,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -50,7 +50,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -153,7 +153,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -269,7 +269,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -385,7 +385,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -501,7 +501,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -624,7 +624,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -876,7 +876,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -1049,7 +1049,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -1169,7 +1169,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -1327,7 +1327,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -1492,7 +1492,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -1625,7 +1625,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -1758,7 +1758,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -1926,7 +1926,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -2084,7 +2084,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -2249,7 +2249,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { diff --git a/test/transactions/unified/errors-client.json b/test/transactions/unified/errors-client.json index 00f1497c2d..4b2656e307 100644 --- a/test/transactions/unified/errors-client.json +++ b/test/transactions/unified/errors-client.json @@ -37,7 +37,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -49,7 +49,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } diff --git a/test/transactions/unified/errors.json b/test/transactions/unified/errors.json index 94a9cac207..6f812d76d2 100644 --- a/test/transactions/unified/errors.json +++ b/test/transactions/unified/errors.json @@ -37,7 +37,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -55,7 +55,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } diff --git a/test/transactions/unified/findOneAndDelete.json b/test/transactions/unified/findOneAndDelete.json index 7db9c872af..9c2575365f 100644 --- a/test/transactions/unified/findOneAndDelete.json +++ b/test/transactions/unified/findOneAndDelete.json @@ -37,7 +37,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -49,7 +49,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -190,7 +190,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -215,7 +215,7 @@ "collection": { "id": "collection_wc_majority", "database": "database0", - "collectionName": "test", + "collectionName": "coll", "collectionOptions": { "writeConcern": { "w": "majority" diff --git a/test/transactions/unified/findOneAndReplace.json b/test/transactions/unified/findOneAndReplace.json index f0742f0c60..b7b26c5f78 100644 --- a/test/transactions/unified/findOneAndReplace.json +++ b/test/transactions/unified/findOneAndReplace.json @@ -37,7 +37,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -49,7 +49,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -212,7 +212,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -245,7 +245,7 @@ "collection": { "id": "collection_wc_majority", "database": "database0", - "collectionName": "test", + "collectionName": "coll", "collectionOptions": { "writeConcern": { "w": "majority" diff --git a/test/transactions/unified/findOneAndUpdate.json b/test/transactions/unified/findOneAndUpdate.json index f5308efef3..79476f37ce 100644 --- a/test/transactions/unified/findOneAndUpdate.json +++ b/test/transactions/unified/findOneAndUpdate.json @@ -37,7 +37,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -49,7 +49,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -398,7 +398,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -431,7 +431,7 @@ "collection": { "id": "collection_wc_majority", "database": "database0", - "collectionName": "test", + "collectionName": "coll", "collectionOptions": { "writeConcern": { "w": "majority" diff --git a/test/transactions/unified/insert.json b/test/transactions/unified/insert.json index 9a80d8bf4b..5afdc95cd6 100644 --- a/test/transactions/unified/insert.json +++ b/test/transactions/unified/insert.json @@ -37,7 +37,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -55,7 +55,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -326,7 +326,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -571,7 +571,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -618,7 +618,7 @@ "collection": { "id": "collection_wc_majority", "database": "database1", - "collectionName": "test", + "collectionName": "coll", "collectionOptions": { "writeConcern": { "w": "majority" @@ -695,7 +695,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -717,7 +717,7 @@ "collection": { "id": "collection_wc_majority", "database": "database0", - "collectionName": "test", + "collectionName": "coll", "collectionOptions": { "writeConcern": { "w": "majority" @@ -875,7 +875,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { diff --git a/test/transactions/unified/isolation.json b/test/transactions/unified/isolation.json index 5d0a0139fb..8ead14cf13 100644 --- a/test/transactions/unified/isolation.json +++ b/test/transactions/unified/isolation.json @@ -37,7 +37,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -55,7 +55,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -157,7 +157,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -267,7 +267,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { diff --git a/test/transactions/unified/mongos-pin-auto.json b/test/transactions/unified/mongos-pin-auto.json index 27db520401..453284a269 100644 --- a/test/transactions/unified/mongos-pin-auto.json +++ b/test/transactions/unified/mongos-pin-auto.json @@ -31,7 +31,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -43,7 +43,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -222,7 +222,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -405,7 +405,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -490,7 +490,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -580,7 +580,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -670,7 +670,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -758,7 +758,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -850,7 +850,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -935,7 +935,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -1022,7 +1022,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -1107,7 +1107,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -1198,7 +1198,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -1287,7 +1287,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -1378,7 +1378,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -1474,7 +1474,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -1565,7 +1565,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -1650,7 +1650,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -1733,7 +1733,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -1816,7 +1816,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -1900,7 +1900,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -1991,7 +1991,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -2084,7 +2084,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -2174,7 +2174,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -2259,7 +2259,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -2349,7 +2349,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -2439,7 +2439,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -2529,7 +2529,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -2619,7 +2619,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -2707,7 +2707,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -2795,7 +2795,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -2887,7 +2887,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -2979,7 +2979,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -3064,7 +3064,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -3149,7 +3149,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -3236,7 +3236,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -3323,7 +3323,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -3408,7 +3408,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -3493,7 +3493,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -3584,7 +3584,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -3675,7 +3675,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -3764,7 +3764,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -3853,7 +3853,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -3944,7 +3944,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -4035,7 +4035,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -4131,7 +4131,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -4227,7 +4227,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -4318,7 +4318,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -4409,7 +4409,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -4494,7 +4494,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -4579,7 +4579,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -4662,7 +4662,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -4745,7 +4745,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -4828,7 +4828,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -4911,7 +4911,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -4995,7 +4995,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -5079,7 +5079,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -5170,7 +5170,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -5261,7 +5261,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -5354,7 +5354,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -5452,7 +5452,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { diff --git a/test/transactions/unified/mongos-recovery-token-errorLabels.json b/test/transactions/unified/mongos-recovery-token-errorLabels.json index 13345c6a29..0814d281c2 100644 --- a/test/transactions/unified/mongos-recovery-token-errorLabels.json +++ b/test/transactions/unified/mongos-recovery-token-errorLabels.json @@ -31,7 +31,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -43,7 +43,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -197,7 +197,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { diff --git a/test/transactions/unified/mongos-recovery-token.json b/test/transactions/unified/mongos-recovery-token.json index bb88aa16bd..3e80457753 100644 --- a/test/transactions/unified/mongos-recovery-token.json +++ b/test/transactions/unified/mongos-recovery-token.json @@ -32,7 +32,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -44,7 +44,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -202,7 +202,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -251,7 +251,7 @@ "collection": { "id": "collection1", "database": "database1", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -409,7 +409,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -558,7 +558,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } diff --git a/test/transactions/unified/mongos-unpin.json b/test/transactions/unified/mongos-unpin.json index 4d1ebc87bc..d082cd9d1c 100644 --- a/test/transactions/unified/mongos-unpin.json +++ b/test/transactions/unified/mongos-unpin.json @@ -27,7 +27,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -39,7 +39,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "mongos-unpin-db", "documents": [] } diff --git a/test/transactions/unified/pin-mongos.json b/test/transactions/unified/pin-mongos.json index c96f3f341f..3a8b22eb68 100644 --- a/test/transactions/unified/pin-mongos.json +++ b/test/transactions/unified/pin-mongos.json @@ -32,7 +32,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -44,7 +44,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -159,7 +159,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -290,7 +290,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -437,7 +437,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -600,7 +600,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -791,7 +791,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -915,7 +915,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -1030,7 +1030,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -1216,7 +1216,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -1268,7 +1268,7 @@ "collection": { "id": "collection1", "database": "database1", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -1449,7 +1449,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { diff --git a/test/transactions/unified/read-concern.json b/test/transactions/unified/read-concern.json index b3bd967c09..c9166b291d 100644 --- a/test/transactions/unified/read-concern.json +++ b/test/transactions/unified/read-concern.json @@ -49,7 +49,7 @@ "collection": { "id": "collection_rc_majority", "database": "database0", - "collectionName": "test", + "collectionName": "coll", "collectionOptions": { "readConcern": { "level": "majority" @@ -66,7 +66,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -240,7 +240,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -356,7 +356,7 @@ "long" ] }, - "collection": "test", + "collection": "coll", "batchSize": 3, "lsid": { "$$sessionLsid": "session0" @@ -408,7 +408,7 @@ "long" ] }, - "collection": "test", + "collection": "coll", "batchSize": 3, "lsid": { "$$sessionLsid": "session0" @@ -458,7 +458,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -595,7 +595,7 @@ "long" ] }, - "collection": "test", + "collection": "coll", "batchSize": 3, "lsid": { "$$sessionLsid": "session0" @@ -656,7 +656,7 @@ "long" ] }, - "collection": "test", + "collection": "coll", "batchSize": 3, "lsid": { "$$sessionLsid": "session0" @@ -706,7 +706,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -856,7 +856,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -996,7 +996,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -1165,7 +1165,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -1276,7 +1276,7 @@ "long" ] }, - "collection": "test", + "collection": "coll", "batchSize": 3, "lsid": { "$$sessionLsid": "session0" @@ -1328,7 +1328,7 @@ "long" ] }, - "collection": "test", + "collection": "coll", "batchSize": 3, "lsid": { "$$sessionLsid": "session0" @@ -1378,7 +1378,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -1510,7 +1510,7 @@ "long" ] }, - "collection": "test", + "collection": "coll", "batchSize": 3, "lsid": { "$$sessionLsid": "session0" @@ -1571,7 +1571,7 @@ "long" ] }, - "collection": "test", + "collection": "coll", "batchSize": 3, "lsid": { "$$sessionLsid": "session0" @@ -1621,7 +1621,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -1766,7 +1766,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -1901,7 +1901,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { diff --git a/test/transactions/unified/read-pref.json b/test/transactions/unified/read-pref.json index eda00bd10d..649e7b1ab2 100644 --- a/test/transactions/unified/read-pref.json +++ b/test/transactions/unified/read-pref.json @@ -37,21 +37,21 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { "collection": { "id": "collection_rp_primary", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { "collection": { "id": "collection_rp_secondary", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -63,7 +63,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -190,7 +190,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -335,7 +335,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -456,7 +456,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -564,7 +564,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -672,7 +672,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -714,7 +714,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { diff --git a/test/transactions/unified/reads.json b/test/transactions/unified/reads.json index 52e8457634..d7cbf11b7e 100644 --- a/test/transactions/unified/reads.json +++ b/test/transactions/unified/reads.json @@ -37,7 +37,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -49,7 +49,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -80,7 +80,7 @@ "collection": { "id": "collection1", "database": "database0", - "collectionName": "test", + "collectionName": "coll", "collectionOptions": { "readConcern": { "level": "majority" @@ -147,7 +147,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -258,7 +258,7 @@ "long" ] }, - "collection": "test", + "collection": "coll", "batchSize": 3, "lsid": { "$$sessionLsid": "session0" @@ -304,7 +304,7 @@ "long" ] }, - "collection": "test", + "collection": "coll", "batchSize": 3, "lsid": { "$$sessionLsid": "session0" @@ -348,7 +348,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -480,7 +480,7 @@ "long" ] }, - "collection": "test", + "collection": "coll", "batchSize": 3, "lsid": { "$$sessionLsid": "session0" @@ -535,7 +535,7 @@ "long" ] }, - "collection": "test", + "collection": "coll", "batchSize": 3, "lsid": { "$$sessionLsid": "session0" @@ -579,7 +579,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -683,7 +683,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { diff --git a/test/transactions/unified/retryable-abort-errorLabels.json b/test/transactions/unified/retryable-abort-errorLabels.json index 77a1b03eb0..5d0451f417 100644 --- a/test/transactions/unified/retryable-abort-errorLabels.json +++ b/test/transactions/unified/retryable-abort-errorLabels.json @@ -32,7 +32,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -44,7 +44,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -183,7 +183,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -298,7 +298,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -438,7 +438,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -578,7 +578,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -718,7 +718,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -858,7 +858,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -998,7 +998,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -1138,7 +1138,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -1278,7 +1278,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -1418,7 +1418,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -1558,7 +1558,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -1698,7 +1698,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -1838,7 +1838,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -1985,7 +1985,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -2132,7 +2132,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -2279,7 +2279,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -2426,7 +2426,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } diff --git a/test/transactions/unified/retryable-abort.json b/test/transactions/unified/retryable-abort.json index 381cfa91f8..91066ff099 100644 --- a/test/transactions/unified/retryable-abort.json +++ b/test/transactions/unified/retryable-abort.json @@ -37,7 +37,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -69,7 +69,7 @@ "collection": { "id": "collection1", "database": "database1", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -81,7 +81,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -217,7 +217,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -332,7 +332,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -454,7 +454,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -590,7 +590,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } diff --git a/test/transactions/unified/retryable-commit-errorLabels.json b/test/transactions/unified/retryable-commit-errorLabels.json index d3ce8b148e..6bfa7e70ed 100644 --- a/test/transactions/unified/retryable-commit-errorLabels.json +++ b/test/transactions/unified/retryable-commit-errorLabels.json @@ -32,7 +32,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -64,7 +64,7 @@ "collection": { "id": "collection1", "database": "database1", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -76,7 +76,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -197,7 +197,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -337,7 +337,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -482,7 +482,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -627,7 +627,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -772,7 +772,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -917,7 +917,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -1062,7 +1062,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -1207,7 +1207,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -1352,7 +1352,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -1497,7 +1497,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -1642,7 +1642,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -1794,7 +1794,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -1946,7 +1946,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -2098,7 +2098,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -2250,7 +2250,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -2400,7 +2400,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -2550,7 +2550,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { diff --git a/test/transactions/unified/retryable-commit.json b/test/transactions/unified/retryable-commit.json index b794c1c55c..e1cf71f3ab 100644 --- a/test/transactions/unified/retryable-commit.json +++ b/test/transactions/unified/retryable-commit.json @@ -37,7 +37,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -69,7 +69,7 @@ "collection": { "id": "collection1", "database": "database1", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -81,7 +81,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -204,7 +204,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -333,7 +333,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -515,7 +515,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -708,7 +708,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -854,7 +854,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { diff --git a/test/transactions/unified/retryable-writes.json b/test/transactions/unified/retryable-writes.json index 21ef22b8ab..04e45fd08b 100644 --- a/test/transactions/unified/retryable-writes.json +++ b/test/transactions/unified/retryable-writes.json @@ -37,7 +37,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -49,7 +49,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -337,7 +337,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -462,7 +462,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } diff --git a/test/transactions/unified/run-command.json b/test/transactions/unified/run-command.json index 7bd420ef74..3a84f31d61 100644 --- a/test/transactions/unified/run-command.json +++ b/test/transactions/unified/run-command.json @@ -37,7 +37,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -49,7 +49,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } diff --git a/test/transactions/unified/transaction-options-repl.json b/test/transactions/unified/transaction-options-repl.json index dc2cb77582..b33d0ce0cc 100644 --- a/test/transactions/unified/transaction-options-repl.json +++ b/test/transactions/unified/transaction-options-repl.json @@ -30,7 +30,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -42,7 +42,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -253,7 +253,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { diff --git a/test/transactions/unified/transaction-options.json b/test/transactions/unified/transaction-options.json index 78e4c8207b..58a960f8d2 100644 --- a/test/transactions/unified/transaction-options.json +++ b/test/transactions/unified/transaction-options.json @@ -37,7 +37,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -49,7 +49,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -240,7 +240,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -282,7 +282,7 @@ "collection": { "id": "collection1", "database": "database1", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -477,7 +477,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -687,7 +687,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -729,7 +729,7 @@ "collection": { "id": "collection1", "database": "database1", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -950,7 +950,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -992,7 +992,7 @@ "collection": { "id": "collection1", "database": "database1", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -1196,7 +1196,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -1237,7 +1237,7 @@ "collection": { "id": "collection1", "database": "database1", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -1427,7 +1427,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -1468,7 +1468,7 @@ "collection": { "id": "collection1", "database": "database1", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -1583,7 +1583,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -1624,7 +1624,7 @@ "collection": { "id": "collection1", "database": "database1", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -1738,7 +1738,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -1779,7 +1779,7 @@ "collection": { "id": "collection1", "database": "database1", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -1900,7 +1900,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -1941,7 +1941,7 @@ "collection": { "id": "collection1", "database": "database1", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -2067,7 +2067,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { diff --git a/test/transactions/unified/update.json b/test/transactions/unified/update.json index 8090fc9087..9975d07cc8 100644 --- a/test/transactions/unified/update.json +++ b/test/transactions/unified/update.json @@ -37,7 +37,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -49,7 +49,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -290,7 +290,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -324,7 +324,7 @@ "collection": { "id": "collection1", "database": "database0", - "collectionName": "test", + "collectionName": "coll", "collectionOptions": { "writeConcern": { "w": "majority" diff --git a/test/transactions/unified/write-concern.json b/test/transactions/unified/write-concern.json index 29d1977a82..5779c571ef 100644 --- a/test/transactions/unified/write-concern.json +++ b/test/transactions/unified/write-concern.json @@ -37,14 +37,14 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { "collection": { "id": "collection_w0", "database": "database0", - "collectionName": "test", + "collectionName": "coll", "collectionOptions": { "writeConcern": { "w": 0 @@ -61,7 +61,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -165,7 +165,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -267,7 +267,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -374,7 +374,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -473,7 +473,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -626,7 +626,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -739,7 +739,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -856,7 +856,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -957,7 +957,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -1051,7 +1051,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -1161,7 +1161,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -1274,7 +1274,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -1368,7 +1368,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -1466,7 +1466,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -1573,7 +1573,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { diff --git a/test/unified-test-format/valid-fail/operator-matchAsDocument.json b/test/unified-test-format/valid-fail/operator-matchAsDocument.json index 24f6be9cb8..559aa6d57c 100644 --- a/test/unified-test-format/valid-fail/operator-matchAsDocument.json +++ b/test/unified-test-format/valid-fail/operator-matchAsDocument.json @@ -11,7 +11,7 @@ "database": { "id": "database0", "client": "client0", - "databaseName": "test" + "databaseName": "db" } }, { @@ -25,7 +25,7 @@ "initialData": [ { "collectionName": "coll0", - "databaseName": "test", + "databaseName": "db", "documents": [ { "_id": 1, diff --git a/test/unified-test-format/valid-fail/operator-matchAsRoot.json b/test/unified-test-format/valid-fail/operator-matchAsRoot.json index ec6309418c..b3d8eadc14 100644 --- a/test/unified-test-format/valid-fail/operator-matchAsRoot.json +++ b/test/unified-test-format/valid-fail/operator-matchAsRoot.json @@ -11,7 +11,7 @@ "database": { "id": "database0", "client": "client0", - "databaseName": "test" + "databaseName": "db" } }, { @@ -25,7 +25,7 @@ "initialData": [ { "collectionName": "coll0", - "databaseName": "test", + "databaseName": "db", "documents": [ { "_id": 1, diff --git a/test/unified-test-format/valid-fail/returnDocument-enum-invalid.json b/test/unified-test-format/valid-fail/returnDocument-enum-invalid.json index ea425fb568..43f74b0cea 100644 --- a/test/unified-test-format/valid-fail/returnDocument-enum-invalid.json +++ b/test/unified-test-format/valid-fail/returnDocument-enum-invalid.json @@ -11,7 +11,7 @@ "database": { "id": "database0", "client": "client0", - "databaseName": "test" + "databaseName": "db" } }, { diff --git a/test/unified-test-format/valid-pass/expectedError-errorResponse.json b/test/unified-test-format/valid-pass/expectedError-errorResponse.json index 177b1baf56..427d821b3d 100644 --- a/test/unified-test-format/valid-pass/expectedError-errorResponse.json +++ b/test/unified-test-format/valid-pass/expectedError-errorResponse.json @@ -11,7 +11,7 @@ "database": { "id": "database0", "client": "client0", - "databaseName": "test" + "databaseName": "db" } }, { diff --git a/test/unified-test-format/valid-pass/expectedError-isClientError.json b/test/unified-test-format/valid-pass/expectedError-isClientError.json index 9c6beda588..9408267741 100644 --- a/test/unified-test-format/valid-pass/expectedError-isClientError.json +++ b/test/unified-test-format/valid-pass/expectedError-isClientError.json @@ -28,7 +28,7 @@ "database": { "id": "database0", "client": "client0", - "databaseName": "test" + "databaseName": "db" } } ], diff --git a/test/unified-test-format/valid-pass/operator-matchAsDocument.json b/test/unified-test-format/valid-pass/operator-matchAsDocument.json index fd8b514d4a..668fd44755 100644 --- a/test/unified-test-format/valid-pass/operator-matchAsDocument.json +++ b/test/unified-test-format/valid-pass/operator-matchAsDocument.json @@ -11,7 +11,7 @@ "database": { "id": "database0", "client": "client0", - "databaseName": "test" + "databaseName": "db" } }, { @@ -25,7 +25,7 @@ "initialData": [ { "collectionName": "coll0", - "databaseName": "test", + "databaseName": "db", "documents": [ { "_id": 1, diff --git a/test/unified-test-format/valid-pass/operator-matchAsRoot.json b/test/unified-test-format/valid-pass/operator-matchAsRoot.json index 1966e3b377..f83356592e 100644 --- a/test/unified-test-format/valid-pass/operator-matchAsRoot.json +++ b/test/unified-test-format/valid-pass/operator-matchAsRoot.json @@ -11,7 +11,7 @@ "database": { "id": "database0", "client": "client0", - "databaseName": "test" + "databaseName": "db" } }, { @@ -25,7 +25,7 @@ "initialData": [ { "collectionName": "coll0", - "databaseName": "test", + "databaseName": "db", "documents": [ { "_id": 1, diff --git a/test/unified-test-format/valid-pass/operator-type-number_alias.json b/test/unified-test-format/valid-pass/operator-type-number_alias.json index e628d0d777..777b036c98 100644 --- a/test/unified-test-format/valid-pass/operator-type-number_alias.json +++ b/test/unified-test-format/valid-pass/operator-type-number_alias.json @@ -11,7 +11,7 @@ "database": { "id": "database0", "client": "client0", - "databaseName": "test" + "databaseName": "db" } }, { @@ -25,7 +25,7 @@ "initialData": [ { "collectionName": "coll0", - "databaseName": "test", + "databaseName": "db", "documents": [] } ], diff --git a/test/unified-test-format/valid-pass/poc-change-streams.json b/test/unified-test-format/valid-pass/poc-change-streams.json index 50f0d06f08..adac2d3262 100644 --- a/test/unified-test-format/valid-pass/poc-change-streams.json +++ b/test/unified-test-format/valid-pass/poc-change-streams.json @@ -31,7 +31,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -58,7 +58,7 @@ "collection": { "id": "collection1", "database": "database1", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -72,13 +72,13 @@ "collection": { "id": "collection3", "database": "database2", - "collectionName": "test" + "collectionName": "coll" } } ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "change-stream-tests", "documents": [] }, @@ -88,7 +88,7 @@ "documents": [] }, { - "collectionName": "test", + "collectionName": "coll", "databaseName": "change-stream-tests-2", "documents": [] } @@ -200,7 +200,7 @@ "operationType": "insert", "ns": { "db": "change-stream-tests-2", - "coll": "test" + "coll": "coll" }, "fullDocument": { "_id": { @@ -217,7 +217,7 @@ "operationType": "insert", "ns": { "db": "change-stream-tests", - "coll": "test" + "coll": "coll" }, "fullDocument": { "_id": { @@ -329,7 +329,7 @@ "operationType": "insert", "ns": { "db": "change-stream-tests", - "coll": "test" + "coll": "coll" }, "fullDocument": { "_id": { @@ -346,7 +346,7 @@ "operationType": "insert", "ns": { "db": "change-stream-tests", - "coll": "test" + "coll": "coll" }, "fullDocument": { "_id": { @@ -363,7 +363,7 @@ "operationType": "insert", "ns": { "db": "change-stream-tests", - "coll": "test" + "coll": "coll" }, "fullDocument": { "_id": { diff --git a/test/unified-test-format/valid-pass/poc-command-monitoring.json b/test/unified-test-format/valid-pass/poc-command-monitoring.json index fe0a5ae991..f201abd517 100644 --- a/test/unified-test-format/valid-pass/poc-command-monitoring.json +++ b/test/unified-test-format/valid-pass/poc-command-monitoring.json @@ -23,13 +23,13 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } } ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "command-monitoring-tests", "documents": [ { @@ -149,7 +149,7 @@ "long" ] }, - "collection": "test", + "collection": "coll", "batchSize": 1 }, "commandName": "getMore", diff --git a/test/unified-test-format/valid-pass/poc-sessions.json b/test/unified-test-format/valid-pass/poc-sessions.json index 117c9e7d00..6855860213 100644 --- a/test/unified-test-format/valid-pass/poc-sessions.json +++ b/test/unified-test-format/valid-pass/poc-sessions.json @@ -27,7 +27,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -39,7 +39,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "session-tests", "documents": [ { @@ -147,7 +147,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "session-tests", "documents": [ { @@ -239,7 +239,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "session-tests", "documents": [ { @@ -446,7 +446,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "session-tests", "documents": [ { diff --git a/test/unified-test-format/valid-pass/poc-transactions-convenient-api.json b/test/unified-test-format/valid-pass/poc-transactions-convenient-api.json index 9ab44a9c54..0716ec2364 100644 --- a/test/unified-test-format/valid-pass/poc-transactions-convenient-api.json +++ b/test/unified-test-format/valid-pass/poc-transactions-convenient-api.json @@ -56,14 +56,14 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { "collection": { "id": "collection1", "database": "database1", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -97,7 +97,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -191,7 +191,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -289,7 +289,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -387,7 +387,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -491,7 +491,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { diff --git a/test/unified-test-format/valid-pass/poc-transactions-mongos-pin-auto.json b/test/unified-test-format/valid-pass/poc-transactions-mongos-pin-auto.json index de08edec44..3c39210754 100644 --- a/test/unified-test-format/valid-pass/poc-transactions-mongos-pin-auto.json +++ b/test/unified-test-format/valid-pass/poc-transactions-mongos-pin-auto.json @@ -30,7 +30,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -42,7 +42,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -215,7 +215,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { @@ -392,7 +392,7 @@ ], "outcome": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [ { diff --git a/test/unified-test-format/valid-pass/poc-transactions.json b/test/unified-test-format/valid-pass/poc-transactions.json index 2055a3b705..005db2f646 100644 --- a/test/unified-test-format/valid-pass/poc-transactions.json +++ b/test/unified-test-format/valid-pass/poc-transactions.json @@ -35,7 +35,7 @@ "collection": { "id": "collection0", "database": "database0", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -47,7 +47,7 @@ ], "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "transaction-tests", "documents": [] } @@ -102,7 +102,7 @@ "name": "dropCollection", "object": "database0", "arguments": { - "collection": "test" + "collection": "coll" } }, { @@ -114,7 +114,7 @@ "object": "database0", "arguments": { "session": "session0", - "collection": "test" + "collection": "coll" } }, { @@ -122,7 +122,7 @@ "object": "testRunner", "arguments": { "databaseName": "transaction-tests", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -134,7 +134,7 @@ "object": "testRunner", "arguments": { "databaseName": "transaction-tests", - "collectionName": "test" + "collectionName": "coll" } } ], @@ -145,7 +145,7 @@ { "commandStartedEvent": { "command": { - "drop": "test", + "drop": "coll", "writeConcern": { "$$exists": false } @@ -157,7 +157,7 @@ { "commandStartedEvent": { "command": { - "create": "test", + "create": "coll", "lsid": { "$$sessionLsid": "session0" }, @@ -212,7 +212,7 @@ "name": "dropCollection", "object": "database0", "arguments": { - "collection": "test" + "collection": "coll" } }, { @@ -235,7 +235,7 @@ "object": "testRunner", "arguments": { "databaseName": "transaction-tests", - "collectionName": "test", + "collectionName": "coll", "indexName": "x_1" } }, @@ -248,7 +248,7 @@ "object": "testRunner", "arguments": { "databaseName": "transaction-tests", - "collectionName": "test", + "collectionName": "coll", "indexName": "x_1" } } @@ -260,7 +260,7 @@ { "commandStartedEvent": { "command": { - "drop": "test", + "drop": "coll", "writeConcern": { "$$exists": false } @@ -272,7 +272,7 @@ { "commandStartedEvent": { "command": { - "createIndexes": "test", + "createIndexes": "coll", "indexes": [ { "name": "x_1", diff --git a/test/utils_shared.py b/test/utils_shared.py index 70a195215a..7e72213434 100644 --- a/test/utils_shared.py +++ b/test/utils_shared.py @@ -390,11 +390,11 @@ def delay(sec): .. code-block:: python db.coll.insert_one({"x": 1}) - db.test.find_one({"x": 1}) + db.coll.find_one({"x": 1}) # {'x': 1, '_id': ObjectId('54f4e12bfba5220aa4d6dee8')} # The following will wait 2.5 seconds before returning. - db.test.find_one({"$where": delay(2.5)}) + db.coll.find_one({"$where": delay(2.5)}) # {'x': 1, '_id': ObjectId('54f4e12bfba5220aa4d6dee8')} Using ``delay`` to provoke a KeyboardInterrupt @@ -548,13 +548,13 @@ def lazy_client_trial(reset, target, test, get_client): `test` takes the lazily-connecting collection and asserts a post-condition to prove `target` succeeded. """ - collection = client_context.client.pymongo_test.test + collection = client_context.client.db.coll with frequent_thread_switches(): for _i in range(NTRIALS): reset(collection) lazy_client = get_client() - lazy_collection = lazy_client.pymongo_test.test + lazy_collection = lazy_client.db.coll run_threads(lazy_collection, target) test(lazy_collection) diff --git a/test/versioned-api/crud-api-version-1-strict.json b/test/versioned-api/crud-api-version-1-strict.json index c1c8ecce01..c4ec4a0110 100644 --- a/test/versioned-api/crud-api-version-1-strict.json +++ b/test/versioned-api/crud-api-version-1-strict.json @@ -37,7 +37,7 @@ "collection": { "id": "collection", "database": "database", - "collectionName": "test" + "collectionName": "coll" } } ], @@ -54,7 +54,7 @@ }, "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "versioned-api-tests", "documents": [ { diff --git a/test/versioned-api/crud-api-version-1.json b/test/versioned-api/crud-api-version-1.json index 23ef59a6d9..00f987c5c8 100644 --- a/test/versioned-api/crud-api-version-1.json +++ b/test/versioned-api/crud-api-version-1.json @@ -37,7 +37,7 @@ "collection": { "id": "collection", "database": "database", - "collectionName": "test" + "collectionName": "coll" } } ], @@ -55,7 +55,7 @@ }, "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "versioned-api-tests", "documents": [ { diff --git a/test/versioned-api/transaction-handling.json b/test/versioned-api/transaction-handling.json index 32031296af..78a4fff47c 100644 --- a/test/versioned-api/transaction-handling.json +++ b/test/versioned-api/transaction-handling.json @@ -34,7 +34,7 @@ "collection": { "id": "collection", "database": "database", - "collectionName": "test" + "collectionName": "coll" } }, { @@ -59,7 +59,7 @@ }, "initialData": [ { - "collectionName": "test", + "collectionName": "coll", "databaseName": "versioned-api-tests", "documents": [ { From b1c52b221fa120f1ae1ca29a0034e9910b6b65ab Mon Sep 17 00:00:00 2001 From: Sophia Yang Date: Fri, 12 Jun 2026 14:50:49 -0400 Subject: [PATCH 2/9] oidc only has access to test --- test/asynchronous/test_auth_oidc.py | 144 +++++++++++++-------------- test/asynchronous/test_client.py | 2 +- test/asynchronous/test_collection.py | 2 +- test/test_auth_oidc.py | 144 +++++++++++++-------------- test/test_client.py | 2 +- test/test_collection.py | 2 +- 6 files changed, 148 insertions(+), 148 deletions(-) diff --git a/test/asynchronous/test_auth_oidc.py b/test/asynchronous/test_auth_oidc.py index 0c9c274330..315e361ffe 100644 --- a/test/asynchronous/test_auth_oidc.py +++ b/test/asynchronous/test_auth_oidc.py @@ -177,7 +177,7 @@ async def test_1_1_single_principal_implicit_username(self): # Create default OIDC client with authMechanism=MONGODB-OIDC. client = await self.create_client() # Perform a find operation that succeeds. - await client.db.coll.find_one() + await client.test.coll.find_one() # Close the client. await client.close() @@ -185,7 +185,7 @@ async def test_1_2_single_principal_explicit_username(self): # Create a client with MONGODB_URI_SINGLE, a username of test_user1, authMechanism=MONGODB-OIDC, and the OIDC human callback. client = await self.create_client(username="test_user1") # Perform a find operation that succeeds. - await client.db.coll.find_one() + await client.test.coll.find_one() # Close the client. await client.close() @@ -195,7 +195,7 @@ async def test_1_3_multiple_principal_user_1(self): # Create a client with MONGODB_URI_MULTI, a username of test_user1, authMechanism=MONGODB-OIDC, and the OIDC human callback. client = await self.create_client(self.uri_multiple, username="test_user1") # Perform a find operation that succeeds. - await client.db.coll.find_one() + await client.test.coll.find_one() # Close the client. await client.close() @@ -206,7 +206,7 @@ async def test_1_4_multiple_principal_user_2(self): # Create a client with MONGODB_URI_MULTI, a username of test_user2, authMechanism=MONGODB-OIDC, and the OIDC human callback. client = await self.create_client(self.uri_multiple, username="test_user2") # Perform a find operation that succeeds. - await client.db.coll.find_one() + await client.test.coll.find_one() # Close the client. await client.close() @@ -217,7 +217,7 @@ async def test_1_5_multiple_principal_no_user(self): client = await self.create_client(self.uri_multiple) # Assert that a find operation fails. with self.assertRaises(OperationFailure): - await client.db.coll.find_one() + await client.test.coll.find_one() # Close the client. await client.close() @@ -228,7 +228,7 @@ async def test_1_6_allowed_hosts_blocked(self): client = await self.create_client(authmechanismproperties=props) # Assert that a find operation fails with a client-side error. with self.assertRaises(ConfigurationError): - await client.db.coll.find_one() + await client.test.coll.find_one() # Close the client. await client.close() @@ -247,7 +247,7 @@ async def test_1_6_allowed_hosts_blocked(self): ) # Assert that a find operation fails with a client-side error. with self.assertRaises(ConfigurationError): - await client.db.coll.find_one() + await client.test.coll.find_one() # Close the client. await client.close() @@ -269,7 +269,7 @@ async def test_1_8_machine_idp_human_callback(self): # Create a client with MONGODB_URI_SINGLE, a username of test_machine, authMechanism=MONGODB-OIDC, and the OIDC human callback. client = await self.create_client(username="test_machine") # Perform a find operation that succeeds. - await client.db.coll.find_one() + await client.test.coll.find_one() # Close the client. await client.close() @@ -278,7 +278,7 @@ async def test_2_1_valid_callback_inputs(self): client = await self.create_client() # Perform a find operation that succeeds. Verify that the human callback was called with the appropriate inputs, including the timeout parameter if possible. # Ensure that there are no unexpected fields. - await client.db.coll.find_one() + await client.test.coll.find_one() # Close the client. await client.close() @@ -291,7 +291,7 @@ def fetch(self, ctx): client = await self.create_client(request_cb=CustomCB()) # Perform a find operation that fails. with self.assertRaises(ValueError): - await client.db.coll.find_one() + await client.test.coll.find_one() # Close the client. await client.close() @@ -300,7 +300,7 @@ async def test_2_3_refresh_token_is_passed_to_the_callback(self): client = await self.create_client() # Perform a find operation that succeeds. - await client.db.coll.find_one() + await client.test.coll.find_one() # Set a fail point for ``find`` commands. async with self.fail_point( @@ -310,7 +310,7 @@ async def test_2_3_refresh_token_is_passed_to_the_callback(self): } ): # Perform a ``find`` operation that succeeds. - await client.db.coll.find_one() + await client.test.coll.find_one() # Assert that the callback has been called twice. self.assertEqual(self.request_called, 2) @@ -331,7 +331,7 @@ async def test_3_1_uses_speculative_authentication_if_there_is_a_cached_token(se ): # Perform a ``find`` operation that fails. with self.assertRaises(AutoReconnect): - await client.db.coll.find_one() + await client.test.coll.find_one() # Set a fail point for ``saslStart`` commands. async with self.fail_point( @@ -341,7 +341,7 @@ async def test_3_1_uses_speculative_authentication_if_there_is_a_cached_token(se } ): # Perform a ``find`` operation that succeeds - await client.db.coll.find_one() + await client.test.coll.find_one() # Close the client. await client.close() @@ -359,7 +359,7 @@ async def test_3_2_does_not_use_speculative_authentication_if_there_is_no_cached ): # Perform a ``find`` operation that fails. with self.assertRaises(OperationFailure): - await client.db.coll.find_one() + await client.test.coll.find_one() # Close the client. await client.close() @@ -372,7 +372,7 @@ async def test_4_1_reauthenticate_succeeds(self): client = await self.create_client(event_listeners=[listener]) # Perform a find operation that succeeds. - await client.db.coll.find_one() + await client.test.coll.find_one() # Assert that the human callback has been called once. self.assertEqual(self.request_called, 1) @@ -388,7 +388,7 @@ async def test_4_1_reauthenticate_succeeds(self): } ): # Perform another find operation that succeeds. - await client.db.coll.find_one() + await client.test.coll.find_one() # Assert that the human callback has been called twice. self.assertEqual(self.request_called, 2) @@ -434,7 +434,7 @@ def fetch(self, *args, **kwargs): client = await self.create_client(request_cb=CustomRequest()) # Perform a find operation that succeeds. - await client.db.coll.find_one() + await client.test.coll.find_one() # Assert that the human callback has been called once. self.assertEqual(self.request_called, 1) @@ -447,7 +447,7 @@ def fetch(self, *args, **kwargs): } ): # Perform a find operation that succeeds. - await client.db.coll.find_one() + await client.test.coll.find_one() # Assert that the human callback has been called twice. self.assertEqual(self.request_called, 2) @@ -467,7 +467,7 @@ def fetch(self, *args, **kwargs): client = await self.create_client(request_cb=CustomRequest()) # Perform a find operation that succeeds. - await client.db.coll.find_one() + await client.test.coll.find_one() # Assert that the human callback has been called once. self.assertEqual(self.request_called, 1) @@ -480,7 +480,7 @@ def fetch(self, *args, **kwargs): } ): # Perform a find operation that succeeds. - await client.db.coll.find_one() + await client.test.coll.find_one() # Assert that the human callback has been called 2 times. self.assertEqual(self.request_called, 2) @@ -507,7 +507,7 @@ def fetch(self, *args, **kwargs): client = await self.create_client(request_cb=CustomRequest()) # Perform a find operation that succeeds (to force a speculative auth). - await client.db.coll.find_one() + await client.test.coll.find_one() # Assert that the human callback has been called once. self.assertEqual(self.request_called, 1) @@ -520,7 +520,7 @@ def fetch(self, *args, **kwargs): ): # Perform a find operation that fails. with self.assertRaises(OperationFailure): - await client.db.coll.find_one() + await client.test.coll.find_one() # Assert that the human callback has been called three times. self.assertEqual(self.request_called, 3) @@ -535,7 +535,7 @@ def fetch(self, a): client = await self.create_client(request_cb=RequestTokenNull()) with self.assertRaises(ValueError): - await client.db.coll.find_one() + await client.test.coll.find_one() await client.close() async def test_request_callback_invalid_result(self): @@ -545,7 +545,7 @@ def fetch(self, a): client = await self.create_client(request_cb=CallbackInvalidToken()) with self.assertRaises(ValueError): - await client.db.coll.find_one() + await client.test.coll.find_one() await client.close() async def test_reauthentication_succeeds_multiple_connections(self): @@ -556,8 +556,8 @@ async def test_reauthentication_succeeds_multiple_connections(self): client2 = await self.create_client(request_cb=request_cb) # Perform an insert operation. - await client1.db.coll.insert_many([{"a": 1}, {"a": 1}]) - await client2.db.coll.find_one() + await client1.test.coll.insert_many([{"a": 1}, {"a": 1}]) + await client2.test.coll.find_one() self.assertEqual(self.request_called, 2) # Use the same authenticator for both clients @@ -568,8 +568,8 @@ async def test_reauthentication_succeeds_multiple_connections(self): client1.options.pool_options._credentials.cache.data ) - await client1.db.coll.find_one() - await client2.db.coll.find_one() + await client1.test.coll.find_one() + await client2.test.coll.find_one() async with self.fail_point( { @@ -577,7 +577,7 @@ async def test_reauthentication_succeeds_multiple_connections(self): "data": {"failCommands": ["find"], "errorCode": 391}, } ): - await client1.db.coll.find_one() + await client1.test.coll.find_one() self.assertEqual(self.request_called, 3) @@ -587,7 +587,7 @@ async def test_reauthentication_succeeds_multiple_connections(self): "data": {"failCommands": ["find"], "errorCode": 391}, } ): - await client2.db.coll.find_one() + await client2.test.coll.find_one() self.assertEqual(self.request_called, 3) await client1.close() @@ -600,7 +600,7 @@ async def test_reauthenticate_succeeds_bulk_write(self): client = await self.create_client() # Perform a find operation. - await client.db.coll.find_one() + await client.test.coll.find_one() # Assert that the request callback has been called once. self.assertEqual(self.request_called, 1) @@ -612,7 +612,7 @@ async def test_reauthenticate_succeeds_bulk_write(self): } ): # Perform a bulk write operation. - await client.db.coll.bulk_write([InsertOne({})]) # type:ignore[type-var] + await client.test.coll.bulk_write([InsertOne({})]) # type:ignore[type-var] # Assert that the request callback has been called twice. self.assertEqual(self.request_called, 2) @@ -623,10 +623,10 @@ async def test_reauthenticate_succeeds_bulk_read(self): client = await self.create_client() # Perform a find operation. - await client.db.coll.find_one() + await client.test.coll.find_one() # Perform a bulk write operation. - await client.db.coll.bulk_write([InsertOne({})]) # type:ignore[type-var] + await client.test.coll.bulk_write([InsertOne({})]) # type:ignore[type-var] # Assert that the request callback has been called once. self.assertEqual(self.request_called, 1) @@ -638,7 +638,7 @@ async def test_reauthenticate_succeeds_bulk_read(self): } ): # Perform a bulk read operation. - cursor = client.db.coll.find_raw_batches({}) + cursor = client.test.coll.find_raw_batches({}) await cursor.to_list() # Assert that the request callback has been called twice. @@ -650,7 +650,7 @@ async def test_reauthenticate_succeeds_cursor(self): client = await self.create_client() # Perform an insert operation. - await client.db.coll.insert_one({"a": 1}) + await client.test.coll.insert_one({"a": 1}) # Assert that the request callback has been called once. self.assertEqual(self.request_called, 1) @@ -662,7 +662,7 @@ async def test_reauthenticate_succeeds_cursor(self): } ): # Perform a find operation. - cursor = client.db.coll.find({"a": 1}) + cursor = client.test.coll.find({"a": 1}) self.assertGreaterEqual(len(await cursor.to_list()), 1) # Assert that the request callback has been called twice. @@ -674,7 +674,7 @@ async def test_reauthenticate_succeeds_get_more(self): client = await self.create_client() # Perform an insert operation. - await client.db.coll.insert_many([{"a": 1}, {"a": 1}]) + await client.test.coll.insert_many([{"a": 1}, {"a": 1}]) # Assert that the request callback has been called once. self.assertEqual(self.request_called, 1) @@ -686,7 +686,7 @@ async def test_reauthenticate_succeeds_get_more(self): } ): # Perform a find operation. - cursor = client.db.coll.find({"a": 1}, batch_size=1) + cursor = client.test.coll.find({"a": 1}, batch_size=1) self.assertGreaterEqual(len(await cursor.to_list()), 1) # Assert that the request callback has been called twice. @@ -704,7 +704,7 @@ async def test_reauthenticate_succeeds_get_more_exhaust(self): client = await self.create_client() # Perform an insert operation. - await client.db.coll.insert_many([{"a": 1}, {"a": 1}]) + await client.test.coll.insert_many([{"a": 1}, {"a": 1}]) # Assert that the request callback has been called once. self.assertEqual(self.request_called, 1) @@ -716,7 +716,7 @@ async def test_reauthenticate_succeeds_get_more_exhaust(self): } ): # Perform a find operation. - cursor = client.db.coll.find({"a": 1}, batch_size=1, cursor_type=CursorType.EXHAUST) + cursor = client.test.coll.find({"a": 1}, batch_size=1, cursor_type=CursorType.EXHAUST) self.assertGreaterEqual(len(await cursor.to_list()), 1) # Assert that the request callback has been called twice. @@ -728,7 +728,7 @@ async def test_reauthenticate_succeeds_command(self): client = await self.create_client() # Perform an insert operation. - await client.db.coll.insert_one({"a": 1}) + await client.test.coll.insert_one({"a": 1}) # Assert that the request callback has been called once. self.assertEqual(self.request_called, 1) @@ -787,7 +787,7 @@ async def test_1_1_callback_is_called_during_reauthentication(self): # implements the provider logic. client = await self.create_client() # Perform a ``find`` operation that succeeds. - await client.db.coll.find_one() + await client.test.coll.find_one() # Assert that the callback was called 1 time. self.assertEqual(self.request_called, 1) @@ -800,7 +800,7 @@ async def test_1_2_callback_is_called_once_for_multiple_connections(self): # Start 10 tasks and run 100 find operations that all succeed in each task. async def target(): for _ in range(100): - await client.db.coll.find_one() + await client.test.coll.find_one() tasks = [] for i in range(10): @@ -816,7 +816,7 @@ async def test_2_1_valid_callback_inputs(self): # Create a AsyncMongoClient configured with an OIDC callback that validates its inputs and returns a valid access token. client = await self.create_client() # Perform a find operation that succeeds. - await client.db.coll.find_one() + await client.test.coll.find_one() # Assert that the OIDC callback was called with the appropriate inputs, including the timeout parameter if possible. Ensure that there are no unexpected fields. self.assertEqual(self.request_called, 1) @@ -829,7 +829,7 @@ def fetch(self, a): client = await self.create_client(request_cb=CallbackNullToken()) # Perform a find operation that fails. with self.assertRaises(ValueError): - await client.db.coll.find_one() + await client.test.coll.find_one() async def test_2_3_oidc_callback_returns_missing_data(self): # Create a AsyncMongoClient configured with an OIDC callback that returns data not conforming to the OIDCCredential with missing fields. @@ -843,7 +843,7 @@ def fetch(self, a): client = await self.create_client(request_cb=CustomCallback()) # Perform a find operation that fails. with self.assertRaises(ValueError): - await client.db.coll.find_one() + await client.test.coll.find_one() async def test_2_4_invalid_client_configuration_with_callback(self): # Create a AsyncMongoClient configured with an OIDC callback and auth mechanism property ENVIRONMENT:test. @@ -898,13 +898,13 @@ async def test_3_1_authentication_failure_with_cached_tokens_fetch_a_new_token_a # Perform a ``find`` operation that fails. This is to force the ``AsyncMongoClient`` # to cache an access token. with self.assertRaises(AutoReconnect): - await client.db.coll.find_one() + await client.test.coll.find_one() # Poison the cache of the client. client.options.pool_options._credentials.cache.data.access_token = "bad" # Reset the request count. self.request_called = 0 # Verify that a find succeeds. - await client.db.coll.find_one() + await client.test.coll.find_one() # Verify that the callback was called 1 time. self.assertEqual(self.request_called, 1) @@ -921,7 +921,7 @@ def fetch(self, a): client = await self.create_client(request_cb=callback) # Perform a ``find`` operation that fails. with self.assertRaises(OperationFailure): - await client.db.coll.find_one() + await client.test.coll.find_one() # Verify that the callback was called 1 time. self.assertEqual(callback.count, 1) @@ -938,13 +938,13 @@ async def test_3_3_unexpected_error_code_does_not_clear_cache(self): ): # Perform a ``find`` operation that fails. with self.assertRaises(OperationFailure): - await client.db.coll.find_one() + await client.test.coll.find_one() # Assert that the callback has been called once. self.assertEqual(self.request_called, 1) # Perform a ``find`` operation that succeeds. - await client.db.coll.find_one() + await client.test.coll.find_one() # Assert that the callback has been called once. self.assertEqual(self.request_called, 1) @@ -963,7 +963,7 @@ async def test_4_1_reauthentication_succeeds(self): } ): # Perform a ``find`` operation that succeeds. - await client.db.coll.find_one() + await client.test.coll.find_one() # Verify that the callback was called 2 times (once during the connection # handshake, and again during reauthentication). @@ -989,7 +989,7 @@ def fetch(self, _): client = await self.create_client(request_cb=callback) # Perform a read operation that succeeds. - await client.db.coll.find_one() + await client.test.coll.find_one() # Set a fail point for the find command. async with self.fail_point( @@ -1000,7 +1000,7 @@ def fetch(self, _): ): # Perform a ``find`` operation that fails. with self.assertRaises(OperationFailure): - await client.db.coll.find_one() + await client.test.coll.find_one() # Verify that the callback was called 2 times. self.assertEqual(callback.count, 2) @@ -1025,7 +1025,7 @@ def fetch(self, _): client = await self.create_client(request_cb=callback) # Perform an insert operation that succeeds. - await client.db.coll.insert_one({}) + await client.test.coll.insert_one({}) # Set a fail point for the find command. async with self.fail_point( @@ -1036,7 +1036,7 @@ def fetch(self, _): ): # Perform a ``insert`` operation that fails. with self.assertRaises(OperationFailure): - await client.db.coll.insert_one({}) + await client.test.coll.insert_one({}) # Verify that the callback was called 2 times. self.assertEqual(callback.count, 2) @@ -1049,7 +1049,7 @@ async def test_4_4_speculative_authentication_should_be_ignored_on_reauthenticat # Preload the *Client Cache* with a valid access token to enforce Speculative Authentication. client2 = await self.create_client() - await client2.db.coll.find_one() + await client2.test.coll.find_one() client.options.pool_options._credentials.cache.data = ( client2.options.pool_options._credentials.cache.data ) @@ -1057,7 +1057,7 @@ async def test_4_4_speculative_authentication_should_be_ignored_on_reauthenticat self.request_called = 0 # Perform an `insert` operation that succeeds. - await client.db.coll.insert_one({}) + await client.test.coll.insert_one({}) # Assert that the callback was not called. self.assertEqual(self.request_called, 0) @@ -1076,7 +1076,7 @@ async def test_4_4_speculative_authentication_should_be_ignored_on_reauthenticat } ): # Perform an `insert` operation that succeeds. - await client.db.coll.insert_one({}) + await client.test.coll.insert_one({}) # Assert that the callback was called once. self.assertEqual(self.request_called, 1) @@ -1098,7 +1098,7 @@ async def test_4_5_reauthentication_succeeds_when_a_session_is_involved(self): # Start a new session. async with client.start_session() as session: # In the started session perform a `find` operation that succeeds. - await client.db.coll.find_one({}, session=session) + await client.test.coll.find_one({}, session=session) # Assert that the callback was called 2 times (once during the connection handshake, and again during reauthentication). self.assertEqual(self.request_called, 2) @@ -1111,7 +1111,7 @@ async def test_5_1_azure_with_no_username(self): props = dict(TOKEN_RESOURCE=resource, ENVIRONMENT="azure") client = await self.create_client(authMechanismProperties=props) - await client.db.coll.find_one() + await client.test.coll.find_one() async def test_5_2_azure_with_bad_username(self): if ENVIRON != "azure": @@ -1123,11 +1123,11 @@ async def test_5_2_azure_with_bad_username(self): props = dict(TOKEN_RESOURCE=token_aud, ENVIRONMENT="azure") client = await self.create_client(username="bad", authmechanismproperties=props) with self.assertRaises(ValueError): - await client.db.coll.find_one() + await client.test.coll.find_one() async def test_speculative_auth_success(self): client1 = await self.create_client() - await client1.db.coll.find_one() + await client1.test.coll.find_one() client2 = await self.create_client() await client2.aconnect() @@ -1144,15 +1144,15 @@ async def test_speculative_auth_success(self): } ): # Perform a find operation. - await client2.db.coll.find_one() + await client2.test.coll.find_one() async def test_reauthentication_succeeds_multiple_connections(self): client1 = await self.create_client() client2 = await self.create_client() # Perform an insert operation. - await client1.db.coll.insert_many([{"a": 1}, {"a": 1}]) - await client2.db.coll.find_one() + await client1.test.coll.insert_many([{"a": 1}, {"a": 1}]) + await client2.test.coll.find_one() self.assertEqual(self.request_called, 2) # Use the same authenticator for both clients @@ -1163,8 +1163,8 @@ async def test_reauthentication_succeeds_multiple_connections(self): client1.options.pool_options._credentials.cache.data ) - await client1.db.coll.find_one() - await client2.db.coll.find_one() + await client1.test.coll.find_one() + await client2.test.coll.find_one() async with self.fail_point( { @@ -1172,7 +1172,7 @@ async def test_reauthentication_succeeds_multiple_connections(self): "data": {"failCommands": ["find"], "errorCode": 391}, } ): - await client1.db.coll.find_one() + await client1.test.coll.find_one() self.assertEqual(self.request_called, 3) @@ -1182,7 +1182,7 @@ async def test_reauthentication_succeeds_multiple_connections(self): "data": {"failCommands": ["find"], "errorCode": 391}, } ): - await client2.db.coll.find_one() + await client2.test.coll.find_one() self.assertEqual(self.request_called, 3) diff --git a/test/asynchronous/test_client.py b/test/asynchronous/test_client.py index 90d14dfe0f..75ad879ad9 100644 --- a/test/asynchronous/test_client.py +++ b/test/asynchronous/test_client.py @@ -1591,7 +1591,7 @@ async def predicate(): await async_wait_until(predicate, "update one document") client = await self.async_rs_or_single_client(connect=False, w=0) - await client.test_lazy_connect_w0.list_collection_names.delete_one({}) + await client.test_lazy_connect_w0.coll.delete_one({}) async def predicate(): return await client.test_lazy_connect_w0.coll.count_documents({}) == 0 diff --git a/test/asynchronous/test_collection.py b/test/asynchronous/test_collection.py index 5f8351ab82..a5870df6a2 100644 --- a/test/asynchronous/test_collection.py +++ b/test/asynchronous/test_collection.py @@ -1011,7 +1011,7 @@ async def test_update_bypass_document_validation(self): db = self.db await db.coll.drop() await db.coll.insert_one({"z": 5}) - await db.command(SON([("collMod", "test"), ("validator", {"z": {"$gte": 0}})])) + await db.command(SON([("collMod", "coll"), ("validator", {"z": {"$gte": 0}})])) db_w0 = self.db.client.get_database(self.db.name, write_concern=WriteConcern(w=0)) # Test update_one diff --git a/test/test_auth_oidc.py b/test/test_auth_oidc.py index c0ff66aa59..edf521c2e8 100644 --- a/test/test_auth_oidc.py +++ b/test/test_auth_oidc.py @@ -177,7 +177,7 @@ def test_1_1_single_principal_implicit_username(self): # Create default OIDC client with authMechanism=MONGODB-OIDC. client = self.create_client() # Perform a find operation that succeeds. - client.db.coll.find_one() + client.test.coll.find_one() # Close the client. client.close() @@ -185,7 +185,7 @@ def test_1_2_single_principal_explicit_username(self): # Create a client with MONGODB_URI_SINGLE, a username of test_user1, authMechanism=MONGODB-OIDC, and the OIDC human callback. client = self.create_client(username="test_user1") # Perform a find operation that succeeds. - client.db.coll.find_one() + client.test.coll.find_one() # Close the client. client.close() @@ -195,7 +195,7 @@ def test_1_3_multiple_principal_user_1(self): # Create a client with MONGODB_URI_MULTI, a username of test_user1, authMechanism=MONGODB-OIDC, and the OIDC human callback. client = self.create_client(self.uri_multiple, username="test_user1") # Perform a find operation that succeeds. - client.db.coll.find_one() + client.test.coll.find_one() # Close the client. client.close() @@ -206,7 +206,7 @@ def test_1_4_multiple_principal_user_2(self): # Create a client with MONGODB_URI_MULTI, a username of test_user2, authMechanism=MONGODB-OIDC, and the OIDC human callback. client = self.create_client(self.uri_multiple, username="test_user2") # Perform a find operation that succeeds. - client.db.coll.find_one() + client.test.coll.find_one() # Close the client. client.close() @@ -217,7 +217,7 @@ def test_1_5_multiple_principal_no_user(self): client = self.create_client(self.uri_multiple) # Assert that a find operation fails. with self.assertRaises(OperationFailure): - client.db.coll.find_one() + client.test.coll.find_one() # Close the client. client.close() @@ -228,7 +228,7 @@ def test_1_6_allowed_hosts_blocked(self): client = self.create_client(authmechanismproperties=props) # Assert that a find operation fails with a client-side error. with self.assertRaises(ConfigurationError): - client.db.coll.find_one() + client.test.coll.find_one() # Close the client. client.close() @@ -247,7 +247,7 @@ def test_1_6_allowed_hosts_blocked(self): ) # Assert that a find operation fails with a client-side error. with self.assertRaises(ConfigurationError): - client.db.coll.find_one() + client.test.coll.find_one() # Close the client. client.close() @@ -269,7 +269,7 @@ def test_1_8_machine_idp_human_callback(self): # Create a client with MONGODB_URI_SINGLE, a username of test_machine, authMechanism=MONGODB-OIDC, and the OIDC human callback. client = self.create_client(username="test_machine") # Perform a find operation that succeeds. - client.db.coll.find_one() + client.test.coll.find_one() # Close the client. client.close() @@ -278,7 +278,7 @@ def test_2_1_valid_callback_inputs(self): client = self.create_client() # Perform a find operation that succeeds. Verify that the human callback was called with the appropriate inputs, including the timeout parameter if possible. # Ensure that there are no unexpected fields. - client.db.coll.find_one() + client.test.coll.find_one() # Close the client. client.close() @@ -291,7 +291,7 @@ def fetch(self, ctx): client = self.create_client(request_cb=CustomCB()) # Perform a find operation that fails. with self.assertRaises(ValueError): - client.db.coll.find_one() + client.test.coll.find_one() # Close the client. client.close() @@ -300,7 +300,7 @@ def test_2_3_refresh_token_is_passed_to_the_callback(self): client = self.create_client() # Perform a find operation that succeeds. - client.db.coll.find_one() + client.test.coll.find_one() # Set a fail point for ``find`` commands. with self.fail_point( @@ -310,7 +310,7 @@ def test_2_3_refresh_token_is_passed_to_the_callback(self): } ): # Perform a ``find`` operation that succeeds. - client.db.coll.find_one() + client.test.coll.find_one() # Assert that the callback has been called twice. self.assertEqual(self.request_called, 2) @@ -331,7 +331,7 @@ def test_3_1_uses_speculative_authentication_if_there_is_a_cached_token(self): ): # Perform a ``find`` operation that fails. with self.assertRaises(AutoReconnect): - client.db.coll.find_one() + client.test.coll.find_one() # Set a fail point for ``saslStart`` commands. with self.fail_point( @@ -341,7 +341,7 @@ def test_3_1_uses_speculative_authentication_if_there_is_a_cached_token(self): } ): # Perform a ``find`` operation that succeeds - client.db.coll.find_one() + client.test.coll.find_one() # Close the client. client.close() @@ -359,7 +359,7 @@ def test_3_2_does_not_use_speculative_authentication_if_there_is_no_cached_token ): # Perform a ``find`` operation that fails. with self.assertRaises(OperationFailure): - client.db.coll.find_one() + client.test.coll.find_one() # Close the client. client.close() @@ -372,7 +372,7 @@ def test_4_1_reauthenticate_succeeds(self): client = self.create_client(event_listeners=[listener]) # Perform a find operation that succeeds. - client.db.coll.find_one() + client.test.coll.find_one() # Assert that the human callback has been called once. self.assertEqual(self.request_called, 1) @@ -388,7 +388,7 @@ def test_4_1_reauthenticate_succeeds(self): } ): # Perform another find operation that succeeds. - client.db.coll.find_one() + client.test.coll.find_one() # Assert that the human callback has been called twice. self.assertEqual(self.request_called, 2) @@ -434,7 +434,7 @@ def fetch(self, *args, **kwargs): client = self.create_client(request_cb=CustomRequest()) # Perform a find operation that succeeds. - client.db.coll.find_one() + client.test.coll.find_one() # Assert that the human callback has been called once. self.assertEqual(self.request_called, 1) @@ -447,7 +447,7 @@ def fetch(self, *args, **kwargs): } ): # Perform a find operation that succeeds. - client.db.coll.find_one() + client.test.coll.find_one() # Assert that the human callback has been called twice. self.assertEqual(self.request_called, 2) @@ -467,7 +467,7 @@ def fetch(self, *args, **kwargs): client = self.create_client(request_cb=CustomRequest()) # Perform a find operation that succeeds. - client.db.coll.find_one() + client.test.coll.find_one() # Assert that the human callback has been called once. self.assertEqual(self.request_called, 1) @@ -480,7 +480,7 @@ def fetch(self, *args, **kwargs): } ): # Perform a find operation that succeeds. - client.db.coll.find_one() + client.test.coll.find_one() # Assert that the human callback has been called 2 times. self.assertEqual(self.request_called, 2) @@ -507,7 +507,7 @@ def fetch(self, *args, **kwargs): client = self.create_client(request_cb=CustomRequest()) # Perform a find operation that succeeds (to force a speculative auth). - client.db.coll.find_one() + client.test.coll.find_one() # Assert that the human callback has been called once. self.assertEqual(self.request_called, 1) @@ -520,7 +520,7 @@ def fetch(self, *args, **kwargs): ): # Perform a find operation that fails. with self.assertRaises(OperationFailure): - client.db.coll.find_one() + client.test.coll.find_one() # Assert that the human callback has been called three times. self.assertEqual(self.request_called, 3) @@ -535,7 +535,7 @@ def fetch(self, a): client = self.create_client(request_cb=RequestTokenNull()) with self.assertRaises(ValueError): - client.db.coll.find_one() + client.test.coll.find_one() client.close() def test_request_callback_invalid_result(self): @@ -545,7 +545,7 @@ def fetch(self, a): client = self.create_client(request_cb=CallbackInvalidToken()) with self.assertRaises(ValueError): - client.db.coll.find_one() + client.test.coll.find_one() client.close() def test_reauthentication_succeeds_multiple_connections(self): @@ -556,8 +556,8 @@ def test_reauthentication_succeeds_multiple_connections(self): client2 = self.create_client(request_cb=request_cb) # Perform an insert operation. - client1.db.coll.insert_many([{"a": 1}, {"a": 1}]) - client2.db.coll.find_one() + client1.test.coll.insert_many([{"a": 1}, {"a": 1}]) + client2.test.coll.find_one() self.assertEqual(self.request_called, 2) # Use the same authenticator for both clients @@ -568,8 +568,8 @@ def test_reauthentication_succeeds_multiple_connections(self): client1.options.pool_options._credentials.cache.data ) - client1.db.coll.find_one() - client2.db.coll.find_one() + client1.test.coll.find_one() + client2.test.coll.find_one() with self.fail_point( { @@ -577,7 +577,7 @@ def test_reauthentication_succeeds_multiple_connections(self): "data": {"failCommands": ["find"], "errorCode": 391}, } ): - client1.db.coll.find_one() + client1.test.coll.find_one() self.assertEqual(self.request_called, 3) @@ -587,7 +587,7 @@ def test_reauthentication_succeeds_multiple_connections(self): "data": {"failCommands": ["find"], "errorCode": 391}, } ): - client2.db.coll.find_one() + client2.test.coll.find_one() self.assertEqual(self.request_called, 3) client1.close() @@ -600,7 +600,7 @@ def test_reauthenticate_succeeds_bulk_write(self): client = self.create_client() # Perform a find operation. - client.db.coll.find_one() + client.test.coll.find_one() # Assert that the request callback has been called once. self.assertEqual(self.request_called, 1) @@ -612,7 +612,7 @@ def test_reauthenticate_succeeds_bulk_write(self): } ): # Perform a bulk write operation. - client.db.coll.bulk_write([InsertOne({})]) # type:ignore[type-var] + client.test.coll.bulk_write([InsertOne({})]) # type:ignore[type-var] # Assert that the request callback has been called twice. self.assertEqual(self.request_called, 2) @@ -623,10 +623,10 @@ def test_reauthenticate_succeeds_bulk_read(self): client = self.create_client() # Perform a find operation. - client.db.coll.find_one() + client.test.coll.find_one() # Perform a bulk write operation. - client.db.coll.bulk_write([InsertOne({})]) # type:ignore[type-var] + client.test.coll.bulk_write([InsertOne({})]) # type:ignore[type-var] # Assert that the request callback has been called once. self.assertEqual(self.request_called, 1) @@ -638,7 +638,7 @@ def test_reauthenticate_succeeds_bulk_read(self): } ): # Perform a bulk read operation. - cursor = client.db.coll.find_raw_batches({}) + cursor = client.test.coll.find_raw_batches({}) cursor.to_list() # Assert that the request callback has been called twice. @@ -650,7 +650,7 @@ def test_reauthenticate_succeeds_cursor(self): client = self.create_client() # Perform an insert operation. - client.db.coll.insert_one({"a": 1}) + client.test.coll.insert_one({"a": 1}) # Assert that the request callback has been called once. self.assertEqual(self.request_called, 1) @@ -662,7 +662,7 @@ def test_reauthenticate_succeeds_cursor(self): } ): # Perform a find operation. - cursor = client.db.coll.find({"a": 1}) + cursor = client.test.coll.find({"a": 1}) self.assertGreaterEqual(len(cursor.to_list()), 1) # Assert that the request callback has been called twice. @@ -674,7 +674,7 @@ def test_reauthenticate_succeeds_get_more(self): client = self.create_client() # Perform an insert operation. - client.db.coll.insert_many([{"a": 1}, {"a": 1}]) + client.test.coll.insert_many([{"a": 1}, {"a": 1}]) # Assert that the request callback has been called once. self.assertEqual(self.request_called, 1) @@ -686,7 +686,7 @@ def test_reauthenticate_succeeds_get_more(self): } ): # Perform a find operation. - cursor = client.db.coll.find({"a": 1}, batch_size=1) + cursor = client.test.coll.find({"a": 1}, batch_size=1) self.assertGreaterEqual(len(cursor.to_list()), 1) # Assert that the request callback has been called twice. @@ -704,7 +704,7 @@ def test_reauthenticate_succeeds_get_more_exhaust(self): client = self.create_client() # Perform an insert operation. - client.db.coll.insert_many([{"a": 1}, {"a": 1}]) + client.test.coll.insert_many([{"a": 1}, {"a": 1}]) # Assert that the request callback has been called once. self.assertEqual(self.request_called, 1) @@ -716,7 +716,7 @@ def test_reauthenticate_succeeds_get_more_exhaust(self): } ): # Perform a find operation. - cursor = client.db.coll.find({"a": 1}, batch_size=1, cursor_type=CursorType.EXHAUST) + cursor = client.test.coll.find({"a": 1}, batch_size=1, cursor_type=CursorType.EXHAUST) self.assertGreaterEqual(len(cursor.to_list()), 1) # Assert that the request callback has been called twice. @@ -728,7 +728,7 @@ def test_reauthenticate_succeeds_command(self): client = self.create_client() # Perform an insert operation. - client.db.coll.insert_one({"a": 1}) + client.test.coll.insert_one({"a": 1}) # Assert that the request callback has been called once. self.assertEqual(self.request_called, 1) @@ -787,7 +787,7 @@ def test_1_1_callback_is_called_during_reauthentication(self): # implements the provider logic. client = self.create_client() # Perform a ``find`` operation that succeeds. - client.db.coll.find_one() + client.test.coll.find_one() # Assert that the callback was called 1 time. self.assertEqual(self.request_called, 1) @@ -800,7 +800,7 @@ def test_1_2_callback_is_called_once_for_multiple_connections(self): # Start 10 tasks and run 100 find operations that all succeed in each task. def target(): for _ in range(100): - client.db.coll.find_one() + client.test.coll.find_one() tasks = [] for i in range(10): @@ -816,7 +816,7 @@ def test_2_1_valid_callback_inputs(self): # Create a MongoClient configured with an OIDC callback that validates its inputs and returns a valid access token. client = self.create_client() # Perform a find operation that succeeds. - client.db.coll.find_one() + client.test.coll.find_one() # Assert that the OIDC callback was called with the appropriate inputs, including the timeout parameter if possible. Ensure that there are no unexpected fields. self.assertEqual(self.request_called, 1) @@ -829,7 +829,7 @@ def fetch(self, a): client = self.create_client(request_cb=CallbackNullToken()) # Perform a find operation that fails. with self.assertRaises(ValueError): - client.db.coll.find_one() + client.test.coll.find_one() def test_2_3_oidc_callback_returns_missing_data(self): # Create a MongoClient configured with an OIDC callback that returns data not conforming to the OIDCCredential with missing fields. @@ -843,7 +843,7 @@ def fetch(self, a): client = self.create_client(request_cb=CustomCallback()) # Perform a find operation that fails. with self.assertRaises(ValueError): - client.db.coll.find_one() + client.test.coll.find_one() def test_2_4_invalid_client_configuration_with_callback(self): # Create a MongoClient configured with an OIDC callback and auth mechanism property ENVIRONMENT:test. @@ -898,13 +898,13 @@ def test_3_1_authentication_failure_with_cached_tokens_fetch_a_new_token_and_ret # Perform a ``find`` operation that fails. This is to force the ``MongoClient`` # to cache an access token. with self.assertRaises(AutoReconnect): - client.db.coll.find_one() + client.test.coll.find_one() # Poison the cache of the client. client.options.pool_options._credentials.cache.data.access_token = "bad" # Reset the request count. self.request_called = 0 # Verify that a find succeeds. - client.db.coll.find_one() + client.test.coll.find_one() # Verify that the callback was called 1 time. self.assertEqual(self.request_called, 1) @@ -921,7 +921,7 @@ def fetch(self, a): client = self.create_client(request_cb=callback) # Perform a ``find`` operation that fails. with self.assertRaises(OperationFailure): - client.db.coll.find_one() + client.test.coll.find_one() # Verify that the callback was called 1 time. self.assertEqual(callback.count, 1) @@ -938,13 +938,13 @@ def test_3_3_unexpected_error_code_does_not_clear_cache(self): ): # Perform a ``find`` operation that fails. with self.assertRaises(OperationFailure): - client.db.coll.find_one() + client.test.coll.find_one() # Assert that the callback has been called once. self.assertEqual(self.request_called, 1) # Perform a ``find`` operation that succeeds. - client.db.coll.find_one() + client.test.coll.find_one() # Assert that the callback has been called once. self.assertEqual(self.request_called, 1) @@ -963,7 +963,7 @@ def test_4_1_reauthentication_succeeds(self): } ): # Perform a ``find`` operation that succeeds. - client.db.coll.find_one() + client.test.coll.find_one() # Verify that the callback was called 2 times (once during the connection # handshake, and again during reauthentication). @@ -989,7 +989,7 @@ def fetch(self, _): client = self.create_client(request_cb=callback) # Perform a read operation that succeeds. - client.db.coll.find_one() + client.test.coll.find_one() # Set a fail point for the find command. with self.fail_point( @@ -1000,7 +1000,7 @@ def fetch(self, _): ): # Perform a ``find`` operation that fails. with self.assertRaises(OperationFailure): - client.db.coll.find_one() + client.test.coll.find_one() # Verify that the callback was called 2 times. self.assertEqual(callback.count, 2) @@ -1025,7 +1025,7 @@ def fetch(self, _): client = self.create_client(request_cb=callback) # Perform an insert operation that succeeds. - client.db.coll.insert_one({}) + client.test.coll.insert_one({}) # Set a fail point for the find command. with self.fail_point( @@ -1036,7 +1036,7 @@ def fetch(self, _): ): # Perform a ``insert`` operation that fails. with self.assertRaises(OperationFailure): - client.db.coll.insert_one({}) + client.test.coll.insert_one({}) # Verify that the callback was called 2 times. self.assertEqual(callback.count, 2) @@ -1049,7 +1049,7 @@ def test_4_4_speculative_authentication_should_be_ignored_on_reauthentication(se # Preload the *Client Cache* with a valid access token to enforce Speculative Authentication. client2 = self.create_client() - client2.db.coll.find_one() + client2.test.coll.find_one() client.options.pool_options._credentials.cache.data = ( client2.options.pool_options._credentials.cache.data ) @@ -1057,7 +1057,7 @@ def test_4_4_speculative_authentication_should_be_ignored_on_reauthentication(se self.request_called = 0 # Perform an `insert` operation that succeeds. - client.db.coll.insert_one({}) + client.test.coll.insert_one({}) # Assert that the callback was not called. self.assertEqual(self.request_called, 0) @@ -1076,7 +1076,7 @@ def test_4_4_speculative_authentication_should_be_ignored_on_reauthentication(se } ): # Perform an `insert` operation that succeeds. - client.db.coll.insert_one({}) + client.test.coll.insert_one({}) # Assert that the callback was called once. self.assertEqual(self.request_called, 1) @@ -1098,7 +1098,7 @@ def test_4_5_reauthentication_succeeds_when_a_session_is_involved(self): # Start a new session. with client.start_session() as session: # In the started session perform a `find` operation that succeeds. - client.db.coll.find_one({}, session=session) + client.test.coll.find_one({}, session=session) # Assert that the callback was called 2 times (once during the connection handshake, and again during reauthentication). self.assertEqual(self.request_called, 2) @@ -1111,7 +1111,7 @@ def test_5_1_azure_with_no_username(self): props = dict(TOKEN_RESOURCE=resource, ENVIRONMENT="azure") client = self.create_client(authMechanismProperties=props) - client.db.coll.find_one() + client.test.coll.find_one() def test_5_2_azure_with_bad_username(self): if ENVIRON != "azure": @@ -1123,11 +1123,11 @@ def test_5_2_azure_with_bad_username(self): props = dict(TOKEN_RESOURCE=token_aud, ENVIRONMENT="azure") client = self.create_client(username="bad", authmechanismproperties=props) with self.assertRaises(ValueError): - client.db.coll.find_one() + client.test.coll.find_one() def test_speculative_auth_success(self): client1 = self.create_client() - client1.db.coll.find_one() + client1.test.coll.find_one() client2 = self.create_client() client2._connect() @@ -1144,15 +1144,15 @@ def test_speculative_auth_success(self): } ): # Perform a find operation. - client2.db.coll.find_one() + client2.test.coll.find_one() def test_reauthentication_succeeds_multiple_connections(self): client1 = self.create_client() client2 = self.create_client() # Perform an insert operation. - client1.db.coll.insert_many([{"a": 1}, {"a": 1}]) - client2.db.coll.find_one() + client1.test.coll.insert_many([{"a": 1}, {"a": 1}]) + client2.test.coll.find_one() self.assertEqual(self.request_called, 2) # Use the same authenticator for both clients @@ -1163,8 +1163,8 @@ def test_reauthentication_succeeds_multiple_connections(self): client1.options.pool_options._credentials.cache.data ) - client1.db.coll.find_one() - client2.db.coll.find_one() + client1.test.coll.find_one() + client2.test.coll.find_one() with self.fail_point( { @@ -1172,7 +1172,7 @@ def test_reauthentication_succeeds_multiple_connections(self): "data": {"failCommands": ["find"], "errorCode": 391}, } ): - client1.db.coll.find_one() + client1.test.coll.find_one() self.assertEqual(self.request_called, 3) @@ -1182,7 +1182,7 @@ def test_reauthentication_succeeds_multiple_connections(self): "data": {"failCommands": ["find"], "errorCode": 391}, } ): - client2.db.coll.find_one() + client2.test.coll.find_one() self.assertEqual(self.request_called, 3) diff --git a/test/test_client.py b/test/test_client.py index 52d5da5a21..f57ba6b867 100644 --- a/test/test_client.py +++ b/test/test_client.py @@ -1548,7 +1548,7 @@ def predicate(): wait_until(predicate, "update one document") client = self.rs_or_single_client(connect=False, w=0) - client.test_lazy_connect_w0.list_collection_names.delete_one({}) + client.test_lazy_connect_w0.coll.delete_one({}) def predicate(): return client.test_lazy_connect_w0.coll.count_documents({}) == 0 diff --git a/test/test_collection.py b/test/test_collection.py index ed957db8ab..85bf263c8f 100644 --- a/test/test_collection.py +++ b/test/test_collection.py @@ -999,7 +999,7 @@ def test_update_bypass_document_validation(self): db = self.db db.coll.drop() db.coll.insert_one({"z": 5}) - db.command(SON([("collMod", "test"), ("validator", {"z": {"$gte": 0}})])) + db.command(SON([("collMod", "coll"), ("validator", {"z": {"$gte": 0}})])) db_w0 = self.db.client.get_database(self.db.name, write_concern=WriteConcern(w=0)) # Test update_one From 2b0c783ec9a05792f72d786074736e8260e93438 Mon Sep 17 00:00:00 2001 From: Sophia Yang Date: Fri, 12 Jun 2026 16:32:08 -0400 Subject: [PATCH 3/9] test to coll --- test/asynchronous/test_database.py | 4 +- test/asynchronous/test_encryption.py | 2 +- test/asynchronous/test_monitoring.py | 4 +- test/auth/unified/mongodb-oidc-no-retry.json | 4 +- .../causal-consistency-clientBulkWrite.json | 2 +- .../causal-consistency-write-commands.json | 56 +++++++++---------- .../clustered-indexes.json | 20 +++---- .../createCollection-pre_and_post_images.json | 4 +- .../timeseries-collection.json | 16 +++--- test/command_monitoring/bulkWrite.json | 4 +- test/command_monitoring/deleteMany.json | 4 +- test/command_monitoring/deleteOne.json | 4 +- test/command_monitoring/find.json | 12 ++-- test/command_monitoring/insertMany.json | 4 +- test/command_monitoring/insertOne.json | 4 +- .../unacknowledgedBulkWrite.json | 2 +- test/command_monitoring/updateMany.json | 4 +- test/command_monitoring/updateOne.json | 6 +- .../command_monitoring/writeConcernError.json | 4 +- test/test_database.py | 4 +- test/test_encryption.py | 2 +- test/test_monitoring.py | 4 +- test/transactions/unified/delete.json | 10 ++-- .../unified/transaction-options.json | 32 +++++------ test/transactions/unified/write-concern.json | 22 ++++---- 25 files changed, 117 insertions(+), 117 deletions(-) diff --git a/test/asynchronous/test_database.py b/test/asynchronous/test_database.py index e0b8548200..850029c7ae 100644 --- a/test/asynchronous/test_database.py +++ b/test/asynchronous/test_database.py @@ -415,7 +415,7 @@ async def test_command_with_regex(self): await db.coll.insert_one({"r": re.compile(".*")}) await db.coll.insert_one({"r": Regex(".*")}) - result = await db.command("aggregate", "test", pipeline=[], cursor={}) + result = await db.command("aggregate", "coll", pipeline=[], cursor={}) for doc in result["cursor"]["firstBatch"]: self.assertIsInstance(doc["r"], Regex) @@ -441,7 +441,7 @@ async def test_cursor_command(self): docs = [{"_id": i, "doc": i} for i in range(3)] await db.coll.insert_many(docs) - cursor = await db.cursor_command("find", "test") + cursor = await db.cursor_command("find", "coll") self.assertIsInstance(cursor, AsyncCommandCursor) diff --git a/test/asynchronous/test_encryption.py b/test/asynchronous/test_encryption.py index d4d185b496..beb6172a9e 100644 --- a/test/asynchronous/test_encryption.py +++ b/test/asynchronous/test_encryption.py @@ -329,7 +329,7 @@ async def count_documents(): await async_wait_until(count_documents, "insert documents with w=0") # Database.command auto decrypts. - res = await client.db.command("find", "test", filter={"ssn": "000"}) + res = await client.db.command("find", "coll", filter={"ssn": "000"}) decrypted_docs = res["cursor"]["firstBatch"] self.assertEqual(decrypted_docs, [{"_id": 0, "ssn": "000"}]) diff --git a/test/asynchronous/test_monitoring.py b/test/asynchronous/test_monitoring.py index 1cbc302dcf..bcc5955861 100644 --- a/test/asynchronous/test_monitoring.py +++ b/test/asynchronous/test_monitoring.py @@ -261,7 +261,7 @@ async def test_find_options(self): } cmd = { - "find": "test", + "find": "coll", "filter": {}, "hint": SON([("x", 1)]), "comment": "this is a test", @@ -289,7 +289,7 @@ async def test_find_snapshot(self): # Test "snapshot" parameter separately, can't combine with "sort". query = {"filter": {}, "snapshot": True} - cmd = {"find": "test", "filter": {}, "snapshot": True} + cmd = {"find": "coll", "filter": {}, "snapshot": True} await self._test_find_options(query, cmd) diff --git a/test/auth/unified/mongodb-oidc-no-retry.json b/test/auth/unified/mongodb-oidc-no-retry.json index 82e05a4790..b32ada172a 100644 --- a/test/auth/unified/mongodb-oidc-no-retry.json +++ b/test/auth/unified/mongodb-oidc-no-retry.json @@ -39,7 +39,7 @@ "database": { "id": "database0", "client": "client0", - "databaseName": "db" + "databaseName": "test" } }, { @@ -53,7 +53,7 @@ "initialData": [ { "collectionName": "collName", - "databaseName": "db", + "databaseName": "test", "documents": [] } ], diff --git a/test/causal_consistency/causal-consistency-clientBulkWrite.json b/test/causal_consistency/causal-consistency-clientBulkWrite.json index 18cd3697d0..0781d38707 100644 --- a/test/causal_consistency/causal-consistency-clientBulkWrite.json +++ b/test/causal_consistency/causal-consistency-clientBulkWrite.json @@ -114,7 +114,7 @@ "commandStartedEvent": { "commandName": "find", "command": { - "find": "test", + "find": "coll", "readConcern": { "$$exists": false }, diff --git a/test/causal_consistency/causal-consistency-write-commands.json b/test/causal_consistency/causal-consistency-write-commands.json index 673b1c82b3..4124929212 100644 --- a/test/causal_consistency/causal-consistency-write-commands.json +++ b/test/causal_consistency/causal-consistency-write-commands.json @@ -113,7 +113,7 @@ "commandStartedEvent": { "commandName": "find", "command": { - "find": "test", + "find": "coll", "readConcern": { "$$exists": false }, @@ -127,7 +127,7 @@ "commandStartedEvent": { "commandName": "insert", "command": { - "insert": "test", + "insert": "coll", "lsid": { "$$sessionLsid": "session0" }, @@ -189,7 +189,7 @@ "commandStartedEvent": { "commandName": "find", "command": { - "find": "test", + "find": "coll", "readConcern": { "$$exists": false }, @@ -203,7 +203,7 @@ "commandStartedEvent": { "commandName": "insert", "command": { - "insert": "test", + "insert": "coll", "lsid": { "$$sessionLsid": "session0" }, @@ -270,7 +270,7 @@ "commandStartedEvent": { "commandName": "find", "command": { - "find": "test", + "find": "coll", "readConcern": { "$$exists": false }, @@ -284,7 +284,7 @@ "commandStartedEvent": { "commandName": "update", "command": { - "update": "test", + "update": "coll", "lsid": { "$$sessionLsid": "session0" }, @@ -353,7 +353,7 @@ "commandStartedEvent": { "commandName": "find", "command": { - "find": "test", + "find": "coll", "readConcern": { "$$exists": false }, @@ -367,7 +367,7 @@ "commandStartedEvent": { "commandName": "update", "command": { - "update": "test", + "update": "coll", "lsid": { "$$sessionLsid": "session0" }, @@ -432,7 +432,7 @@ "commandStartedEvent": { "commandName": "find", "command": { - "find": "test", + "find": "coll", "readConcern": { "$$exists": false }, @@ -446,7 +446,7 @@ "commandStartedEvent": { "commandName": "update", "command": { - "update": "test", + "update": "coll", "lsid": { "$$sessionLsid": "session0" }, @@ -506,7 +506,7 @@ "commandStartedEvent": { "commandName": "find", "command": { - "find": "test", + "find": "coll", "readConcern": { "$$exists": false }, @@ -520,7 +520,7 @@ "commandStartedEvent": { "commandName": "delete", "command": { - "delete": "test", + "delete": "coll", "lsid": { "$$sessionLsid": "session0" }, @@ -582,7 +582,7 @@ "commandStartedEvent": { "commandName": "find", "command": { - "find": "test", + "find": "coll", "readConcern": { "$$exists": false }, @@ -596,7 +596,7 @@ "commandStartedEvent": { "commandName": "delete", "command": { - "delete": "test", + "delete": "coll", "lsid": { "$$sessionLsid": "session0" }, @@ -662,7 +662,7 @@ "commandStartedEvent": { "commandName": "find", "command": { - "find": "test", + "find": "coll", "readConcern": { "$$exists": false }, @@ -737,7 +737,7 @@ "commandStartedEvent": { "commandName": "find", "command": { - "find": "test", + "find": "coll", "readConcern": { "$$exists": false }, @@ -815,7 +815,7 @@ "commandStartedEvent": { "commandName": "find", "command": { - "find": "test", + "find": "coll", "readConcern": { "$$exists": false }, @@ -911,7 +911,7 @@ "commandStartedEvent": { "commandName": "find", "command": { - "find": "test", + "find": "coll", "readConcern": { "$$exists": false }, @@ -925,7 +925,7 @@ "commandStartedEvent": { "commandName": "insert", "command": { - "insert": "test", + "insert": "coll", "lsid": { "$$sessionLsid": "session0" }, @@ -944,7 +944,7 @@ "commandStartedEvent": { "commandName": "update", "command": { - "update": "test", + "update": "coll", "lsid": { "$$sessionLsid": "session0" }, @@ -963,7 +963,7 @@ "commandStartedEvent": { "commandName": "delete", "command": { - "delete": "test", + "delete": "coll", "lsid": { "$$sessionLsid": "session0" }, @@ -1026,7 +1026,7 @@ "commandStartedEvent": { "commandName": "find", "command": { - "find": "test", + "find": "coll", "readConcern": { "$$exists": false }, @@ -1109,7 +1109,7 @@ "commandStartedEvent": { "commandName": "find", "command": { - "find": "test", + "find": "coll", "readConcern": { "$$exists": false }, @@ -1178,7 +1178,7 @@ "commandStartedEvent": { "commandName": "find", "command": { - "find": "test", + "find": "coll", "readConcern": { "$$exists": false }, @@ -1192,7 +1192,7 @@ "commandStartedEvent": { "commandName": "drop", "command": { - "drop": "test", + "drop": "coll", "lsid": { "$$sessionLsid": "session0" }, @@ -1247,7 +1247,7 @@ "commandStartedEvent": { "commandName": "find", "command": { - "find": "test", + "find": "coll", "readConcern": { "$$exists": false }, @@ -1316,7 +1316,7 @@ "commandStartedEvent": { "commandName": "find", "command": { - "find": "test", + "find": "coll", "readConcern": { "$$exists": false }, @@ -1378,7 +1378,7 @@ "commandStartedEvent": { "commandName": "insert", "command": { - "insert": "test", + "insert": "coll", "lsid": { "$$sessionLsid": "session0" }, diff --git a/test/collection_management/clustered-indexes.json b/test/collection_management/clustered-indexes.json index 5e87aad0f1..d00f762bf3 100644 --- a/test/collection_management/clustered-indexes.json +++ b/test/collection_management/clustered-indexes.json @@ -79,7 +79,7 @@ { "commandStartedEvent": { "command": { - "drop": "test" + "drop": "coll" }, "databaseName": "ci-tests" } @@ -87,7 +87,7 @@ { "commandStartedEvent": { "command": { - "create": "test", + "create": "coll", "clusteredIndex": { "key": { "_id": 1 @@ -133,13 +133,13 @@ "arguments": { "filter": { "name": { - "$eq": "test" + "$eq": "coll" } } }, "expectResult": [ { - "name": "test", + "name": "coll", "options": { "clusteredIndex": { "key": { @@ -166,7 +166,7 @@ { "commandStartedEvent": { "command": { - "drop": "test" + "drop": "coll" }, "databaseName": "ci-tests" } @@ -174,7 +174,7 @@ { "commandStartedEvent": { "command": { - "create": "test", + "create": "coll", "clusteredIndex": { "key": { "_id": 1 @@ -192,7 +192,7 @@ "listCollections": 1, "filter": { "name": { - "$eq": "test" + "$eq": "coll" } } }, @@ -255,7 +255,7 @@ { "commandStartedEvent": { "command": { - "drop": "test" + "drop": "coll" }, "databaseName": "ci-tests" } @@ -263,7 +263,7 @@ { "commandStartedEvent": { "command": { - "create": "test", + "create": "coll", "clusteredIndex": { "key": { "_id": 1 @@ -278,7 +278,7 @@ { "commandStartedEvent": { "command": { - "listIndexes": "test" + "listIndexes": "coll" }, "databaseName": "ci-tests" } diff --git a/test/collection_management/createCollection-pre_and_post_images.json b/test/collection_management/createCollection-pre_and_post_images.json index e6d2734ea7..f79727df84 100644 --- a/test/collection_management/createCollection-pre_and_post_images.json +++ b/test/collection_management/createCollection-pre_and_post_images.json @@ -68,7 +68,7 @@ { "commandStartedEvent": { "command": { - "drop": "test" + "drop": "coll" }, "databaseName": "papi-tests" } @@ -76,7 +76,7 @@ { "commandStartedEvent": { "command": { - "create": "test", + "create": "coll", "changeStreamPreAndPostImages": { "enabled": true } diff --git a/test/collection_management/timeseries-collection.json b/test/collection_management/timeseries-collection.json index 0e6aac8df2..2630dd41de 100644 --- a/test/collection_management/timeseries-collection.json +++ b/test/collection_management/timeseries-collection.json @@ -77,7 +77,7 @@ { "commandStartedEvent": { "command": { - "drop": "test" + "drop": "coll" }, "databaseName": "ts-tests" } @@ -85,7 +85,7 @@ { "commandStartedEvent": { "command": { - "create": "test", + "create": "coll", "expireAfterSeconds": 604800, "timeseries": { "timeField": "time", @@ -191,7 +191,7 @@ { "commandStartedEvent": { "command": { - "drop": "test" + "drop": "coll" }, "databaseName": "ts-tests" } @@ -199,7 +199,7 @@ { "commandStartedEvent": { "command": { - "create": "test", + "create": "coll", "expireAfterSeconds": 604800, "timeseries": { "timeField": "time", @@ -213,7 +213,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1, @@ -238,7 +238,7 @@ { "commandStartedEvent": { "command": { - "find": "test", + "find": "coll", "filter": {}, "sort": { "time": 1 @@ -294,7 +294,7 @@ { "commandStartedEvent": { "command": { - "drop": "test" + "drop": "coll" }, "databaseName": "ts-tests" } @@ -302,7 +302,7 @@ { "commandStartedEvent": { "command": { - "create": "test", + "create": "coll", "timeseries": { "timeField": "time", "bucketMaxSpanSeconds": 3600, diff --git a/test/command_monitoring/bulkWrite.json b/test/command_monitoring/bulkWrite.json index f7563bcc99..6bda94f1ad 100644 --- a/test/command_monitoring/bulkWrite.json +++ b/test/command_monitoring/bulkWrite.json @@ -87,7 +87,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 4, @@ -112,7 +112,7 @@ { "commandStartedEvent": { "command": { - "update": "test", + "update": "coll", "updates": [ { "q": { diff --git a/test/command_monitoring/deleteMany.json b/test/command_monitoring/deleteMany.json index 7cebe04c62..836e2ac67c 100644 --- a/test/command_monitoring/deleteMany.json +++ b/test/command_monitoring/deleteMany.json @@ -70,7 +70,7 @@ { "commandStartedEvent": { "command": { - "delete": "test", + "delete": "coll", "deletes": [ { "q": { @@ -125,7 +125,7 @@ { "commandStartedEvent": { "command": { - "delete": "test", + "delete": "coll", "deletes": [ { "q": { diff --git a/test/command_monitoring/deleteOne.json b/test/command_monitoring/deleteOne.json index 463e91f4fb..54f55409a8 100644 --- a/test/command_monitoring/deleteOne.json +++ b/test/command_monitoring/deleteOne.json @@ -70,7 +70,7 @@ { "commandStartedEvent": { "command": { - "delete": "test", + "delete": "coll", "deletes": [ { "q": { @@ -125,7 +125,7 @@ { "commandStartedEvent": { "command": { - "delete": "test", + "delete": "coll", "deletes": [ { "q": { diff --git a/test/command_monitoring/find.json b/test/command_monitoring/find.json index 272b8e17da..7afc312ee4 100644 --- a/test/command_monitoring/find.json +++ b/test/command_monitoring/find.json @@ -79,7 +79,7 @@ { "commandStartedEvent": { "command": { - "find": "test", + "find": "coll", "filter": { "_id": 1 } @@ -152,7 +152,7 @@ { "commandStartedEvent": { "command": { - "find": "test", + "find": "coll", "filter": { "_id": { "$gt": 1 @@ -230,7 +230,7 @@ { "commandStartedEvent": { "command": { - "find": "test", + "find": "coll", "showRecordId": true, "returnKey": true }, @@ -298,7 +298,7 @@ { "commandStartedEvent": { "command": { - "find": "test", + "find": "coll", "filter": { "_id": { "$gte": 1 @@ -425,7 +425,7 @@ { "commandStartedEvent": { "command": { - "find": "test", + "find": "coll", "filter": { "_id": { "$gte": 1 @@ -535,7 +535,7 @@ { "commandStartedEvent": { "command": { - "find": "test", + "find": "coll", "filter": { "$or": true } diff --git a/test/command_monitoring/insertMany.json b/test/command_monitoring/insertMany.json index 2a9ef788bb..c9b1d3fd72 100644 --- a/test/command_monitoring/insertMany.json +++ b/test/command_monitoring/insertMany.json @@ -63,7 +63,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 2, @@ -115,7 +115,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1, diff --git a/test/command_monitoring/insertOne.json b/test/command_monitoring/insertOne.json index cb6131cc42..902d795e4e 100644 --- a/test/command_monitoring/insertOne.json +++ b/test/command_monitoring/insertOne.json @@ -61,7 +61,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 2, @@ -111,7 +111,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1, diff --git a/test/command_monitoring/unacknowledgedBulkWrite.json b/test/command_monitoring/unacknowledgedBulkWrite.json index 7936e56550..42f22b8a25 100644 --- a/test/command_monitoring/unacknowledgedBulkWrite.json +++ b/test/command_monitoring/unacknowledgedBulkWrite.json @@ -82,7 +82,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": "unorderedBulkWriteInsertW0", diff --git a/test/command_monitoring/updateMany.json b/test/command_monitoring/updateMany.json index 37f1ad615b..a93b72a59c 100644 --- a/test/command_monitoring/updateMany.json +++ b/test/command_monitoring/updateMany.json @@ -75,7 +75,7 @@ { "commandStartedEvent": { "command": { - "update": "test", + "update": "coll", "updates": [ { "q": { @@ -143,7 +143,7 @@ { "commandStartedEvent": { "command": { - "update": "test", + "update": "coll", "updates": [ { "q": { diff --git a/test/command_monitoring/updateOne.json b/test/command_monitoring/updateOne.json index 22905bf16e..7e53e60c80 100644 --- a/test/command_monitoring/updateOne.json +++ b/test/command_monitoring/updateOne.json @@ -75,7 +75,7 @@ { "commandStartedEvent": { "command": { - "update": "test", + "update": "coll", "updates": [ { "q": { @@ -141,7 +141,7 @@ { "commandStartedEvent": { "command": { - "update": "test", + "update": "coll", "updates": [ { "q": { @@ -213,7 +213,7 @@ { "commandStartedEvent": { "command": { - "update": "test", + "update": "coll", "updates": [ { "q": { diff --git a/test/command_monitoring/writeConcernError.json b/test/command_monitoring/writeConcernError.json index 32aa60a606..ca2c679149 100644 --- a/test/command_monitoring/writeConcernError.json +++ b/test/command_monitoring/writeConcernError.json @@ -94,7 +94,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 2, @@ -125,7 +125,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 2, diff --git a/test/test_database.py b/test/test_database.py index 6c9cfe7afa..8a25b2b86d 100644 --- a/test/test_database.py +++ b/test/test_database.py @@ -412,7 +412,7 @@ def test_command_with_regex(self): db.coll.insert_one({"r": re.compile(".*")}) db.coll.insert_one({"r": Regex(".*")}) - result = db.command("aggregate", "test", pipeline=[], cursor={}) + result = db.command("aggregate", "coll", pipeline=[], cursor={}) for doc in result["cursor"]["firstBatch"]: self.assertIsInstance(doc["r"], Regex) @@ -438,7 +438,7 @@ def test_cursor_command(self): docs = [{"_id": i, "doc": i} for i in range(3)] db.coll.insert_many(docs) - cursor = db.cursor_command("find", "test") + cursor = db.cursor_command("find", "coll") self.assertIsInstance(cursor, CommandCursor) diff --git a/test/test_encryption.py b/test/test_encryption.py index 262a693729..67a2256421 100644 --- a/test/test_encryption.py +++ b/test/test_encryption.py @@ -329,7 +329,7 @@ def count_documents(): wait_until(count_documents, "insert documents with w=0") # Database.command auto decrypts. - res = client.db.command("find", "test", filter={"ssn": "000"}) + res = client.db.command("find", "coll", filter={"ssn": "000"}) decrypted_docs = res["cursor"]["firstBatch"] self.assertEqual(decrypted_docs, [{"_id": 0, "ssn": "000"}]) diff --git a/test/test_monitoring.py b/test/test_monitoring.py index c933b75c7b..d81f71ae40 100644 --- a/test/test_monitoring.py +++ b/test/test_monitoring.py @@ -259,7 +259,7 @@ def test_find_options(self): } cmd = { - "find": "test", + "find": "coll", "filter": {}, "hint": SON([("x", 1)]), "comment": "this is a test", @@ -287,7 +287,7 @@ def test_find_snapshot(self): # Test "snapshot" parameter separately, can't combine with "sort". query = {"filter": {}, "snapshot": True} - cmd = {"find": "test", "filter": {}, "snapshot": True} + cmd = {"find": "coll", "filter": {}, "snapshot": True} self._test_find_options(query, cmd) diff --git a/test/transactions/unified/delete.json b/test/transactions/unified/delete.json index 6586707e73..d35a63e870 100644 --- a/test/transactions/unified/delete.json +++ b/test/transactions/unified/delete.json @@ -131,7 +131,7 @@ { "commandStartedEvent": { "command": { - "delete": "test", + "delete": "coll", "deletes": [ { "q": { @@ -163,7 +163,7 @@ { "commandStartedEvent": { "command": { - "delete": "test", + "delete": "coll", "deletes": [ { "q": { @@ -196,7 +196,7 @@ { "commandStartedEvent": { "command": { - "delete": "test", + "delete": "coll", "deletes": [ { "q": { @@ -333,7 +333,7 @@ { "commandStartedEvent": { "command": { - "delete": "test", + "delete": "coll", "deletes": [ { "q": { @@ -365,7 +365,7 @@ { "commandStartedEvent": { "command": { - "delete": "test", + "delete": "coll", "deletes": [ { "q": { diff --git a/test/transactions/unified/transaction-options.json b/test/transactions/unified/transaction-options.json index 58a960f8d2..558373a144 100644 --- a/test/transactions/unified/transaction-options.json +++ b/test/transactions/unified/transaction-options.json @@ -116,7 +116,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -176,7 +176,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 2 @@ -352,7 +352,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -412,7 +412,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 2 @@ -573,7 +573,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -628,7 +628,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 2 @@ -827,7 +827,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -885,7 +885,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 2 @@ -1073,7 +1073,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -1131,7 +1131,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 2 @@ -1314,7 +1314,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -1368,7 +1368,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 2 @@ -1530,7 +1530,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -1682,7 +1682,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -1844,7 +1844,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -2011,7 +2011,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 diff --git a/test/transactions/unified/write-concern.json b/test/transactions/unified/write-concern.json index 5779c571ef..7560431d9e 100644 --- a/test/transactions/unified/write-concern.json +++ b/test/transactions/unified/write-concern.json @@ -112,7 +112,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -214,7 +214,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -321,7 +321,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -420,7 +420,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -573,7 +573,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -683,7 +683,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -803,7 +803,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -901,7 +901,7 @@ { "commandStartedEvent": { "command": { - "delete": "test", + "delete": "coll", "deletes": [ { "q": { @@ -995,7 +995,7 @@ { "commandStartedEvent": { "command": { - "delete": "test", + "delete": "coll", "deletes": [ { "q": { @@ -1097,7 +1097,7 @@ { "commandStartedEvent": { "command": { - "update": "test", + "update": "coll", "updates": [ { "q": { @@ -1212,7 +1212,7 @@ { "commandStartedEvent": { "command": { - "update": "test", + "update": "coll", "updates": [ { "q": { From 6df3486d882e0ff358d68e79ea7d0b5c8e60b682 Mon Sep 17 00:00:00 2001 From: Sophia Yang Date: Fri, 12 Jun 2026 16:49:29 -0400 Subject: [PATCH 4/9] more fixes --- test/asynchronous/test_collection.py | 20 ++++++------ test/asynchronous/test_cursor.py | 12 +++---- test/asynchronous/test_database.py | 20 ++++++------ test/command_monitoring/find.json | 16 +++++----- .../unacknowledged-client-bulkWrite.json | 8 ++--- .../aggregate-merge-errorResponse.json | 2 +- test/crud/unified/bulkWrite-arrayFilters.json | 4 +-- .../bulkWrite-updateMany-pipeline.json | 2 +- .../unified/bulkWrite-updateOne-pipeline.json | 2 +- test/crud/unified/updateMany-pipeline.json | 2 +- test/crud/unified/updateOne-pipeline.json | 2 +- test/test_collection.py | 20 ++++++------ test/test_cursor.py | 12 +++---- test/test_database.py | 20 ++++++------ .../crud-api-version-1-strict.json | 32 +++++++++---------- test/versioned-api/crud-api-version-1.json | 32 +++++++++---------- 16 files changed, 103 insertions(+), 103 deletions(-) diff --git a/test/asynchronous/test_collection.py b/test/asynchronous/test_collection.py index a5870df6a2..7a81a6b0c4 100644 --- a/test/asynchronous/test_collection.py +++ b/test/asynchronous/test_collection.py @@ -930,10 +930,10 @@ async def test_insert_bypass_document_validation(self): self.assertIsInstance(result, InsertOneResult) self.assertEqual(2, result.inserted_id) - await db_w0.test.insert_one({"y": 1}, bypass_document_validation=True) + await db_w0.coll.insert_one({"y": 1}, bypass_document_validation=True) async def async_lambda(): - return await db_w0.test.find_one({"y": 1}) + return await db_w0.coll.find_one({"y": 1}) await async_wait_until(async_lambda, "find w:0 inserted document") @@ -962,7 +962,7 @@ async def async_lambda(): self.assertTrue(result.acknowledged) with self.assertRaises(OperationFailure): - await db_w0.test.insert_many( + await db_w0.coll.insert_many( [{"x": 1}, {"x": 2}], bypass_document_validation=True, ) @@ -1000,10 +1000,10 @@ async def test_replace_bypass_document_validation(self): self.assertEqual(1, await db.coll.count_documents({"a": 103})) await db.coll.insert_one({"y": 1}, bypass_document_validation=True) - await db_w0.test.replace_one({"y": 1}, {"x": 1}, bypass_document_validation=True) + await db_w0.coll.replace_one({"y": 1}, {"x": 1}, bypass_document_validation=True) async def predicate(): - return await db_w0.test.find_one({"x": 1}) + return await db_w0.coll.find_one({"x": 1}) await async_wait_until(predicate, "find w:0 replaced document") @@ -1039,10 +1039,10 @@ async def test_update_bypass_document_validation(self): self.assertEqual(1, await db.coll.count_documents({"z": 0})) await db.coll.insert_one({"y": 1, "x": 0}, bypass_document_validation=True) - await db_w0.test.update_one({"y": 1}, {"$inc": {"x": 1}}, bypass_document_validation=True) + await db_w0.coll.update_one({"y": 1}, {"$inc": {"x": 1}}, bypass_document_validation=True) async def async_lambda(): - return await db_w0.test.find_one({"y": 1, "x": 1}) + return await db_w0.coll.find_one({"y": 1, "x": 1}) await async_wait_until(async_lambda, "find w:0 updated document") @@ -1083,10 +1083,10 @@ async def async_lambda(): await db.coll.insert_one({"m": 1, "x": 0}, bypass_document_validation=True) await db.coll.insert_one({"m": 1, "x": 0}, bypass_document_validation=True) - await db_w0.test.update_many({"m": 1}, {"$inc": {"x": 1}}, bypass_document_validation=True) + await db_w0.coll.update_many({"m": 1}, {"$inc": {"x": 1}}, bypass_document_validation=True) async def async_lambda(): - return await db_w0.test.count_documents({"m": 1, "x": 1}) == 2 + return await db_w0.coll.count_documents({"m": 1, "x": 1}) == 2 await async_wait_until(async_lambda, "find w:0 updated documents") @@ -1117,7 +1117,7 @@ async def test_bypass_document_validation_bulk_write(self): await db.coll.bulk_write([op]) with self.assertRaises(OperationFailure): - await db_w0.test.bulk_write(ops, bypass_document_validation=True) + await db_w0.coll.bulk_write(ops, bypass_document_validation=True) async def test_find_by_default_dct(self): db = self.db diff --git a/test/asynchronous/test_cursor.py b/test/asynchronous/test_cursor.py index cd20310f2b..daf506a4c6 100644 --- a/test/asynchronous/test_cursor.py +++ b/test/asynchronous/test_cursor.py @@ -1304,7 +1304,7 @@ async def test_close_kills_cursor_synchronously(self): listener = AllowListEventListener("killCursors") client = await self.async_rs_or_single_client(event_listeners=[listener]) - coll = client[self.db.name].test_close_kills_cursors + coll = client[self.db.name].coll # Add some test data. docs_inserted = 1000 @@ -1342,7 +1342,7 @@ def assertCursorKilled(): async def test_timeout_kills_cursor_asynchronously(self): listener = AllowListEventListener("killCursors") client = await self.async_rs_or_single_client(event_listeners=[listener]) - coll = client[self.db.name].test_timeout_kills_cursor + coll = client[self.db.name].coll_timeout_kills_cursor # Add some test data. docs_inserted = 10 @@ -1539,7 +1539,7 @@ async def test_find_raw_transaction(self): async with client.start_session() as session: async with await session.start_transaction(): batches = await ( - client[self.db.name].test.find_raw_batches(session=session).sort("_id") + client[self.db.name].coll.find_raw_batches(session=session).sort("_id") ).to_list() cmd = listener.started_events[0] self.assertEqual(cmd.command_name, "find") @@ -1568,7 +1568,7 @@ async def test_find_raw_retryable_reads(self): async with self.fail_point( {"mode": {"times": 1}, "data": {"failCommands": ["find"], "closeConnection": True}} ): - batches = await client[self.db.name].test.find_raw_batches().sort("_id").to_list() + batches = await client[self.db.name].coll.find_raw_batches().sort("_id").to_list() self.assertEqual(1, len(batches)) self.assertEqual(docs, decode_all(batches[0])) @@ -1709,7 +1709,7 @@ async def test_aggregate_raw_transaction(self): async with client.start_session() as session: async with await session.start_transaction(): batches = await ( - await client[self.db.name].test.aggregate_raw_batches( + await client[self.db.name].coll.aggregate_raw_batches( [{"$sort": {"_id": 1}}], session=session ) ).to_list() @@ -1741,7 +1741,7 @@ async def test_aggregate_raw_retryable_reads(self): {"mode": {"times": 1}, "data": {"failCommands": ["aggregate"], "closeConnection": True}} ): batches = await ( - await client[self.db.name].test.aggregate_raw_batches([{"$sort": {"_id": 1}}]) + await client[self.db.name].coll.aggregate_raw_batches([{"$sort": {"_id": 1}}]) ).to_list() self.assertEqual(1, len(batches)) diff --git a/test/asynchronous/test_database.py b/test/asynchronous/test_database.py index 850029c7ae..96029acda9 100644 --- a/test/asynchronous/test_database.py +++ b/test/asynchronous/test_database.py @@ -134,10 +134,10 @@ def test_hashable(self): def test_get_coll(self): db = AsyncDatabase(self.client, "db") - self.assertEqual(db.coll, db["test"]) - self.assertEqual(db.coll, AsyncCollection(db, "test")) + self.assertEqual(db.coll, db["coll"]) + self.assertEqual(db.coll, AsyncCollection(db, "coll")) self.assertNotEqual(db.coll, AsyncCollection(db, "mike")) - self.assertEqual(db.coll.mike, db["test.mike"]) + self.assertEqual(db.coll.mike, db["coll.mike"]) def test_repr(self): name = "AsyncDatabase" @@ -500,18 +500,18 @@ async def test_deref(self): with self.assertRaises(TypeError): await db.dereference(None) # type: ignore[arg-type] - self.assertEqual(None, await db.dereference(DBRef("test", ObjectId()))) + self.assertEqual(None, await db.dereference(DBRef("coll", ObjectId()))) obj: dict[str, Any] = {"x": True} key = (await db.coll.insert_one(obj)).inserted_id - self.assertEqual(obj, await db.dereference(DBRef("test", key))) - self.assertEqual(obj, await db.dereference(DBRef("test", key, "db"))) + self.assertEqual(obj, await db.dereference(DBRef("coll", key))) + self.assertEqual(obj, await db.dereference(DBRef("coll", key, "db"))) with self.assertRaises(ValueError): - await db.dereference(DBRef("test", key, "foo")) + await db.dereference(DBRef("coll", key, "foo")) - self.assertEqual(None, await db.dereference(DBRef("test", 4))) + self.assertEqual(None, await db.dereference(DBRef("coll", 4))) obj = {"_id": 4} await db.coll.insert_one(obj) - self.assertEqual(obj, await db.dereference(DBRef("test", 4))) + self.assertEqual(obj, await db.dereference(DBRef("coll", 4))) async def test_deref_kwargs(self): db = self.client.db @@ -522,7 +522,7 @@ async def test_deref_kwargs(self): "db", codec_options=CodecOptions(document_class=SON[str, Any]) ) self.assertEqual( - SON([("foo", "bar")]), await db.dereference(DBRef("test", 4), projection={"_id": False}) + SON([("foo", "bar")]), await db.dereference(DBRef("coll", 4), projection={"_id": False}) ) # TODO some of these tests belong in the collection level testing. diff --git a/test/command_monitoring/find.json b/test/command_monitoring/find.json index 7afc312ee4..32e2cca802 100644 --- a/test/command_monitoring/find.json +++ b/test/command_monitoring/find.json @@ -28,7 +28,7 @@ } ], "_yamlAnchors": { - "namespace": "command-monitoring-tests.test" + "namespace": "command-monitoring-tests.coll" }, "initialData": [ { @@ -94,7 +94,7 @@ "ok": 1, "cursor": { "id": 0, - "ns": "command-monitoring-tests.test", + "ns": "command-monitoring-tests.coll", "firstBatch": [ { "_id": 1, @@ -188,7 +188,7 @@ "ok": 1, "cursor": { "id": 0, - "ns": "command-monitoring-tests.test", + "ns": "command-monitoring-tests.coll", "firstBatch": [ { "x": 33 @@ -244,7 +244,7 @@ "ok": 1, "cursor": { "id": 0, - "ns": "command-monitoring-tests.test", + "ns": "command-monitoring-tests.coll", "firstBatch": [ { "_id": 1 @@ -324,7 +324,7 @@ "long" ] }, - "ns": "command-monitoring-tests.test", + "ns": "command-monitoring-tests.coll", "firstBatch": [ { "_id": 1, @@ -367,7 +367,7 @@ "ok": 1, "cursor": { "id": 0, - "ns": "command-monitoring-tests.test", + "ns": "command-monitoring-tests.coll", "nextBatch": [ { "_id": 4, @@ -452,7 +452,7 @@ "long" ] }, - "ns": "command-monitoring-tests.test", + "ns": "command-monitoring-tests.coll", "firstBatch": [ { "_id": 1, @@ -495,7 +495,7 @@ "ok": 1, "cursor": { "id": 0, - "ns": "command-monitoring-tests.test", + "ns": "command-monitoring-tests.coll", "nextBatch": [ { "_id": 4, diff --git a/test/command_monitoring/unacknowledged-client-bulkWrite.json b/test/command_monitoring/unacknowledged-client-bulkWrite.json index 7c8c4cef97..456ad1ed7c 100644 --- a/test/command_monitoring/unacknowledged-client-bulkWrite.json +++ b/test/command_monitoring/unacknowledged-client-bulkWrite.json @@ -58,7 +58,7 @@ } ], "_yamlAnchors": { - "namespace": "command-monitoring-tests.test" + "namespace": "command-monitoring-tests.coll" }, "tests": [ { @@ -71,7 +71,7 @@ "models": [ { "insertOne": { - "namespace": "command-monitoring-tests.test", + "namespace": "command-monitoring-tests.coll", "document": { "_id": 4, "x": 44 @@ -80,7 +80,7 @@ }, { "updateOne": { - "namespace": "command-monitoring-tests.test", + "namespace": "command-monitoring-tests.coll", "filter": { "_id": 3 }, @@ -188,7 +188,7 @@ ], "nsInfo": [ { - "ns": "command-monitoring-tests.test" + "ns": "command-monitoring-tests.coll" } ] } diff --git a/test/crud/unified/aggregate-merge-errorResponse.json b/test/crud/unified/aggregate-merge-errorResponse.json index 5cb794dab6..dd45b9c559 100644 --- a/test/crud/unified/aggregate-merge-errorResponse.json +++ b/test/crud/unified/aggregate-merge-errorResponse.json @@ -66,7 +66,7 @@ }, { "$merge": { - "into": "test", + "into": "coll", "whenMatched": "fail" } } diff --git a/test/crud/unified/bulkWrite-arrayFilters.json b/test/crud/unified/bulkWrite-arrayFilters.json index 407b1e8fa0..fa784bad1d 100644 --- a/test/crud/unified/bulkWrite-arrayFilters.json +++ b/test/crud/unified/bulkWrite-arrayFilters.json @@ -107,7 +107,7 @@ { "commandStartedEvent": { "command": { - "update": "test", + "update": "coll", "updates": [ { "q": {}, @@ -215,7 +215,7 @@ { "commandStartedEvent": { "command": { - "update": "test", + "update": "coll", "updates": [ { "q": {}, diff --git a/test/crud/unified/bulkWrite-updateMany-pipeline.json b/test/crud/unified/bulkWrite-updateMany-pipeline.json index ea58708d20..0da94a376e 100644 --- a/test/crud/unified/bulkWrite-updateMany-pipeline.json +++ b/test/crud/unified/bulkWrite-updateMany-pipeline.json @@ -95,7 +95,7 @@ { "commandStartedEvent": { "command": { - "update": "test", + "update": "coll", "updates": [ { "q": {}, diff --git a/test/crud/unified/bulkWrite-updateOne-pipeline.json b/test/crud/unified/bulkWrite-updateOne-pipeline.json index 2de9dc3861..9e29618f17 100644 --- a/test/crud/unified/bulkWrite-updateOne-pipeline.json +++ b/test/crud/unified/bulkWrite-updateOne-pipeline.json @@ -97,7 +97,7 @@ { "commandStartedEvent": { "command": { - "update": "test", + "update": "coll", "updates": [ { "q": { diff --git a/test/crud/unified/updateMany-pipeline.json b/test/crud/unified/updateMany-pipeline.json index 5349b54710..62f80da4b0 100644 --- a/test/crud/unified/updateMany-pipeline.json +++ b/test/crud/unified/updateMany-pipeline.json @@ -89,7 +89,7 @@ { "commandStartedEvent": { "command": { - "update": "test", + "update": "coll", "updates": [ { "q": {}, diff --git a/test/crud/unified/updateOne-pipeline.json b/test/crud/unified/updateOne-pipeline.json index af1a9fff77..4aae405bbb 100644 --- a/test/crud/unified/updateOne-pipeline.json +++ b/test/crud/unified/updateOne-pipeline.json @@ -91,7 +91,7 @@ { "commandStartedEvent": { "command": { - "update": "test", + "update": "coll", "updates": [ { "q": { diff --git a/test/test_collection.py b/test/test_collection.py index 85bf263c8f..6cb8434974 100644 --- a/test/test_collection.py +++ b/test/test_collection.py @@ -918,10 +918,10 @@ def test_insert_bypass_document_validation(self): self.assertIsInstance(result, InsertOneResult) self.assertEqual(2, result.inserted_id) - db_w0.test.insert_one({"y": 1}, bypass_document_validation=True) + db_w0.coll.insert_one({"y": 1}, bypass_document_validation=True) def async_lambda(): - return db_w0.test.find_one({"y": 1}) + return db_w0.coll.find_one({"y": 1}) wait_until(async_lambda, "find w:0 inserted document") @@ -950,7 +950,7 @@ def async_lambda(): self.assertTrue(result.acknowledged) with self.assertRaises(OperationFailure): - db_w0.test.insert_many( + db_w0.coll.insert_many( [{"x": 1}, {"x": 2}], bypass_document_validation=True, ) @@ -988,10 +988,10 @@ def test_replace_bypass_document_validation(self): self.assertEqual(1, db.coll.count_documents({"a": 103})) db.coll.insert_one({"y": 1}, bypass_document_validation=True) - db_w0.test.replace_one({"y": 1}, {"x": 1}, bypass_document_validation=True) + db_w0.coll.replace_one({"y": 1}, {"x": 1}, bypass_document_validation=True) def predicate(): - return db_w0.test.find_one({"x": 1}) + return db_w0.coll.find_one({"x": 1}) wait_until(predicate, "find w:0 replaced document") @@ -1027,10 +1027,10 @@ def test_update_bypass_document_validation(self): self.assertEqual(1, db.coll.count_documents({"z": 0})) db.coll.insert_one({"y": 1, "x": 0}, bypass_document_validation=True) - db_w0.test.update_one({"y": 1}, {"$inc": {"x": 1}}, bypass_document_validation=True) + db_w0.coll.update_one({"y": 1}, {"$inc": {"x": 1}}, bypass_document_validation=True) def async_lambda(): - return db_w0.test.find_one({"y": 1, "x": 1}) + return db_w0.coll.find_one({"y": 1, "x": 1}) wait_until(async_lambda, "find w:0 updated document") @@ -1071,10 +1071,10 @@ def async_lambda(): db.coll.insert_one({"m": 1, "x": 0}, bypass_document_validation=True) db.coll.insert_one({"m": 1, "x": 0}, bypass_document_validation=True) - db_w0.test.update_many({"m": 1}, {"$inc": {"x": 1}}, bypass_document_validation=True) + db_w0.coll.update_many({"m": 1}, {"$inc": {"x": 1}}, bypass_document_validation=True) def async_lambda(): - return db_w0.test.count_documents({"m": 1, "x": 1}) == 2 + return db_w0.coll.count_documents({"m": 1, "x": 1}) == 2 wait_until(async_lambda, "find w:0 updated documents") @@ -1105,7 +1105,7 @@ def test_bypass_document_validation_bulk_write(self): db.coll.bulk_write([op]) with self.assertRaises(OperationFailure): - db_w0.test.bulk_write(ops, bypass_document_validation=True) + db_w0.coll.bulk_write(ops, bypass_document_validation=True) def test_find_by_default_dct(self): db = self.db diff --git a/test/test_cursor.py b/test/test_cursor.py index 282e6381ad..e97a8e14cb 100644 --- a/test/test_cursor.py +++ b/test/test_cursor.py @@ -1297,7 +1297,7 @@ def test_close_kills_cursor_synchronously(self): listener = AllowListEventListener("killCursors") client = self.rs_or_single_client(event_listeners=[listener]) - coll = client[self.db.name].test_close_kills_cursors + coll = client[self.db.name].coll # Add some test data. docs_inserted = 1000 @@ -1335,7 +1335,7 @@ def assertCursorKilled(): def test_timeout_kills_cursor_synchronously(self): listener = AllowListEventListener("killCursors") client = self.rs_or_single_client(event_listeners=[listener]) - coll = client[self.db.name].test_timeout_kills_cursor + coll = client[self.db.name].coll_timeout_kills_cursor # Add some test data. docs_inserted = 10 @@ -1532,7 +1532,7 @@ def test_find_raw_transaction(self): with client.start_session() as session: with session.start_transaction(): batches = ( - client[self.db.name].test.find_raw_batches(session=session).sort("_id") + client[self.db.name].coll.find_raw_batches(session=session).sort("_id") ).to_list() cmd = listener.started_events[0] self.assertEqual(cmd.command_name, "find") @@ -1561,7 +1561,7 @@ def test_find_raw_retryable_reads(self): with self.fail_point( {"mode": {"times": 1}, "data": {"failCommands": ["find"], "closeConnection": True}} ): - batches = client[self.db.name].test.find_raw_batches().sort("_id").to_list() + batches = client[self.db.name].coll.find_raw_batches().sort("_id").to_list() self.assertEqual(1, len(batches)) self.assertEqual(docs, decode_all(batches[0])) @@ -1700,7 +1700,7 @@ def test_aggregate_raw_transaction(self): with client.start_session() as session: with session.start_transaction(): batches = ( - client[self.db.name].test.aggregate_raw_batches( + client[self.db.name].coll.aggregate_raw_batches( [{"$sort": {"_id": 1}}], session=session ) ).to_list() @@ -1732,7 +1732,7 @@ def test_aggregate_raw_retryable_reads(self): {"mode": {"times": 1}, "data": {"failCommands": ["aggregate"], "closeConnection": True}} ): batches = ( - client[self.db.name].test.aggregate_raw_batches([{"$sort": {"_id": 1}}]) + client[self.db.name].coll.aggregate_raw_batches([{"$sort": {"_id": 1}}]) ).to_list() self.assertEqual(1, len(batches)) diff --git a/test/test_database.py b/test/test_database.py index 8a25b2b86d..68e907eac5 100644 --- a/test/test_database.py +++ b/test/test_database.py @@ -133,10 +133,10 @@ def test_hashable(self): def test_get_coll(self): db = Database(self.client, "db") - self.assertEqual(db.coll, db["test"]) - self.assertEqual(db.coll, Collection(db, "test")) + self.assertEqual(db.coll, db["coll"]) + self.assertEqual(db.coll, Collection(db, "coll")) self.assertNotEqual(db.coll, Collection(db, "mike")) - self.assertEqual(db.coll.mike, db["test.mike"]) + self.assertEqual(db.coll.mike, db["coll.mike"]) def test_repr(self): name = "Database" @@ -497,18 +497,18 @@ def test_deref(self): with self.assertRaises(TypeError): db.dereference(None) # type: ignore[arg-type] - self.assertEqual(None, db.dereference(DBRef("test", ObjectId()))) + self.assertEqual(None, db.dereference(DBRef("coll", ObjectId()))) obj: dict[str, Any] = {"x": True} key = (db.coll.insert_one(obj)).inserted_id - self.assertEqual(obj, db.dereference(DBRef("test", key))) - self.assertEqual(obj, db.dereference(DBRef("test", key, "db"))) + self.assertEqual(obj, db.dereference(DBRef("coll", key))) + self.assertEqual(obj, db.dereference(DBRef("coll", key, "db"))) with self.assertRaises(ValueError): - db.dereference(DBRef("test", key, "foo")) + db.dereference(DBRef("coll", key, "foo")) - self.assertEqual(None, db.dereference(DBRef("test", 4))) + self.assertEqual(None, db.dereference(DBRef("coll", 4))) obj = {"_id": 4} db.coll.insert_one(obj) - self.assertEqual(obj, db.dereference(DBRef("test", 4))) + self.assertEqual(obj, db.dereference(DBRef("coll", 4))) def test_deref_kwargs(self): db = self.client.db @@ -519,7 +519,7 @@ def test_deref_kwargs(self): "db", codec_options=CodecOptions(document_class=SON[str, Any]) ) self.assertEqual( - SON([("foo", "bar")]), db.dereference(DBRef("test", 4), projection={"_id": False}) + SON([("foo", "bar")]), db.dereference(DBRef("coll", 4), projection={"_id": False}) ) # TODO some of these tests belong in the collection level testing. diff --git a/test/versioned-api/crud-api-version-1-strict.json b/test/versioned-api/crud-api-version-1-strict.json index c4ec4a0110..e0fab6c71e 100644 --- a/test/versioned-api/crud-api-version-1-strict.json +++ b/test/versioned-api/crud-api-version-1-strict.json @@ -112,7 +112,7 @@ { "commandStartedEvent": { "command": { - "aggregate": "test", + "aggregate": "coll", "pipeline": [ { "$sort": { @@ -278,7 +278,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 6, @@ -296,7 +296,7 @@ { "commandStartedEvent": { "command": { - "update": "test", + "update": "coll", "updates": [ { "q": { @@ -326,7 +326,7 @@ { "commandStartedEvent": { "command": { - "delete": "test", + "delete": "coll", "deletes": [ { "q": { @@ -351,7 +351,7 @@ { "commandStartedEvent": { "command": { - "update": "test", + "update": "coll", "updates": [ { "q": { @@ -381,7 +381,7 @@ { "commandStartedEvent": { "command": { - "delete": "test", + "delete": "coll", "deletes": [ { "q": { @@ -401,7 +401,7 @@ { "commandStartedEvent": { "command": { - "update": "test", + "update": "coll", "updates": [ { "q": { @@ -451,7 +451,7 @@ { "commandStartedEvent": { "command": { - "aggregate": "test", + "aggregate": "coll", "pipeline": [ { "$match": { @@ -506,7 +506,7 @@ { "commandStartedEvent": { "command": { - "delete": "test", + "delete": "coll", "deletes": [ { "q": { @@ -552,7 +552,7 @@ { "commandStartedEvent": { "command": { - "delete": "test", + "delete": "coll", "deletes": [ { "q": { @@ -693,7 +693,7 @@ { "commandStartedEvent": { "command": { - "find": "test", + "find": "coll", "apiVersion": "1", "apiStrict": true, "apiDeprecationErrors": { @@ -875,7 +875,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 6, @@ -919,7 +919,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 6, @@ -963,7 +963,7 @@ { "commandStartedEvent": { "command": { - "update": "test", + "update": "coll", "updates": [ { "q": { @@ -1018,7 +1018,7 @@ { "commandStartedEvent": { "command": { - "update": "test", + "update": "coll", "updates": [ { "q": { @@ -1074,7 +1074,7 @@ { "commandStartedEvent": { "command": { - "update": "test", + "update": "coll", "updates": [ { "q": { diff --git a/test/versioned-api/crud-api-version-1.json b/test/versioned-api/crud-api-version-1.json index 00f987c5c8..03aa9a2002 100644 --- a/test/versioned-api/crud-api-version-1.json +++ b/test/versioned-api/crud-api-version-1.json @@ -113,7 +113,7 @@ { "commandStartedEvent": { "command": { - "aggregate": "test", + "aggregate": "coll", "pipeline": [ { "$sort": { @@ -276,7 +276,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 6, @@ -294,7 +294,7 @@ { "commandStartedEvent": { "command": { - "update": "test", + "update": "coll", "updates": [ { "q": { @@ -324,7 +324,7 @@ { "commandStartedEvent": { "command": { - "delete": "test", + "delete": "coll", "deletes": [ { "q": { @@ -349,7 +349,7 @@ { "commandStartedEvent": { "command": { - "update": "test", + "update": "coll", "updates": [ { "q": { @@ -379,7 +379,7 @@ { "commandStartedEvent": { "command": { - "delete": "test", + "delete": "coll", "deletes": [ { "q": { @@ -399,7 +399,7 @@ { "commandStartedEvent": { "command": { - "update": "test", + "update": "coll", "updates": [ { "q": { @@ -529,7 +529,7 @@ { "commandStartedEvent": { "command": { - "aggregate": "test", + "aggregate": "coll", "pipeline": [ { "$match": { @@ -584,7 +584,7 @@ { "commandStartedEvent": { "command": { - "delete": "test", + "delete": "coll", "deletes": [ { "q": { @@ -630,7 +630,7 @@ { "commandStartedEvent": { "command": { - "delete": "test", + "delete": "coll", "deletes": [ { "q": { @@ -766,7 +766,7 @@ { "commandStartedEvent": { "command": { - "find": "test", + "find": "coll", "apiVersion": "1", "apiStrict": { "$$unsetOrMatches": false @@ -948,7 +948,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 6, @@ -992,7 +992,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 6, @@ -1036,7 +1036,7 @@ { "commandStartedEvent": { "command": { - "update": "test", + "update": "coll", "updates": [ { "q": { @@ -1091,7 +1091,7 @@ { "commandStartedEvent": { "command": { - "update": "test", + "update": "coll", "updates": [ { "q": { @@ -1147,7 +1147,7 @@ { "commandStartedEvent": { "command": { - "update": "test", + "update": "coll", "updates": [ { "q": { From ec8dd0fff6077931bda40d507c9b5d0765835d43 Mon Sep 17 00:00:00 2001 From: Sophia Yang Date: Fri, 12 Jun 2026 16:54:12 -0400 Subject: [PATCH 5/9] fix --- test/asynchronous/test_raw_bson.py | 4 +-- test/asynchronous/test_session.py | 4 +-- .../driver-sessions-dirty-session-errors.json | 30 +++++++++---------- .../driver-sessions-server-support.json | 8 ++--- test/test_raw_bson.py | 4 +-- test/test_session.py | 4 +-- .../valid-pass/poc-sessions.json | 16 +++++----- test/versioned-api/transaction-handling.json | 8 ++--- 8 files changed, 39 insertions(+), 39 deletions(-) diff --git a/test/asynchronous/test_raw_bson.py b/test/asynchronous/test_raw_bson.py index ce9a2608d0..99b1ac7163 100644 --- a/test/asynchronous/test_raw_bson.py +++ b/test/asynchronous/test_raw_bson.py @@ -44,7 +44,7 @@ class TestRawBSONDocument(AsyncIntegrationTest): async def asyncTearDown(self): if async_client_context.connected: - await self.db.coll.drop() + await self.client.db.coll.drop() def test_decode(self): self.assertEqual("Sherlock", self.document["name"]) @@ -170,7 +170,7 @@ async def test_raw_bson_document_embedded(self): await db.coll.drop() await db.coll.insert_one(rbd) result = await db.get_collection( - "test_raw", codec_options=CodecOptions(uuid_representation=JAVA_LEGACY) + "coll", codec_options=CodecOptions(uuid_representation=JAVA_LEGACY) ).find_one() assert result is not None self.assertEqual(rbd["embedded"][0]["_id"], result["embedded"][0]["_id"]) diff --git a/test/asynchronous/test_session.py b/test/asynchronous/test_session.py index 24a6fe42b6..2390aaa260 100644 --- a/test/asynchronous/test_session.py +++ b/test/asynchronous/test_session.py @@ -398,7 +398,7 @@ async def test_collection(self): coll = client.db.coll # Test some collection methods - the rest are in test_cursor. - ops = self.collection_write_ops(coll) + ops = self.test_write_ops(coll) ops.extend( [ (coll.distinct, ["a"], {}), @@ -836,7 +836,7 @@ async def test_unacknowledged_writes(self): (db.create_collection, ["coll"], {}), (db.drop_collection, ["coll"], {}), ] - ops.extend(self.collection_write_ops(coll)) + ops.extend(self.test_write_ops(coll)) await self._test_unacknowledged_ops(client, *ops) async def drop_db(): diff --git a/test/sessions/driver-sessions-dirty-session-errors.json b/test/sessions/driver-sessions-dirty-session-errors.json index 5fbe1fe98d..4dc5703531 100644 --- a/test/sessions/driver-sessions-dirty-session-errors.json +++ b/test/sessions/driver-sessions-dirty-session-errors.json @@ -164,7 +164,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 2 @@ -183,7 +183,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 2 @@ -202,7 +202,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 3 @@ -221,7 +221,7 @@ { "commandStartedEvent": { "command": { - "find": "test", + "find": "coll", "filter": { "_id": -1 }, @@ -398,7 +398,7 @@ { "commandStartedEvent": { "command": { - "find": "test", + "find": "coll", "filter": { "_id": -1 }, @@ -489,7 +489,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 2 @@ -508,7 +508,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 2 @@ -527,7 +527,7 @@ { "commandStartedEvent": { "command": { - "find": "test", + "find": "coll", "filter": { "_id": -1 }, @@ -682,7 +682,7 @@ { "commandStartedEvent": { "command": { - "find": "test", + "find": "coll", "filter": { "_id": -1 }, @@ -775,7 +775,7 @@ { "commandStartedEvent": { "command": { - "aggregate": "test", + "aggregate": "coll", "pipeline": [ { "$project": { @@ -794,7 +794,7 @@ { "commandStartedEvent": { "command": { - "aggregate": "test", + "aggregate": "coll", "pipeline": [ { "$project": { @@ -813,7 +813,7 @@ { "commandStartedEvent": { "command": { - "find": "test", + "find": "coll", "filter": { "_id": -1 }, @@ -895,7 +895,7 @@ { "commandStartedEvent": { "command": { - "aggregate": "test", + "aggregate": "coll", "pipeline": [ { "$match": {} @@ -920,7 +920,7 @@ { "commandStartedEvent": { "command": { - "aggregate": "test", + "aggregate": "coll", "pipeline": [ { "$match": {} @@ -945,7 +945,7 @@ { "commandStartedEvent": { "command": { - "find": "test", + "find": "coll", "filter": { "_id": -1 }, diff --git a/test/sessions/driver-sessions-server-support.json b/test/sessions/driver-sessions-server-support.json index 43a39958b8..0a4c13adb9 100644 --- a/test/sessions/driver-sessions-server-support.json +++ b/test/sessions/driver-sessions-server-support.json @@ -112,7 +112,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 2 @@ -130,7 +130,7 @@ { "commandStartedEvent": { "command": { - "find": "test", + "find": "coll", "filter": { "_id": -1 }, @@ -204,7 +204,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 2 @@ -222,7 +222,7 @@ { "commandStartedEvent": { "command": { - "find": "test", + "find": "coll", "filter": { "_id": -1 }, diff --git a/test/test_raw_bson.py b/test/test_raw_bson.py index fb0f771620..d37d714595 100644 --- a/test/test_raw_bson.py +++ b/test/test_raw_bson.py @@ -44,7 +44,7 @@ class TestRawBSONDocument(IntegrationTest): def tearDown(self): if client_context.connected: - self.db.coll.drop() + self.client.db.coll.drop() def test_decode(self): self.assertEqual("Sherlock", self.document["name"]) @@ -170,7 +170,7 @@ def test_raw_bson_document_embedded(self): db.coll.drop() db.coll.insert_one(rbd) result = db.get_collection( - "test_raw", codec_options=CodecOptions(uuid_representation=JAVA_LEGACY) + "coll", codec_options=CodecOptions(uuid_representation=JAVA_LEGACY) ).find_one() assert result is not None self.assertEqual(rbd["embedded"][0]["_id"], result["embedded"][0]["_id"]) diff --git a/test/test_session.py b/test/test_session.py index 0f2dde76b7..f6b8658267 100644 --- a/test/test_session.py +++ b/test/test_session.py @@ -398,7 +398,7 @@ def test_collection(self): coll = client.db.coll # Test some collection methods - the rest are in test_cursor. - ops = self.collection_write_ops(coll) + ops = self.test_write_ops(coll) ops.extend( [ (coll.distinct, ["a"], {}), @@ -836,7 +836,7 @@ def test_unacknowledged_writes(self): (db.create_collection, ["coll"], {}), (db.drop_collection, ["coll"], {}), ] - ops.extend(self.collection_write_ops(coll)) + ops.extend(self.test_write_ops(coll)) self._test_unacknowledged_ops(client, *ops) def drop_db(): diff --git a/test/unified-test-format/valid-pass/poc-sessions.json b/test/unified-test-format/valid-pass/poc-sessions.json index 6855860213..b6042a10c6 100644 --- a/test/unified-test-format/valid-pass/poc-sessions.json +++ b/test/unified-test-format/valid-pass/poc-sessions.json @@ -112,7 +112,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 2 @@ -130,7 +130,7 @@ { "commandStartedEvent": { "command": { - "find": "test", + "find": "coll", "filter": { "_id": -1 }, @@ -204,7 +204,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 2 @@ -222,7 +222,7 @@ { "commandStartedEvent": { "command": { - "find": "test", + "find": "coll", "filter": { "_id": -1 }, @@ -372,7 +372,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 2 @@ -391,7 +391,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 2 @@ -410,7 +410,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 3 @@ -429,7 +429,7 @@ { "commandStartedEvent": { "command": { - "find": "test", + "find": "coll", "filter": { "_id": -1 }, diff --git a/test/versioned-api/transaction-handling.json b/test/versioned-api/transaction-handling.json index 78a4fff47c..c88424edd3 100644 --- a/test/versioned-api/transaction-handling.json +++ b/test/versioned-api/transaction-handling.json @@ -150,7 +150,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 6, @@ -174,7 +174,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 7, @@ -279,7 +279,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 6, @@ -303,7 +303,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 7, From ebec7df7413e18a611485b074eb320f7b1a78ecd Mon Sep 17 00:00:00 2001 From: Sophia Yang Date: Fri, 12 Jun 2026 17:07:42 -0400 Subject: [PATCH 6/9] fix fix --- test/asynchronous/test_monitoring.py | 2 +- test/asynchronous/test_raw_bson.py | 1 + test/asynchronous/test_session.py | 2 +- .../change-streams-pre_and_post_images.json | 20 +++++----- test/test_monitoring.py | 2 +- test/test_raw_bson.py | 1 + test/test_session.py | 2 +- .../unified/callback-aborts.json | 6 +-- .../unified/callback-commits.json | 10 ++--- .../unified/callback-retry.json | 10 ++--- .../unified/commit-retry-errorLabels.json | 2 +- .../unified/commit-retry.json | 6 +-- .../commit-transienttransactionerror-4.2.json | 6 +-- .../commit-transienttransactionerror.json | 24 +++++------ .../unified/commit-writeconcernerror.json | 10 ++--- .../unified/commit.json | 8 ++-- .../unified/transaction-options.json | 12 +++--- test/transactions/unified/abort.json | 16 ++++---- .../unified/backpressure-retryable-abort.json | 4 +- .../backpressure-retryable-commit.json | 4 +- .../unified/backpressure-retryable-reads.json | 6 +-- .../backpressure-retryable-writes.json | 6 +-- test/transactions/unified/bulk.json | 18 ++++----- .../unified/causal-consistency.json | 8 ++-- test/transactions/unified/commit.json | 22 +++++----- test/transactions/unified/create-index.json | 6 +-- .../unified/error-labels-blockConnection.json | 2 +- .../unified/error-labels-errorLabels.json | 4 +- test/transactions/unified/error-labels.json | 36 ++++++++--------- test/transactions/unified/insert.json | 20 +++++----- .../transactions/unified/mongos-pin-auto.json | 14 +++---- .../mongos-recovery-token-errorLabels.json | 2 +- .../unified/mongos-recovery-token.json | 6 +-- test/transactions/unified/pin-mongos.json | 8 ++-- test/transactions/unified/read-concern.json | 40 +++++++++---------- test/transactions/unified/reads.json | 10 ++--- .../unified/retryable-abort-errorLabels.json | 34 ++++++++-------- .../transactions/unified/retryable-abort.json | 8 ++-- .../unified/retryable-commit-errorLabels.json | 34 ++++++++-------- .../unified/retryable-commit.json | 10 ++--- .../unified/retryable-writes.json | 10 ++--- test/transactions/unified/run-command.json | 16 ++++---- .../unified/transaction-options-repl.json | 4 +- test/transactions/unified/update.json | 12 +++--- .../valid-pass/poc-change-streams.json | 6 +-- .../valid-pass/poc-command-monitoring.json | 4 +- .../poc-transactions-convenient-api.json | 8 ++-- .../poc-transactions-mongos-pin-auto.json | 8 ++-- 48 files changed, 256 insertions(+), 254 deletions(-) diff --git a/test/asynchronous/test_monitoring.py b/test/asynchronous/test_monitoring.py index bcc5955861..af4298c7a9 100644 --- a/test/asynchronous/test_monitoring.py +++ b/test/asynchronous/test_monitoring.py @@ -312,7 +312,7 @@ async def test_command_and_get_more(self): self.assertEqualCommand( SON( [ - ("aggregate", "test"), + ("aggregate", "coll"), ("pipeline", [{"$project": {"_id": False, "x": 1}}]), ("cursor", {"batchSize": 4}), ] diff --git a/test/asynchronous/test_raw_bson.py b/test/asynchronous/test_raw_bson.py index 99b1ac7163..c31a7b82c3 100644 --- a/test/asynchronous/test_raw_bson.py +++ b/test/asynchronous/test_raw_bson.py @@ -45,6 +45,7 @@ class TestRawBSONDocument(AsyncIntegrationTest): async def asyncTearDown(self): if async_client_context.connected: await self.client.db.coll.drop() + await self.client.db.test_raw.drop() def test_decode(self): self.assertEqual("Sherlock", self.document["name"]) diff --git a/test/asynchronous/test_session.py b/test/asynchronous/test_session.py index 2390aaa260..15b6129ea2 100644 --- a/test/asynchronous/test_session.py +++ b/test/asynchronous/test_session.py @@ -359,7 +359,7 @@ async def test_database(self): db = client.db ops: list = [ (db.command, ["ping"], {}), - (db.create_coll, ["collection"], {}), + (db.create_collection, ["coll"], {}), (db.list_collection_names, [], {}), (db.validate_collection, ["coll"], {}), (db.drop_collection, ["coll"], {}), diff --git a/test/change_streams/unified/change-streams-pre_and_post_images.json b/test/change_streams/unified/change-streams-pre_and_post_images.json index 216205c804..0a9db14d6d 100644 --- a/test/change_streams/unified/change-streams-pre_and_post_images.json +++ b/test/change_streams/unified/change-streams-pre_and_post_images.json @@ -120,7 +120,7 @@ { "commandStartedEvent": { "command": { - "aggregate": "test", + "aggregate": "coll", "pipeline": [ { "$changeStream": { @@ -197,7 +197,7 @@ { "commandStartedEvent": { "command": { - "aggregate": "test", + "aggregate": "coll", "pipeline": [ { "$changeStream": { @@ -277,7 +277,7 @@ { "commandStartedEvent": { "command": { - "aggregate": "test", + "aggregate": "coll", "pipeline": [ { "$changeStream": { @@ -346,7 +346,7 @@ { "commandStartedEvent": { "command": { - "aggregate": "test", + "aggregate": "coll", "pipeline": [ { "$changeStream": { @@ -425,7 +425,7 @@ { "commandStartedEvent": { "command": { - "aggregate": "test", + "aggregate": "coll", "pipeline": [ { "$changeStream": { @@ -502,7 +502,7 @@ { "commandStartedEvent": { "command": { - "aggregate": "test", + "aggregate": "coll", "pipeline": [ { "$changeStream": { @@ -581,7 +581,7 @@ { "commandStartedEvent": { "command": { - "aggregate": "test", + "aggregate": "coll", "pipeline": [ { "$changeStream": { @@ -650,7 +650,7 @@ { "commandStartedEvent": { "command": { - "aggregate": "test", + "aggregate": "coll", "pipeline": [ { "$changeStream": { @@ -729,7 +729,7 @@ { "commandStartedEvent": { "command": { - "aggregate": "test", + "aggregate": "coll", "pipeline": [ { "$changeStream": { @@ -808,7 +808,7 @@ { "commandStartedEvent": { "command": { - "aggregate": "test", + "aggregate": "coll", "pipeline": [ { "$changeStream": { diff --git a/test/test_monitoring.py b/test/test_monitoring.py index d81f71ae40..49c0f1d9ff 100644 --- a/test/test_monitoring.py +++ b/test/test_monitoring.py @@ -310,7 +310,7 @@ def test_command_and_get_more(self): self.assertEqualCommand( SON( [ - ("aggregate", "test"), + ("aggregate", "coll"), ("pipeline", [{"$project": {"_id": False, "x": 1}}]), ("cursor", {"batchSize": 4}), ] diff --git a/test/test_raw_bson.py b/test/test_raw_bson.py index d37d714595..1890df5ab8 100644 --- a/test/test_raw_bson.py +++ b/test/test_raw_bson.py @@ -45,6 +45,7 @@ class TestRawBSONDocument(IntegrationTest): def tearDown(self): if client_context.connected: self.client.db.coll.drop() + self.client.db.test_raw.drop() def test_decode(self): self.assertEqual("Sherlock", self.document["name"]) diff --git a/test/test_session.py b/test/test_session.py index f6b8658267..c9446bd845 100644 --- a/test/test_session.py +++ b/test/test_session.py @@ -359,7 +359,7 @@ def test_database(self): db = client.db ops: list = [ (db.command, ["ping"], {}), - (db.create_coll, ["collection"], {}), + (db.create_collection, ["coll"], {}), (db.list_collection_names, [], {}), (db.validate_collection, ["coll"], {}), (db.drop_collection, ["coll"], {}), diff --git a/test/transactions-convenient-api/unified/callback-aborts.json b/test/transactions-convenient-api/unified/callback-aborts.json index 6083061e30..71b26e1fb8 100644 --- a/test/transactions-convenient-api/unified/callback-aborts.json +++ b/test/transactions-convenient-api/unified/callback-aborts.json @@ -95,7 +95,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -244,7 +244,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -298,7 +298,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 2 diff --git a/test/transactions-convenient-api/unified/callback-commits.json b/test/transactions-convenient-api/unified/callback-commits.json index b6e6f6661b..3b28e0c64f 100644 --- a/test/transactions-convenient-api/unified/callback-commits.json +++ b/test/transactions-convenient-api/unified/callback-commits.json @@ -112,7 +112,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -141,7 +141,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 2 @@ -286,7 +286,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -315,7 +315,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 2 @@ -371,7 +371,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 3 diff --git a/test/transactions-convenient-api/unified/callback-retry.json b/test/transactions-convenient-api/unified/callback-retry.json index 1c6e34b4de..b418965926 100644 --- a/test/transactions-convenient-api/unified/callback-retry.json +++ b/test/transactions-convenient-api/unified/callback-retry.json @@ -138,7 +138,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -192,7 +192,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -248,7 +248,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -375,7 +375,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -404,7 +404,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 diff --git a/test/transactions-convenient-api/unified/commit-retry-errorLabels.json b/test/transactions-convenient-api/unified/commit-retry-errorLabels.json index c3e315ebf6..e6763209a4 100644 --- a/test/transactions-convenient-api/unified/commit-retry-errorLabels.json +++ b/test/transactions-convenient-api/unified/commit-retry-errorLabels.json @@ -109,7 +109,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 diff --git a/test/transactions-convenient-api/unified/commit-retry.json b/test/transactions-convenient-api/unified/commit-retry.json index 018a644c50..016bb4f662 100644 --- a/test/transactions-convenient-api/unified/commit-retry.json +++ b/test/transactions-convenient-api/unified/commit-retry.json @@ -115,7 +115,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -298,7 +298,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -485,7 +485,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 diff --git a/test/transactions-convenient-api/unified/commit-transienttransactionerror-4.2.json b/test/transactions-convenient-api/unified/commit-transienttransactionerror-4.2.json index 2da2a71047..aaa4f36fd3 100644 --- a/test/transactions-convenient-api/unified/commit-transienttransactionerror-4.2.json +++ b/test/transactions-convenient-api/unified/commit-transienttransactionerror-4.2.json @@ -112,7 +112,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -166,7 +166,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -222,7 +222,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 diff --git a/test/transactions-convenient-api/unified/commit-transienttransactionerror.json b/test/transactions-convenient-api/unified/commit-transienttransactionerror.json index cc642e2c83..fe282989ec 100644 --- a/test/transactions-convenient-api/unified/commit-transienttransactionerror.json +++ b/test/transactions-convenient-api/unified/commit-transienttransactionerror.json @@ -112,7 +112,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -166,7 +166,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -222,7 +222,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -346,7 +346,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -400,7 +400,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -456,7 +456,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -580,7 +580,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -634,7 +634,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -690,7 +690,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -814,7 +814,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -868,7 +868,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -924,7 +924,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 diff --git a/test/transactions-convenient-api/unified/commit-writeconcernerror.json b/test/transactions-convenient-api/unified/commit-writeconcernerror.json index 6bfbc7f0de..52f6b0b4c4 100644 --- a/test/transactions-convenient-api/unified/commit-writeconcernerror.json +++ b/test/transactions-convenient-api/unified/commit-writeconcernerror.json @@ -116,7 +116,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -292,7 +292,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -476,7 +476,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -608,7 +608,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -742,7 +742,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 diff --git a/test/transactions-convenient-api/unified/commit.json b/test/transactions-convenient-api/unified/commit.json index e4f6609001..bde2b35091 100644 --- a/test/transactions-convenient-api/unified/commit.json +++ b/test/transactions-convenient-api/unified/commit.json @@ -108,7 +108,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -137,7 +137,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 2 @@ -269,7 +269,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -323,7 +323,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 2 diff --git a/test/transactions-convenient-api/unified/transaction-options.json b/test/transactions-convenient-api/unified/transaction-options.json index 33341eadfe..c1259621d7 100644 --- a/test/transactions-convenient-api/unified/transaction-options.json +++ b/test/transactions-convenient-api/unified/transaction-options.json @@ -91,7 +91,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -234,7 +234,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -360,7 +360,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -468,7 +468,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -600,7 +600,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -749,7 +749,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 diff --git a/test/transactions/unified/abort.json b/test/transactions/unified/abort.json index 5cdfbf6936..96b84e61b5 100644 --- a/test/transactions/unified/abort.json +++ b/test/transactions/unified/abort.json @@ -116,7 +116,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -167,7 +167,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -264,7 +264,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -366,7 +366,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -526,7 +526,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -661,7 +661,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -690,7 +690,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -721,7 +721,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 diff --git a/test/transactions/unified/backpressure-retryable-abort.json b/test/transactions/unified/backpressure-retryable-abort.json index 9e6e26b924..ceede5fd98 100644 --- a/test/transactions/unified/backpressure-retryable-abort.json +++ b/test/transactions/unified/backpressure-retryable-abort.json @@ -109,7 +109,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -269,7 +269,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 diff --git a/test/transactions/unified/backpressure-retryable-commit.json b/test/transactions/unified/backpressure-retryable-commit.json index d1ff9b3f60..091f0cb7db 100644 --- a/test/transactions/unified/backpressure-retryable-commit.json +++ b/test/transactions/unified/backpressure-retryable-commit.json @@ -114,7 +114,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -286,7 +286,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 diff --git a/test/transactions/unified/backpressure-retryable-reads.json b/test/transactions/unified/backpressure-retryable-reads.json index 0afe8ea8cb..9eea696397 100644 --- a/test/transactions/unified/backpressure-retryable-reads.json +++ b/test/transactions/unified/backpressure-retryable-reads.json @@ -117,7 +117,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -146,7 +146,7 @@ { "commandStartedEvent": { "command": { - "find": "test", + "find": "coll", "readConcern": { "$$exists": false }, @@ -168,7 +168,7 @@ { "commandStartedEvent": { "command": { - "find": "test", + "find": "coll", "readConcern": { "$$exists": false }, diff --git a/test/transactions/unified/backpressure-retryable-writes.json b/test/transactions/unified/backpressure-retryable-writes.json index e0712e025a..4b1f81515a 100644 --- a/test/transactions/unified/backpressure-retryable-writes.json +++ b/test/transactions/unified/backpressure-retryable-writes.json @@ -119,7 +119,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -148,7 +148,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 2 @@ -176,7 +176,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 2 diff --git a/test/transactions/unified/bulk.json b/test/transactions/unified/bulk.json index 95a1756cfb..280ebbca3c 100644 --- a/test/transactions/unified/bulk.json +++ b/test/transactions/unified/bulk.json @@ -257,7 +257,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -286,7 +286,7 @@ { "commandStartedEvent": { "command": { - "delete": "test", + "delete": "coll", "deletes": [ { "q": { @@ -317,7 +317,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -345,7 +345,7 @@ { "commandStartedEvent": { "command": { - "update": "test", + "update": "coll", "updates": [ { "q": { @@ -400,7 +400,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 3 @@ -440,7 +440,7 @@ { "commandStartedEvent": { "command": { - "update": "test", + "update": "coll", "updates": [ { "q": { @@ -493,7 +493,7 @@ { "commandStartedEvent": { "command": { - "delete": "test", + "delete": "coll", "deletes": [ { "q": { @@ -530,7 +530,7 @@ { "commandStartedEvent": { "command": { - "update": "test", + "update": "coll", "updates": [ { "q": { @@ -571,7 +571,7 @@ { "commandStartedEvent": { "command": { - "delete": "test", + "delete": "coll", "deletes": [ { "q": { diff --git a/test/transactions/unified/causal-consistency.json b/test/transactions/unified/causal-consistency.json index 8de044d3cf..ccce759f0e 100644 --- a/test/transactions/unified/causal-consistency.json +++ b/test/transactions/unified/causal-consistency.json @@ -131,7 +131,7 @@ { "commandStartedEvent": { "command": { - "update": "test", + "update": "coll", "updates": [ { "q": { @@ -177,7 +177,7 @@ { "commandStartedEvent": { "command": { - "update": "test", + "update": "coll", "updates": [ { "q": { @@ -312,7 +312,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 2 @@ -342,7 +342,7 @@ { "commandStartedEvent": { "command": { - "update": "test", + "update": "coll", "updates": [ { "q": { diff --git a/test/transactions/unified/commit.json b/test/transactions/unified/commit.json index 0cfca0bdc3..a67cd758bd 100644 --- a/test/transactions/unified/commit.json +++ b/test/transactions/unified/commit.json @@ -148,7 +148,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -199,7 +199,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 2 @@ -315,7 +315,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -422,7 +422,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -684,7 +684,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -809,7 +809,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -860,7 +860,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -981,7 +981,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -1032,7 +1032,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 2 @@ -1139,7 +1139,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -1190,7 +1190,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 2 diff --git a/test/transactions/unified/create-index.json b/test/transactions/unified/create-index.json index f129d34b19..98e02aca1b 100644 --- a/test/transactions/unified/create-index.json +++ b/test/transactions/unified/create-index.json @@ -105,7 +105,7 @@ { "commandStartedEvent": { "command": { - "drop": "test", + "drop": "coll", "writeConcern": { "$$exists": false } @@ -231,7 +231,7 @@ { "commandStartedEvent": { "command": { - "drop": "test", + "drop": "coll", "writeConcern": { "$$exists": false } @@ -243,7 +243,7 @@ { "commandStartedEvent": { "command": { - "create": "test", + "create": "coll", "lsid": { "$$sessionLsid": "session0" }, diff --git a/test/transactions/unified/error-labels-blockConnection.json b/test/transactions/unified/error-labels-blockConnection.json index 0e92a50d4b..a552df1047 100644 --- a/test/transactions/unified/error-labels-blockConnection.json +++ b/test/transactions/unified/error-labels-blockConnection.json @@ -122,7 +122,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 diff --git a/test/transactions/unified/error-labels-errorLabels.json b/test/transactions/unified/error-labels-errorLabels.json index 3daa9fa09b..ce955d87f1 100644 --- a/test/transactions/unified/error-labels-errorLabels.json +++ b/test/transactions/unified/error-labels-errorLabels.json @@ -122,7 +122,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -310,7 +310,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 diff --git a/test/transactions/unified/error-labels.json b/test/transactions/unified/error-labels.json index b37ad2e60b..c7edbc1ef1 100644 --- a/test/transactions/unified/error-labels.json +++ b/test/transactions/unified/error-labels.json @@ -97,7 +97,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -216,7 +216,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -332,7 +332,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -448,7 +448,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -571,7 +571,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -748,7 +748,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -777,7 +777,7 @@ { "commandStartedEvent": { "command": { - "find": "test", + "find": "coll", "readConcern": { "$$exists": false }, @@ -799,7 +799,7 @@ { "commandStartedEvent": { "command": { - "aggregate": "test", + "aggregate": "coll", "pipeline": [ { "$project": { @@ -950,7 +950,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -1122,7 +1122,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -1251,7 +1251,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -1416,7 +1416,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -1572,7 +1572,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -1705,7 +1705,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -1845,7 +1845,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -1874,7 +1874,7 @@ { "commandStartedEvent": { "command": { - "aggregate": "test", + "aggregate": "coll", "pipeline": [ { "$project": { @@ -2006,7 +2006,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -2171,7 +2171,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 diff --git a/test/transactions/unified/insert.json b/test/transactions/unified/insert.json index 5afdc95cd6..12b8fcaadd 100644 --- a/test/transactions/unified/insert.json +++ b/test/transactions/unified/insert.json @@ -164,7 +164,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -193,7 +193,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 2 @@ -224,7 +224,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 4 @@ -271,7 +271,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 5 @@ -434,7 +434,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -463,7 +463,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 2 @@ -516,7 +516,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 4 @@ -660,7 +660,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -791,7 +791,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -820,7 +820,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 2 diff --git a/test/transactions/unified/mongos-pin-auto.json b/test/transactions/unified/mongos-pin-auto.json index 453284a269..6c21dd51bd 100644 --- a/test/transactions/unified/mongos-pin-auto.json +++ b/test/transactions/unified/mongos-pin-auto.json @@ -135,7 +135,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 3 @@ -164,7 +164,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 4 @@ -318,7 +318,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 3 @@ -347,7 +347,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 4 @@ -1963,7 +1963,7 @@ "session": "session0", "commandName": "insert", "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -5142,7 +5142,7 @@ "session": "session0", "commandName": "insert", "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -5233,7 +5233,7 @@ "session": "session0", "commandName": "insert", "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 diff --git a/test/transactions/unified/mongos-recovery-token-errorLabels.json b/test/transactions/unified/mongos-recovery-token-errorLabels.json index 0814d281c2..0e2a090fea 100644 --- a/test/transactions/unified/mongos-recovery-token-errorLabels.json +++ b/test/transactions/unified/mongos-recovery-token-errorLabels.json @@ -115,7 +115,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 diff --git a/test/transactions/unified/mongos-recovery-token.json b/test/transactions/unified/mongos-recovery-token.json index 3e80457753..0ce95148c7 100644 --- a/test/transactions/unified/mongos-recovery-token.json +++ b/test/transactions/unified/mongos-recovery-token.json @@ -94,7 +94,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -327,7 +327,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -477,7 +477,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 diff --git a/test/transactions/unified/pin-mongos.json b/test/transactions/unified/pin-mongos.json index 3a8b22eb68..74d1ea73d2 100644 --- a/test/transactions/unified/pin-mongos.json +++ b/test/transactions/unified/pin-mongos.json @@ -1129,7 +1129,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 3 @@ -1158,7 +1158,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 4 @@ -1362,7 +1362,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 3 @@ -1391,7 +1391,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 4 diff --git a/test/transactions/unified/read-concern.json b/test/transactions/unified/read-concern.json index c9166b291d..adb89d23f3 100644 --- a/test/transactions/unified/read-concern.json +++ b/test/transactions/unified/read-concern.json @@ -135,7 +135,7 @@ { "commandStartedEvent": { "command": { - "aggregate": "test", + "aggregate": "coll", "pipeline": [ { "$match": { @@ -173,7 +173,7 @@ { "commandStartedEvent": { "command": { - "aggregate": "test", + "aggregate": "coll", "pipeline": [ { "$match": { @@ -329,7 +329,7 @@ { "commandStartedEvent": { "command": { - "find": "test", + "find": "coll", "batchSize": 3, "lsid": { "$$sessionLsid": "session0" @@ -379,7 +379,7 @@ { "commandStartedEvent": { "command": { - "find": "test", + "find": "coll", "batchSize": 3, "lsid": { "$$sessionLsid": "session0" @@ -559,7 +559,7 @@ { "commandStartedEvent": { "command": { - "aggregate": "test", + "aggregate": "coll", "pipeline": [ { "$project": { @@ -618,7 +618,7 @@ { "commandStartedEvent": { "command": { - "aggregate": "test", + "aggregate": "coll", "pipeline": [ { "$project": { @@ -893,7 +893,7 @@ "arguments": { "session": "session0", "command": { - "find": "test" + "find": "coll" }, "commandName": "find" } @@ -904,7 +904,7 @@ "arguments": { "session": "session0", "command": { - "find": "test" + "find": "coll" }, "commandName": "find" } @@ -921,7 +921,7 @@ { "commandStartedEvent": { "command": { - "find": "test", + "find": "coll", "lsid": { "$$sessionLsid": "session0" }, @@ -944,7 +944,7 @@ { "commandStartedEvent": { "command": { - "find": "test", + "find": "coll", "lsid": { "$$sessionLsid": "session0" }, @@ -1060,7 +1060,7 @@ { "commandStartedEvent": { "command": { - "aggregate": "test", + "aggregate": "coll", "pipeline": [ { "$match": { @@ -1098,7 +1098,7 @@ { "commandStartedEvent": { "command": { - "aggregate": "test", + "aggregate": "coll", "pipeline": [ { "$match": { @@ -1249,7 +1249,7 @@ { "commandStartedEvent": { "command": { - "find": "test", + "find": "coll", "batchSize": 3, "lsid": { "$$sessionLsid": "session0" @@ -1299,7 +1299,7 @@ { "commandStartedEvent": { "command": { - "find": "test", + "find": "coll", "batchSize": 3, "lsid": { "$$sessionLsid": "session0" @@ -1474,7 +1474,7 @@ { "commandStartedEvent": { "command": { - "aggregate": "test", + "aggregate": "coll", "pipeline": [ { "$project": { @@ -1533,7 +1533,7 @@ { "commandStartedEvent": { "command": { - "aggregate": "test", + "aggregate": "coll", "pipeline": [ { "$project": { @@ -1798,7 +1798,7 @@ "arguments": { "session": "session0", "command": { - "find": "test" + "find": "coll" }, "commandName": "find" } @@ -1809,7 +1809,7 @@ "arguments": { "session": "session0", "command": { - "find": "test" + "find": "coll" }, "commandName": "find" } @@ -1826,7 +1826,7 @@ { "commandStartedEvent": { "command": { - "find": "test", + "find": "coll", "lsid": { "$$sessionLsid": "session0" }, @@ -1849,7 +1849,7 @@ { "commandStartedEvent": { "command": { - "find": "test", + "find": "coll", "lsid": { "$$sessionLsid": "session0" }, diff --git a/test/transactions/unified/reads.json b/test/transactions/unified/reads.json index d7cbf11b7e..6fe49f3c75 100644 --- a/test/transactions/unified/reads.json +++ b/test/transactions/unified/reads.json @@ -121,7 +121,7 @@ { "commandStartedEvent": { "command": { - "find": "test", + "find": "coll", "readConcern": { "level": "majority" }, @@ -231,7 +231,7 @@ { "commandStartedEvent": { "command": { - "find": "test", + "find": "coll", "batchSize": 3, "readConcern": { "$$exists": false @@ -278,7 +278,7 @@ { "commandStartedEvent": { "command": { - "find": "test", + "find": "coll", "batchSize": 3, "lsid": { "$$sessionLsid": "session0" @@ -444,7 +444,7 @@ { "commandStartedEvent": { "command": { - "aggregate": "test", + "aggregate": "coll", "pipeline": [ { "$project": { @@ -500,7 +500,7 @@ { "commandStartedEvent": { "command": { - "aggregate": "test", + "aggregate": "coll", "pipeline": [ { "$project": { diff --git a/test/transactions/unified/retryable-abort-errorLabels.json b/test/transactions/unified/retryable-abort-errorLabels.json index 5d0451f417..1ee428fb4e 100644 --- a/test/transactions/unified/retryable-abort-errorLabels.json +++ b/test/transactions/unified/retryable-abort-errorLabels.json @@ -108,7 +108,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -245,7 +245,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -363,7 +363,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -503,7 +503,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -643,7 +643,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -783,7 +783,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -923,7 +923,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -1063,7 +1063,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -1203,7 +1203,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -1343,7 +1343,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -1483,7 +1483,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -1623,7 +1623,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -1763,7 +1763,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -1910,7 +1910,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -2057,7 +2057,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -2204,7 +2204,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -2351,7 +2351,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 diff --git a/test/transactions/unified/retryable-abort.json b/test/transactions/unified/retryable-abort.json index 91066ff099..817db0505a 100644 --- a/test/transactions/unified/retryable-abort.json +++ b/test/transactions/unified/retryable-abort.json @@ -142,7 +142,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -279,7 +279,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -401,7 +401,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -515,7 +515,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 diff --git a/test/transactions/unified/retryable-commit-errorLabels.json b/test/transactions/unified/retryable-commit-errorLabels.json index 6bfa7e70ed..71fba6fbe9 100644 --- a/test/transactions/unified/retryable-commit-errorLabels.json +++ b/test/transactions/unified/retryable-commit-errorLabels.json @@ -144,7 +144,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -261,7 +261,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -406,7 +406,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -551,7 +551,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -696,7 +696,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -841,7 +841,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -986,7 +986,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -1131,7 +1131,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -1276,7 +1276,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -1421,7 +1421,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -1566,7 +1566,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -1718,7 +1718,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -1870,7 +1870,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -2022,7 +2022,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -2174,7 +2174,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -2324,7 +2324,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -2474,7 +2474,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 diff --git a/test/transactions/unified/retryable-commit.json b/test/transactions/unified/retryable-commit.json index e1cf71f3ab..e0475c6e22 100644 --- a/test/transactions/unified/retryable-commit.json +++ b/test/transactions/unified/retryable-commit.json @@ -151,7 +151,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -280,7 +280,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -416,7 +416,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -605,7 +605,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -778,7 +778,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 diff --git a/test/transactions/unified/retryable-writes.json b/test/transactions/unified/retryable-writes.json index 04e45fd08b..f77677f654 100644 --- a/test/transactions/unified/retryable-writes.json +++ b/test/transactions/unified/retryable-writes.json @@ -158,7 +158,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -209,7 +209,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 2 @@ -244,7 +244,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 3 @@ -297,7 +297,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 4 @@ -409,7 +409,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 diff --git a/test/transactions/unified/run-command.json b/test/transactions/unified/run-command.json index 3a84f31d61..dd2d5eea0c 100644 --- a/test/transactions/unified/run-command.json +++ b/test/transactions/unified/run-command.json @@ -68,7 +68,7 @@ "arguments": { "session": "session0", "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -93,7 +93,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -195,7 +195,7 @@ "arguments": { "session": "session1", "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -220,7 +220,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -284,7 +284,7 @@ "arguments": { "session": "session0", "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -312,7 +312,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -376,7 +376,7 @@ "arguments": { "session": "session0", "command": { - "find": "test" + "find": "coll" }, "readPreference": { "mode": "secondary" @@ -407,7 +407,7 @@ "arguments": { "session": "session0", "command": { - "find": "test" + "find": "coll" }, "commandName": "find" }, diff --git a/test/transactions/unified/transaction-options-repl.json b/test/transactions/unified/transaction-options-repl.json index b33d0ce0cc..1b1b54d596 100644 --- a/test/transactions/unified/transaction-options-repl.json +++ b/test/transactions/unified/transaction-options-repl.json @@ -140,7 +140,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -194,7 +194,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 2 diff --git a/test/transactions/unified/update.json b/test/transactions/unified/update.json index 9975d07cc8..f364bf095e 100644 --- a/test/transactions/unified/update.json +++ b/test/transactions/unified/update.json @@ -146,7 +146,7 @@ { "commandStartedEvent": { "command": { - "update": "test", + "update": "coll", "updates": [ { "q": { @@ -186,7 +186,7 @@ { "commandStartedEvent": { "command": { - "update": "test", + "update": "coll", "updates": [ { "q": { @@ -225,7 +225,7 @@ { "commandStartedEvent": { "command": { - "update": "test", + "update": "coll", "updates": [ { "q": { @@ -418,7 +418,7 @@ { "commandStartedEvent": { "command": { - "update": "test", + "update": "coll", "updates": [ { "q": { @@ -458,7 +458,7 @@ { "commandStartedEvent": { "command": { - "update": "test", + "update": "coll", "updates": [ { "q": { @@ -497,7 +497,7 @@ { "commandStartedEvent": { "command": { - "update": "test", + "update": "coll", "updates": [ { "q": { diff --git a/test/unified-test-format/valid-pass/poc-change-streams.json b/test/unified-test-format/valid-pass/poc-change-streams.json index adac2d3262..fee7270978 100644 --- a/test/unified-test-format/valid-pass/poc-change-streams.json +++ b/test/unified-test-format/valid-pass/poc-change-streams.json @@ -381,7 +381,7 @@ { "commandStartedEvent": { "command": { - "aggregate": "test", + "aggregate": "coll", "cursor": { "batchSize": 1 }, @@ -402,7 +402,7 @@ { "commandStartedEvent": { "command": { - "aggregate": "test", + "aggregate": "coll", "cursor": { "batchSize": 1 }, @@ -426,7 +426,7 @@ { "commandStartedEvent": { "command": { - "aggregate": "test", + "aggregate": "coll", "cursor": { "batchSize": 1 }, diff --git a/test/unified-test-format/valid-pass/poc-command-monitoring.json b/test/unified-test-format/valid-pass/poc-command-monitoring.json index f201abd517..5f23c79993 100644 --- a/test/unified-test-format/valid-pass/poc-command-monitoring.json +++ b/test/unified-test-format/valid-pass/poc-command-monitoring.json @@ -93,7 +93,7 @@ { "commandStartedEvent": { "command": { - "find": "test", + "find": "coll", "filter": { "_id": { "$gte": 1 @@ -201,7 +201,7 @@ { "commandStartedEvent": { "command": { - "find": "test", + "find": "coll", "filter": { "$or": true } diff --git a/test/unified-test-format/valid-pass/poc-transactions-convenient-api.json b/test/unified-test-format/valid-pass/poc-transactions-convenient-api.json index 0716ec2364..923e133171 100644 --- a/test/unified-test-format/valid-pass/poc-transactions-convenient-api.json +++ b/test/unified-test-format/valid-pass/poc-transactions-convenient-api.json @@ -139,7 +139,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -237,7 +237,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -335,7 +335,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 @@ -439,7 +439,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 1 diff --git a/test/unified-test-format/valid-pass/poc-transactions-mongos-pin-auto.json b/test/unified-test-format/valid-pass/poc-transactions-mongos-pin-auto.json index 3c39210754..330b72d2e8 100644 --- a/test/unified-test-format/valid-pass/poc-transactions-mongos-pin-auto.json +++ b/test/unified-test-format/valid-pass/poc-transactions-mongos-pin-auto.json @@ -134,7 +134,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 3 @@ -161,7 +161,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 4 @@ -311,7 +311,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 3 @@ -338,7 +338,7 @@ { "commandStartedEvent": { "command": { - "insert": "test", + "insert": "coll", "documents": [ { "_id": 4 From 3e6510f78392ebc2d95f804b4ef15fb910665117 Mon Sep 17 00:00:00 2001 From: Sophia Yang Date: Fri, 12 Jun 2026 17:17:07 -0400 Subject: [PATCH 7/9] test test test --- test/asynchronous/test_collection.py | 2 +- test/asynchronous/test_cursor.py | 2 +- test/asynchronous/test_database.py | 38 +++++++++---------- .../causal-consistency-write-commands.json | 6 +-- .../unified/findOneAndUpdate-pipeline.json | 2 +- .../driver-sessions-dirty-session-errors.json | 8 ++-- test/test_collection.py | 2 +- test/test_cursor.py | 2 +- test/test_database.py | 38 +++++++++---------- test/transactions/unified/error-labels.json | 2 +- .../unified/findOneAndDelete.json | 6 +-- .../unified/findOneAndReplace.json | 6 +-- .../unified/findOneAndUpdate.json | 10 ++--- test/transactions/unified/read-concern.json | 8 ++-- test/transactions/unified/reads.json | 2 +- test/transactions/unified/write-concern.json | 6 +-- .../crud-api-version-1-strict.json | 8 ++-- test/versioned-api/crud-api-version-1.json | 8 ++-- 18 files changed, 78 insertions(+), 78 deletions(-) diff --git a/test/asynchronous/test_collection.py b/test/asynchronous/test_collection.py index 7a81a6b0c4..0af178df8a 100644 --- a/test/asynchronous/test_collection.py +++ b/test/asynchronous/test_collection.py @@ -471,7 +471,7 @@ async def test_index_haystack(self): await db.command( SON( [ - ("geoSearch", "test"), + ("geoSearch", "coll"), ("near", [33, 33]), ("maxDistance", 6), ("search", {"type": "restaurant"}), diff --git a/test/asynchronous/test_cursor.py b/test/asynchronous/test_cursor.py index daf506a4c6..9b10997fd7 100644 --- a/test/asynchronous/test_cursor.py +++ b/test/asynchronous/test_cursor.py @@ -224,7 +224,7 @@ async def test_maxtime_ms_message(self): async def test_max_await_time_ms(self): db = self.db await db.coll.drop() - coll = await db.create_collection("db", capped=True, size=4096) + coll = await db.create_collection("coll", capped=True, size=4096) with self.assertRaises(TypeError): coll.find().max_await_time_ms("foo") # type: ignore[arg-type] diff --git a/test/asynchronous/test_database.py b/test/asynchronous/test_database.py index 96029acda9..ec95740fa5 100644 --- a/test/asynchronous/test_database.py +++ b/test/asynchronous/test_database.py @@ -163,7 +163,7 @@ async def test_create_collection(self): await db.create_collection("coll..ection") # type: ignore[arg-type] test = await db.create_collection("coll") - self.assertIn("test", await db.list_collection_names()) + self.assertIn("coll", await db.list_collection_names()) await test.insert_one({"hello": "world"}) self.assertEqual((await db.coll.find_one())["hello"], "world") @@ -179,8 +179,8 @@ async def test_list_collection_names(self): await db.coll.mike.insert_one({"dummy": "object"}) colls = await db.list_collection_names() - self.assertIn("test", colls) - self.assertIn("test.mike", colls) + self.assertIn("coll", colls) + self.assertIn("coll.mike", colls) for coll in colls: self.assertNotIn("$", coll) @@ -252,8 +252,8 @@ async def test_list_collections(self): colls = [result["name"] async for result in results] # All the collections present. - self.assertIn("test", colls) - self.assertIn("test.mike", colls) + self.assertIn("coll", colls) + self.assertIn("coll.mike", colls) # No collection containing a '$'. for coll in colls: @@ -271,13 +271,13 @@ async def test_list_collections(self): coll_cnt: dict = {} # Check if there are any collections which don't exist. - self.assertLessEqual(set(colls), {"test", "test.mike", "system.indexes"}) + self.assertLessEqual(set(colls), {"coll", "coll.mike", "system.indexes"}) - colls = await (await db.list_collections(filter={"name": {"$regex": "^test$"}})).to_list() + colls = await (await db.list_collections(filter={"name": {"$regex": "^coll$"}})).to_list() self.assertEqual(1, len(colls)) colls = await ( - await db.list_collections(filter={"name": {"$regex": "^test.mike$"}}) + await db.list_collections(filter={"name": {"$regex": "^coll\\.mike$"}}) ).to_list() self.assertEqual(1, len(colls)) @@ -288,8 +288,8 @@ async def test_list_collections(self): colls = [result["name"] async for result in results] # Checking only capped collections are present - self.assertIn("test", colls) - self.assertNotIn("test.mike", colls) + self.assertIn("coll", colls) + self.assertNotIn("coll.mike", colls) # No collection containing a '$'. for coll in colls: @@ -307,7 +307,7 @@ async def test_list_collections(self): coll_cnt = {} # Check if there are any collections which don't exist. - self.assertLessEqual(set(colls), {"test", "system.indexes"}) + self.assertLessEqual(set(colls), {"coll", "system.indexes"}) await self.client.drop_database("db") @@ -330,24 +330,24 @@ async def test_drop_collection(self): await db.drop_collection(None) # type: ignore[arg-type] await db.coll.insert_one({"dummy": "object"}) - self.assertIn("test", await db.list_collection_names()) + self.assertIn("coll", await db.list_collection_names()) await db.drop_collection("coll") - self.assertNotIn("test", await db.list_collection_names()) + self.assertNotIn("coll", await db.list_collection_names()) await db.coll.insert_one({"dummy": "object"}) - self.assertIn("test", await db.list_collection_names()) + self.assertIn("coll", await db.list_collection_names()) await db.drop_collection("coll") - self.assertNotIn("test", await db.list_collection_names()) + self.assertNotIn("coll", await db.list_collection_names()) await db.coll.insert_one({"dummy": "object"}) - self.assertIn("test", await db.list_collection_names()) + self.assertIn("coll", await db.list_collection_names()) await db.drop_collection(db.coll) - self.assertNotIn("test", await db.list_collection_names()) + self.assertNotIn("coll", await db.list_collection_names()) await db.coll.insert_one({"dummy": "object"}) - self.assertIn("test", await db.list_collection_names()) + self.assertIn("coll", await db.list_collection_names()) await db.coll.drop() - self.assertNotIn("test", await db.list_collection_names()) + self.assertNotIn("coll", await db.list_collection_names()) await db.coll.drop() await db.drop_collection(db.coll.doesnotexist) diff --git a/test/causal_consistency/causal-consistency-write-commands.json b/test/causal_consistency/causal-consistency-write-commands.json index 4124929212..a43bae13d5 100644 --- a/test/causal_consistency/causal-consistency-write-commands.json +++ b/test/causal_consistency/causal-consistency-write-commands.json @@ -676,7 +676,7 @@ "commandStartedEvent": { "commandName": "findAndModify", "command": { - "findAndModify": "test", + "findAndModify": "coll", "lsid": { "$$sessionLsid": "session0" }, @@ -751,7 +751,7 @@ "commandStartedEvent": { "commandName": "findAndModify", "command": { - "findAndModify": "test", + "findAndModify": "coll", "lsid": { "$$sessionLsid": "session0" }, @@ -829,7 +829,7 @@ "commandStartedEvent": { "commandName": "findAndModify", "command": { - "findAndModify": "test", + "findAndModify": "coll", "lsid": { "$$sessionLsid": "session0" }, diff --git a/test/crud/unified/findOneAndUpdate-pipeline.json b/test/crud/unified/findOneAndUpdate-pipeline.json index 98c561d46e..da1a5b5bea 100644 --- a/test/crud/unified/findOneAndUpdate-pipeline.json +++ b/test/crud/unified/findOneAndUpdate-pipeline.json @@ -86,7 +86,7 @@ { "commandStartedEvent": { "command": { - "findAndModify": "test", + "findAndModify": "coll", "update": [ { "$project": { diff --git a/test/sessions/driver-sessions-dirty-session-errors.json b/test/sessions/driver-sessions-dirty-session-errors.json index 4dc5703531..fe0884dcff 100644 --- a/test/sessions/driver-sessions-dirty-session-errors.json +++ b/test/sessions/driver-sessions-dirty-session-errors.json @@ -338,7 +338,7 @@ { "commandStartedEvent": { "command": { - "findAndModify": "test", + "findAndModify": "coll", "query": { "_id": 1 }, @@ -368,7 +368,7 @@ { "commandStartedEvent": { "command": { - "findAndModify": "test", + "findAndModify": "coll", "query": { "_id": 1 }, @@ -622,7 +622,7 @@ { "commandStartedEvent": { "command": { - "findAndModify": "test", + "findAndModify": "coll", "query": { "_id": 1 }, @@ -652,7 +652,7 @@ { "commandStartedEvent": { "command": { - "findAndModify": "test", + "findAndModify": "coll", "query": { "_id": 1 }, diff --git a/test/test_collection.py b/test/test_collection.py index 6cb8434974..68e61068c7 100644 --- a/test/test_collection.py +++ b/test/test_collection.py @@ -461,7 +461,7 @@ def test_index_haystack(self): db.command( SON( [ - ("geoSearch", "test"), + ("geoSearch", "coll"), ("near", [33, 33]), ("maxDistance", 6), ("search", {"type": "restaurant"}), diff --git a/test/test_cursor.py b/test/test_cursor.py index e97a8e14cb..9dac2fb26d 100644 --- a/test/test_cursor.py +++ b/test/test_cursor.py @@ -222,7 +222,7 @@ def test_maxtime_ms_message(self): def test_max_await_time_ms(self): db = self.db db.coll.drop() - coll = db.create_collection("db", capped=True, size=4096) + coll = db.create_collection("coll", capped=True, size=4096) with self.assertRaises(TypeError): coll.find().max_await_time_ms("foo") # type: ignore[arg-type] diff --git a/test/test_database.py b/test/test_database.py index 68e907eac5..82bb1f9b11 100644 --- a/test/test_database.py +++ b/test/test_database.py @@ -162,7 +162,7 @@ def test_create_collection(self): db.create_collection("coll..ection") # type: ignore[arg-type] test = db.create_collection("coll") - self.assertIn("test", db.list_collection_names()) + self.assertIn("coll", db.list_collection_names()) test.insert_one({"hello": "world"}) self.assertEqual((db.coll.find_one())["hello"], "world") @@ -178,8 +178,8 @@ def test_list_collection_names(self): db.coll.mike.insert_one({"dummy": "object"}) colls = db.list_collection_names() - self.assertIn("test", colls) - self.assertIn("test.mike", colls) + self.assertIn("coll", colls) + self.assertIn("coll.mike", colls) for coll in colls: self.assertNotIn("$", coll) @@ -251,8 +251,8 @@ def test_list_collections(self): colls = [result["name"] for result in results] # All the collections present. - self.assertIn("test", colls) - self.assertIn("test.mike", colls) + self.assertIn("coll", colls) + self.assertIn("coll.mike", colls) # No collection containing a '$'. for coll in colls: @@ -270,12 +270,12 @@ def test_list_collections(self): coll_cnt: dict = {} # Check if there are any collections which don't exist. - self.assertLessEqual(set(colls), {"test", "test.mike", "system.indexes"}) + self.assertLessEqual(set(colls), {"coll", "coll.mike", "system.indexes"}) - colls = (db.list_collections(filter={"name": {"$regex": "^test$"}})).to_list() + colls = (db.list_collections(filter={"name": {"$regex": "^coll$"}})).to_list() self.assertEqual(1, len(colls)) - colls = (db.list_collections(filter={"name": {"$regex": "^test.mike$"}})).to_list() + colls = (db.list_collections(filter={"name": {"$regex": "^coll\\.mike$"}})).to_list() self.assertEqual(1, len(colls)) db.drop_collection("coll") @@ -285,8 +285,8 @@ def test_list_collections(self): colls = [result["name"] for result in results] # Checking only capped collections are present - self.assertIn("test", colls) - self.assertNotIn("test.mike", colls) + self.assertIn("coll", colls) + self.assertNotIn("coll.mike", colls) # No collection containing a '$'. for coll in colls: @@ -304,7 +304,7 @@ def test_list_collections(self): coll_cnt = {} # Check if there are any collections which don't exist. - self.assertLessEqual(set(colls), {"test", "system.indexes"}) + self.assertLessEqual(set(colls), {"coll", "system.indexes"}) self.client.drop_database("db") @@ -327,24 +327,24 @@ def test_drop_collection(self): db.drop_collection(None) # type: ignore[arg-type] db.coll.insert_one({"dummy": "object"}) - self.assertIn("test", db.list_collection_names()) + self.assertIn("coll", db.list_collection_names()) db.drop_collection("coll") - self.assertNotIn("test", db.list_collection_names()) + self.assertNotIn("coll", db.list_collection_names()) db.coll.insert_one({"dummy": "object"}) - self.assertIn("test", db.list_collection_names()) + self.assertIn("coll", db.list_collection_names()) db.drop_collection("coll") - self.assertNotIn("test", db.list_collection_names()) + self.assertNotIn("coll", db.list_collection_names()) db.coll.insert_one({"dummy": "object"}) - self.assertIn("test", db.list_collection_names()) + self.assertIn("coll", db.list_collection_names()) db.drop_collection(db.coll) - self.assertNotIn("test", db.list_collection_names()) + self.assertNotIn("coll", db.list_collection_names()) db.coll.insert_one({"dummy": "object"}) - self.assertIn("test", db.list_collection_names()) + self.assertIn("coll", db.list_collection_names()) db.coll.drop() - self.assertNotIn("test", db.list_collection_names()) + self.assertNotIn("coll", db.list_collection_names()) db.coll.drop() db.drop_collection(db.coll.doesnotexist) diff --git a/test/transactions/unified/error-labels.json b/test/transactions/unified/error-labels.json index c7edbc1ef1..fe6e3f28bb 100644 --- a/test/transactions/unified/error-labels.json +++ b/test/transactions/unified/error-labels.json @@ -829,7 +829,7 @@ { "commandStartedEvent": { "command": { - "distinct": "test", + "distinct": "coll", "key": "_id", "lsid": { "$$sessionLsid": "session0" diff --git a/test/transactions/unified/findOneAndDelete.json b/test/transactions/unified/findOneAndDelete.json index 9c2575365f..a9be82161f 100644 --- a/test/transactions/unified/findOneAndDelete.json +++ b/test/transactions/unified/findOneAndDelete.json @@ -107,7 +107,7 @@ { "commandStartedEvent": { "command": { - "findAndModify": "test", + "findAndModify": "coll", "query": { "_id": 3 }, @@ -134,7 +134,7 @@ { "commandStartedEvent": { "command": { - "findAndModify": "test", + "findAndModify": "coll", "query": { "_id": 4 }, @@ -260,7 +260,7 @@ { "commandStartedEvent": { "command": { - "findAndModify": "test", + "findAndModify": "coll", "query": { "_id": 3 }, diff --git a/test/transactions/unified/findOneAndReplace.json b/test/transactions/unified/findOneAndReplace.json index b7b26c5f78..cfad4dce16 100644 --- a/test/transactions/unified/findOneAndReplace.json +++ b/test/transactions/unified/findOneAndReplace.json @@ -120,7 +120,7 @@ { "commandStartedEvent": { "command": { - "findAndModify": "test", + "findAndModify": "coll", "query": { "_id": 3 }, @@ -152,7 +152,7 @@ { "commandStartedEvent": { "command": { - "findAndModify": "test", + "findAndModify": "coll", "query": { "_id": 4 }, @@ -294,7 +294,7 @@ { "commandStartedEvent": { "command": { - "findAndModify": "test", + "findAndModify": "coll", "query": { "_id": 3 }, diff --git a/test/transactions/unified/findOneAndUpdate.json b/test/transactions/unified/findOneAndUpdate.json index 79476f37ce..1e336062b7 100644 --- a/test/transactions/unified/findOneAndUpdate.json +++ b/test/transactions/unified/findOneAndUpdate.json @@ -180,7 +180,7 @@ { "commandStartedEvent": { "command": { - "findAndModify": "test", + "findAndModify": "coll", "query": { "_id": 3 }, @@ -214,7 +214,7 @@ { "commandStartedEvent": { "command": { - "findAndModify": "test", + "findAndModify": "coll", "query": { "_id": 4 }, @@ -274,7 +274,7 @@ { "commandStartedEvent": { "command": { - "findAndModify": "test", + "findAndModify": "coll", "query": { "_id": 3 }, @@ -335,7 +335,7 @@ { "commandStartedEvent": { "command": { - "findAndModify": "test", + "findAndModify": "coll", "query": { "_id": 3 }, @@ -482,7 +482,7 @@ { "commandStartedEvent": { "command": { - "findAndModify": "test", + "findAndModify": "coll", "query": { "_id": 3 }, diff --git a/test/transactions/unified/read-concern.json b/test/transactions/unified/read-concern.json index adb89d23f3..4f645050ae 100644 --- a/test/transactions/unified/read-concern.json +++ b/test/transactions/unified/read-concern.json @@ -779,7 +779,7 @@ { "commandStartedEvent": { "command": { - "distinct": "test", + "distinct": "coll", "key": "_id", "lsid": { "$$sessionLsid": "session0" @@ -803,7 +803,7 @@ { "commandStartedEvent": { "command": { - "distinct": "test", + "distinct": "coll", "key": "_id", "lsid": { "$$sessionLsid": "session0" @@ -1689,7 +1689,7 @@ { "commandStartedEvent": { "command": { - "distinct": "test", + "distinct": "coll", "key": "_id", "lsid": { "$$sessionLsid": "session0" @@ -1713,7 +1713,7 @@ { "commandStartedEvent": { "command": { - "distinct": "test", + "distinct": "coll", "key": "_id", "lsid": { "$$sessionLsid": "session0" diff --git a/test/transactions/unified/reads.json b/test/transactions/unified/reads.json index 6fe49f3c75..3162e86ced 100644 --- a/test/transactions/unified/reads.json +++ b/test/transactions/unified/reads.json @@ -632,7 +632,7 @@ { "commandStartedEvent": { "command": { - "distinct": "test", + "distinct": "coll", "key": "_id", "lsid": { "$$sessionLsid": "session0" diff --git a/test/transactions/unified/write-concern.json b/test/transactions/unified/write-concern.json index 7560431d9e..cb4ef08bbd 100644 --- a/test/transactions/unified/write-concern.json +++ b/test/transactions/unified/write-concern.json @@ -1317,7 +1317,7 @@ { "commandStartedEvent": { "command": { - "findAndModify": "test", + "findAndModify": "coll", "query": { "_id": 0 }, @@ -1410,7 +1410,7 @@ { "commandStartedEvent": { "command": { - "findAndModify": "test", + "findAndModify": "coll", "query": { "_id": 0 }, @@ -1515,7 +1515,7 @@ { "commandStartedEvent": { "command": { - "findAndModify": "test", + "findAndModify": "coll", "query": { "_id": 0 }, diff --git a/test/versioned-api/crud-api-version-1-strict.json b/test/versioned-api/crud-api-version-1-strict.json index e0fab6c71e..acd45a4464 100644 --- a/test/versioned-api/crud-api-version-1-strict.json +++ b/test/versioned-api/crud-api-version-1-strict.json @@ -597,7 +597,7 @@ { "commandStartedEvent": { "command": { - "distinct": "test", + "distinct": "coll", "key": "x", "apiVersion": "1", "apiStrict": true, @@ -743,7 +743,7 @@ { "commandStartedEvent": { "command": { - "findAndModify": "test", + "findAndModify": "coll", "query": { "_id": 1 }, @@ -783,7 +783,7 @@ { "commandStartedEvent": { "command": { - "findAndModify": "test", + "findAndModify": "coll", "query": { "_id": 1 }, @@ -827,7 +827,7 @@ { "commandStartedEvent": { "command": { - "findAndModify": "test", + "findAndModify": "coll", "query": { "_id": 1 }, diff --git a/test/versioned-api/crud-api-version-1.json b/test/versioned-api/crud-api-version-1.json index 03aa9a2002..10503e8c8f 100644 --- a/test/versioned-api/crud-api-version-1.json +++ b/test/versioned-api/crud-api-version-1.json @@ -670,7 +670,7 @@ { "commandStartedEvent": { "command": { - "distinct": "test", + "distinct": "coll", "key": "x", "apiVersion": "1", "apiStrict": { @@ -816,7 +816,7 @@ { "commandStartedEvent": { "command": { - "findAndModify": "test", + "findAndModify": "coll", "query": { "_id": 1 }, @@ -856,7 +856,7 @@ { "commandStartedEvent": { "command": { - "findAndModify": "test", + "findAndModify": "coll", "query": { "_id": 1 }, @@ -900,7 +900,7 @@ { "commandStartedEvent": { "command": { - "findAndModify": "test", + "findAndModify": "coll", "query": { "_id": 1 }, From b35bd48c6b6e56b09d3175b1560429bb9d30b6e3 Mon Sep 17 00:00:00 2001 From: Sophia Yang Date: Fri, 12 Jun 2026 17:29:08 -0400 Subject: [PATCH 8/9] fixing --- test/asynchronous/test_monitoring.py | 8 ++++---- test/asynchronous/test_session.py | 6 +++--- test/connection_string/test/valid-auth.json | 2 +- test/test_monitoring.py | 8 ++++---- test/test_session.py | 6 +++--- test/test_typing.py | 2 +- .../valid-pass/poc-command-monitoring.json | 4 ++-- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/test/asynchronous/test_monitoring.py b/test/asynchronous/test_monitoring.py index af4298c7a9..c88abf298e 100644 --- a/test/asynchronous/test_monitoring.py +++ b/test/asynchronous/test_monitoring.py @@ -113,7 +113,7 @@ async def test_find_one(self): self.assertIsInstance(succeeded, monitoring.CommandSucceededEvent) self.assertIsInstance(started, monitoring.CommandStartedEvent) self.assertEqualCommand( - SON([("find", "test"), ("filter", {}), ("limit", 1), ("singleBatch", True)]), + SON([("find", "coll"), ("filter", {}), ("limit", 1), ("singleBatch", True)]), started.command, ) self.assertEqual("find", started.command_name) @@ -135,7 +135,7 @@ async def test_find_and_get_more(self): self.assertIsInstance(started, monitoring.CommandStartedEvent) self.assertEqualCommand( SON( - [("find", "test"), ("filter", {}), ("projection", {"_id": False}), ("batchSize", 4)] + [("find", "coll"), ("filter", {}), ("projection", {"_id": False}), ("batchSize", 4)] ), started.command, ) @@ -184,7 +184,7 @@ async def test_find_and_get_more(self): tuple(await cursor.to_list()) async def test_find_with_explain(self): - cmd = SON([("explain", SON([("find", "test"), ("filter", {})]))]) + cmd = SON([("explain", SON([("find", "coll"), ("filter", {})]))]) await self.client.db.coll.drop() await self.client.db.coll.insert_one({}) self.listener.reset() @@ -437,7 +437,7 @@ async def test_exhaust(self): self.assertIsInstance(started, monitoring.CommandStartedEvent) self.assertEqualCommand( SON( - [("find", "test"), ("filter", {}), ("projection", {"_id": False}), ("batchSize", 5)] + [("find", "coll"), ("filter", {}), ("projection", {"_id": False}), ("batchSize", 5)] ), started.command, ) diff --git a/test/asynchronous/test_session.py b/test/asynchronous/test_session.py index 15b6129ea2..72cfb256b2 100644 --- a/test/asynchronous/test_session.py +++ b/test/asynchronous/test_session.py @@ -368,7 +368,7 @@ async def test_database(self): await self._test_ops(client, *ops) @staticmethod - def test_write_ops(coll): + def collection_write_ops(coll): """Generate database write ops for tests.""" return [ (coll.drop, [], {}), @@ -398,7 +398,7 @@ async def test_collection(self): coll = client.db.coll # Test some collection methods - the rest are in test_cursor. - ops = self.test_write_ops(coll) + ops = self.collection_write_ops(coll) ops.extend( [ (coll.distinct, ["a"], {}), @@ -836,7 +836,7 @@ async def test_unacknowledged_writes(self): (db.create_collection, ["coll"], {}), (db.drop_collection, ["coll"], {}), ] - ops.extend(self.test_write_ops(coll)) + ops.extend(self.collection_write_ops(coll)) await self._test_unacknowledged_ops(client, *ops) async def drop_db(): diff --git a/test/connection_string/test/valid-auth.json b/test/connection_string/test/valid-auth.json index 803ff1a23b..60f63f4e3f 100644 --- a/test/connection_string/test/valid-auth.json +++ b/test/connection_string/test/valid-auth.json @@ -34,7 +34,7 @@ "auth": { "username": "alice", "password": "foo", - "db": "db" + "db": "test" }, "options": null }, diff --git a/test/test_monitoring.py b/test/test_monitoring.py index 49c0f1d9ff..08e93538d5 100644 --- a/test/test_monitoring.py +++ b/test/test_monitoring.py @@ -111,7 +111,7 @@ def test_find_one(self): self.assertIsInstance(succeeded, monitoring.CommandSucceededEvent) self.assertIsInstance(started, monitoring.CommandStartedEvent) self.assertEqualCommand( - SON([("find", "test"), ("filter", {}), ("limit", 1), ("singleBatch", True)]), + SON([("find", "coll"), ("filter", {}), ("limit", 1), ("singleBatch", True)]), started.command, ) self.assertEqual("find", started.command_name) @@ -133,7 +133,7 @@ def test_find_and_get_more(self): self.assertIsInstance(started, monitoring.CommandStartedEvent) self.assertEqualCommand( SON( - [("find", "test"), ("filter", {}), ("projection", {"_id": False}), ("batchSize", 4)] + [("find", "coll"), ("filter", {}), ("projection", {"_id": False}), ("batchSize", 4)] ), started.command, ) @@ -182,7 +182,7 @@ def test_find_and_get_more(self): tuple(cursor.to_list()) def test_find_with_explain(self): - cmd = SON([("explain", SON([("find", "test"), ("filter", {})]))]) + cmd = SON([("explain", SON([("find", "coll"), ("filter", {})]))]) self.client.db.coll.drop() self.client.db.coll.insert_one({}) self.listener.reset() @@ -435,7 +435,7 @@ def test_exhaust(self): self.assertIsInstance(started, monitoring.CommandStartedEvent) self.assertEqualCommand( SON( - [("find", "test"), ("filter", {}), ("projection", {"_id": False}), ("batchSize", 5)] + [("find", "coll"), ("filter", {}), ("projection", {"_id": False}), ("batchSize", 5)] ), started.command, ) diff --git a/test/test_session.py b/test/test_session.py index c9446bd845..51dc495ac8 100644 --- a/test/test_session.py +++ b/test/test_session.py @@ -368,7 +368,7 @@ def test_database(self): self._test_ops(client, *ops) @staticmethod - def test_write_ops(coll): + def collection_write_ops(coll): """Generate database write ops for tests.""" return [ (coll.drop, [], {}), @@ -398,7 +398,7 @@ def test_collection(self): coll = client.db.coll # Test some collection methods - the rest are in test_cursor. - ops = self.test_write_ops(coll) + ops = self.collection_write_ops(coll) ops.extend( [ (coll.distinct, ["a"], {}), @@ -836,7 +836,7 @@ def test_unacknowledged_writes(self): (db.create_collection, ["coll"], {}), (db.drop_collection, ["coll"], {}), ] - ops.extend(self.test_write_ops(coll)) + ops.extend(self.collection_write_ops(coll)) self._test_unacknowledged_ops(client, *ops) def drop_db(): diff --git a/test/test_typing.py b/test/test_typing.py index 8d186814e9..26621324e0 100644 --- a/test/test_typing.py +++ b/test/test_typing.py @@ -207,7 +207,7 @@ def test_command(self) -> None: result.items() def test_list_collections(self) -> None: - cursor = self.client.test.list_collections() + cursor = self.client.db.list_collections() value = cursor.next() value.items() diff --git a/test/unified-test-format/valid-pass/poc-command-monitoring.json b/test/unified-test-format/valid-pass/poc-command-monitoring.json index 5f23c79993..fb6c74ed2d 100644 --- a/test/unified-test-format/valid-pass/poc-command-monitoring.json +++ b/test/unified-test-format/valid-pass/poc-command-monitoring.json @@ -120,7 +120,7 @@ "long" ] }, - "ns": "command-monitoring-tests.test", + "ns": "command-monitoring-tests.coll", "firstBatch": [ { "_id": 1, @@ -162,7 +162,7 @@ "ok": 1, "cursor": { "id": 0, - "ns": "command-monitoring-tests.test", + "ns": "command-monitoring-tests.coll", "nextBatch": [ { "_id": 4, From d890900d53f9cbeef92904a667ab29d423da9bed Mon Sep 17 00:00:00 2001 From: Sophia Yang Date: Fri, 12 Jun 2026 17:44:14 -0400 Subject: [PATCH 9/9] this time is it good? --- test/asynchronous/test_monitoring.py | 8 ++++---- test/test_monitoring.py | 8 ++++---- test/transactions/unified/count.json | 2 +- test/versioned-api/crud-api-version-1-strict.json | 2 +- test/versioned-api/crud-api-version-1.json | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/test/asynchronous/test_monitoring.py b/test/asynchronous/test_monitoring.py index c88abf298e..f328688ef9 100644 --- a/test/asynchronous/test_monitoring.py +++ b/test/asynchronous/test_monitoring.py @@ -163,7 +163,7 @@ async def test_find_and_get_more(self): self.assertEqual(0, len(self.listener.failed_events)) self.assertIsInstance(started, monitoring.CommandStartedEvent) self.assertEqualCommand( - SON([("getMore", cursor_id), ("collection", "db.coll"), ("batchSize", 4)]), + SON([("getMore", cursor_id), ("collection", "coll"), ("batchSize", 4)]), started.command, ) self.assertEqual("getMore", started.command_name) @@ -343,7 +343,7 @@ async def test_command_and_get_more(self): self.assertEqual(0, len(self.listener.failed_events)) self.assertIsInstance(started, monitoring.CommandStartedEvent) self.assertEqualCommand( - SON([("getMore", cursor_id), ("collection", "db.coll"), ("batchSize", 4)]), + SON([("getMore", cursor_id), ("collection", "coll"), ("batchSize", 4)]), started.command, ) self.assertEqual("getMore", started.command_name) @@ -383,7 +383,7 @@ async def test_get_more_failure(self): failed = self.listener.failed_events[0] self.assertIsInstance(started, monitoring.CommandStartedEvent) self.assertEqualCommand( - SON([("getMore", cursor_id), ("collection", "db.coll")]), started.command + SON([("getMore", cursor_id), ("collection", "coll")]), started.command ) self.assertEqual("getMore", started.command_name) self.assertEqual(await self.client.address, started.connection_id) @@ -466,7 +466,7 @@ async def test_exhaust(self): for event in self.listener.started_events: self.assertIsInstance(event, monitoring.CommandStartedEvent) self.assertEqualCommand( - SON([("getMore", cursor_id), ("collection", "db.coll"), ("batchSize", 5)]), + SON([("getMore", cursor_id), ("collection", "coll"), ("batchSize", 5)]), event.command, ) self.assertEqual("getMore", event.command_name) diff --git a/test/test_monitoring.py b/test/test_monitoring.py index 08e93538d5..9ed484c2fe 100644 --- a/test/test_monitoring.py +++ b/test/test_monitoring.py @@ -161,7 +161,7 @@ def test_find_and_get_more(self): self.assertEqual(0, len(self.listener.failed_events)) self.assertIsInstance(started, monitoring.CommandStartedEvent) self.assertEqualCommand( - SON([("getMore", cursor_id), ("collection", "db.coll"), ("batchSize", 4)]), + SON([("getMore", cursor_id), ("collection", "coll"), ("batchSize", 4)]), started.command, ) self.assertEqual("getMore", started.command_name) @@ -341,7 +341,7 @@ def test_command_and_get_more(self): self.assertEqual(0, len(self.listener.failed_events)) self.assertIsInstance(started, monitoring.CommandStartedEvent) self.assertEqualCommand( - SON([("getMore", cursor_id), ("collection", "db.coll"), ("batchSize", 4)]), + SON([("getMore", cursor_id), ("collection", "coll"), ("batchSize", 4)]), started.command, ) self.assertEqual("getMore", started.command_name) @@ -381,7 +381,7 @@ def test_get_more_failure(self): failed = self.listener.failed_events[0] self.assertIsInstance(started, monitoring.CommandStartedEvent) self.assertEqualCommand( - SON([("getMore", cursor_id), ("collection", "db.coll")]), started.command + SON([("getMore", cursor_id), ("collection", "coll")]), started.command ) self.assertEqual("getMore", started.command_name) self.assertEqual(self.client.address, started.connection_id) @@ -464,7 +464,7 @@ def test_exhaust(self): for event in self.listener.started_events: self.assertIsInstance(event, monitoring.CommandStartedEvent) self.assertEqualCommand( - SON([("getMore", cursor_id), ("collection", "db.coll"), ("batchSize", 5)]), + SON([("getMore", cursor_id), ("collection", "coll"), ("batchSize", 5)]), event.command, ) self.assertEqual("getMore", event.command_name) diff --git a/test/transactions/unified/count.json b/test/transactions/unified/count.json index b7087ec7cf..89acfcffe7 100644 --- a/test/transactions/unified/count.json +++ b/test/transactions/unified/count.json @@ -104,7 +104,7 @@ { "commandStartedEvent": { "command": { - "count": "test", + "count": "coll", "query": { "_id": 1 }, diff --git a/test/versioned-api/crud-api-version-1-strict.json b/test/versioned-api/crud-api-version-1-strict.json index acd45a4464..6994c07442 100644 --- a/test/versioned-api/crud-api-version-1-strict.json +++ b/test/versioned-api/crud-api-version-1-strict.json @@ -636,7 +636,7 @@ { "commandStartedEvent": { "command": { - "count": "test", + "count": "coll", "apiVersion": "1", "apiStrict": true, "apiDeprecationErrors": { diff --git a/test/versioned-api/crud-api-version-1.json b/test/versioned-api/crud-api-version-1.json index 10503e8c8f..7fbbaf5633 100644 --- a/test/versioned-api/crud-api-version-1.json +++ b/test/versioned-api/crud-api-version-1.json @@ -709,7 +709,7 @@ { "commandStartedEvent": { "command": { - "count": "test", + "count": "coll", "apiVersion": "1", "apiStrict": { "$$unsetOrMatches": false