Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions test/asynchronous/test_change_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from test.utils import (
AllowListEventListener,
EventListener,
OvertCommandListener,
async_wait_until,
)

Expand Down Expand Up @@ -179,7 +180,7 @@ async def _wait_until():

@no_type_check
async def test_try_next_runs_one_getmore(self):
listener = EventListener()
listener = OvertCommandListener()
client = await self.async_rs_or_single_client(event_listeners=[listener])
# Connect to the cluster.
await client.admin.command("ping")
Expand Down Expand Up @@ -237,7 +238,7 @@ async def _wait_until():

@no_type_check
async def test_batch_size_is_honored(self):
listener = EventListener()
listener = OvertCommandListener()
client = await self.async_rs_or_single_client(event_listeners=[listener])
# Connect to the cluster.
await client.admin.command("ping")
Expand Down
4 changes: 2 additions & 2 deletions test/asynchronous/test_collation.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import functools
import warnings
from test.asynchronous import AsyncIntegrationTest, async_client_context, unittest
from test.utils import EventListener
from test.utils import EventListener, OvertCommandListener
from typing import Any

from pymongo.asynchronous.helpers import anext
Expand Down Expand Up @@ -101,7 +101,7 @@ class TestCollation(AsyncIntegrationTest):
@async_client_context.require_connection
async def _setup_class(cls):
await super()._setup_class()
cls.listener = EventListener()
cls.listener = OvertCommandListener()
cls.client = await cls.unmanaged_async_rs_or_single_client(event_listeners=[cls.listener])
cls.db = cls.client.pymongo_test
cls.collation = Collation("en_US")
Expand Down
3 changes: 2 additions & 1 deletion test/asynchronous/test_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from test.utils import (
IMPOSSIBLE_WRITE_CONCERN,
EventListener,
OvertCommandListener,
async_get_pool,
async_is_mongos,
async_wait_until,
Expand Down Expand Up @@ -2116,7 +2117,7 @@ async def test_find_one_and(self):
self.assertEqual(4, (await c.find_one_and_update({}, {"$inc": {"i": 1}}, sort=sort))["j"])

async def test_find_one_and_write_concern(self):
listener = EventListener()
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))
Expand Down
4 changes: 2 additions & 2 deletions test/asynchronous/test_cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1601,7 +1601,7 @@ async def test_read_concern(self):
await anext(c.find_raw_batches())

async def test_monitoring(self):
listener = EventListener()
listener = OvertCommandListener()
client = await self.async_rs_or_single_client(event_listeners=[listener])
c = client.pymongo_test.test
await c.drop()
Expand Down Expand Up @@ -1768,7 +1768,7 @@ async def test_collation(self):
await anext(await self.db.test.aggregate_raw_batches([], collation=Collation("en_US")))

async def test_monitoring(self):
listener = EventListener()
listener = OvertCommandListener()
client = await self.async_rs_or_single_client(event_listeners=[listener])
c = client.pymongo_test.test
await c.drop()
Expand Down
4 changes: 2 additions & 2 deletions test/asynchronous/test_grid_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

sys.path[0:0] = [""]

from test.utils import EventListener
from test.utils import OvertCommandListener

from bson.objectid import ObjectId
from gridfs.asynchronous.grid_file import (
Expand Down Expand Up @@ -810,7 +810,7 @@ async def test_survive_cursor_not_found(self):
# Use 102 batches to cause a single getMore.
chunk_size = 1024
data = b"d" * (102 * chunk_size)
listener = EventListener()
listener = OvertCommandListener()
client = await self.async_rs_or_single_client(event_listeners=[listener])
db = client.pymongo_test
async with AsyncGridIn(db.fs, chunk_size=chunk_size) as infile:
Expand Down
5 changes: 3 additions & 2 deletions test/asynchronous/test_monitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
)
from test.utils import (
EventListener,
OvertCommandListener,
async_wait_until,
)

Expand All @@ -54,7 +55,7 @@ class AsyncTestCommandMonitoring(AsyncIntegrationTest):
@async_client_context.require_connection
async def _setup_class(cls):
await super()._setup_class()
cls.listener = EventListener()
cls.listener = OvertCommandListener()
cls.client = await cls.unmanaged_async_rs_or_single_client(
event_listeners=[cls.listener], retryWrites=False
)
Expand Down Expand Up @@ -1140,7 +1141,7 @@ class AsyncTestGlobalListener(AsyncIntegrationTest):
@async_client_context.require_connection
async def _setup_class(cls):
await super()._setup_class()
cls.listener = EventListener()
cls.listener = OvertCommandListener()
# We plan to call register(), which internally modifies _LISTENERS.
cls.saved_listeners = copy.deepcopy(monitoring._LISTENERS)
monitoring.register(cls.listener)
Expand Down
3 changes: 2 additions & 1 deletion test/asynchronous/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from test.utils import (
EventListener,
ExceptionCatchingThread,
OvertCommandListener,
async_wait_until,
wait_until,
)
Expand Down Expand Up @@ -199,7 +200,7 @@ def test_implicit_sessions_checkout(self):
lsid_set = set()
failures = 0
for _ in range(5):
listener = EventListener()
listener = OvertCommandListener()
client = self.async_rs_or_single_client(event_listeners=[listener], maxPoolSize=1)
cursor = client.db.test.find({})
ops: List[Tuple[Callable, List[Any]]] = [
Expand Down
6 changes: 3 additions & 3 deletions test/auth_oidc/test_auth_oidc.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
sys.path[0:0] = [""]

from test.unified_format import generate_test_classes
from test.utils import EventListener
from test.utils import EventListener, OvertCommandListener

from bson import SON
from pymongo import MongoClient
Expand Down Expand Up @@ -348,7 +348,7 @@ def test_4_1_reauthenticate_succeeds(self):
# Create a default OIDC client and add an event listener.
# The following assumes that the driver does not emit saslStart or saslContinue events.
# If the driver does emit those events, ignore/filter them for the purposes of this test.
listener = EventListener()
listener = OvertCommandListener()
client = self.create_client(event_listeners=[listener])

# Perform a find operation that succeeds.
Expand Down Expand Up @@ -1021,7 +1021,7 @@ def fetch(self, _):

def test_4_4_speculative_authentication_should_be_ignored_on_reauthentication(self):
# Create an OIDC configured client that can listen for `SaslStart` commands.
listener = EventListener()
listener = OvertCommandListener()
client = self.create_client(event_listeners=[listener])

# Preload the *Client Cache* with a valid access token to enforce Speculative Authentication.
Expand Down
5 changes: 3 additions & 2 deletions test/test_change_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from test.utils import (
AllowListEventListener,
EventListener,
OvertCommandListener,
wait_until,
)

Expand Down Expand Up @@ -177,7 +178,7 @@ def _wait_until():

@no_type_check
def test_try_next_runs_one_getmore(self):
listener = EventListener()
listener = OvertCommandListener()
client = self.rs_or_single_client(event_listeners=[listener])
# Connect to the cluster.
client.admin.command("ping")
Expand Down Expand Up @@ -235,7 +236,7 @@ def _wait_until():

@no_type_check
def test_batch_size_is_honored(self):
listener = EventListener()
listener = OvertCommandListener()
client = self.rs_or_single_client(event_listeners=[listener])
# Connect to the cluster.
client.admin.command("ping")
Expand Down
4 changes: 2 additions & 2 deletions test/test_collation.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import functools
import warnings
from test import IntegrationTest, client_context, unittest
from test.utils import EventListener
from test.utils import EventListener, OvertCommandListener
from typing import Any

from pymongo.collation import (
Expand Down Expand Up @@ -101,7 +101,7 @@ class TestCollation(IntegrationTest):
@client_context.require_connection
def _setup_class(cls):
super()._setup_class()
cls.listener = EventListener()
cls.listener = OvertCommandListener()
cls.client = cls.unmanaged_rs_or_single_client(event_listeners=[cls.listener])
cls.db = cls.client.pymongo_test
cls.collation = Collation("en_US")
Expand Down
3 changes: 2 additions & 1 deletion test/test_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from test.utils import (
IMPOSSIBLE_WRITE_CONCERN,
EventListener,
OvertCommandListener,
get_pool,
is_mongos,
wait_until,
Expand Down Expand Up @@ -2093,7 +2094,7 @@ def test_find_one_and(self):
self.assertEqual(4, (c.find_one_and_update({}, {"$inc": {"i": 1}}, sort=sort))["j"])

def test_find_one_and_write_concern(self):
listener = EventListener()
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))
Expand Down
4 changes: 2 additions & 2 deletions test/test_cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1590,7 +1590,7 @@ def test_read_concern(self):
next(c.find_raw_batches())

def test_monitoring(self):
listener = EventListener()
listener = OvertCommandListener()
client = self.rs_or_single_client(event_listeners=[listener])
c = client.pymongo_test.test
c.drop()
Expand Down Expand Up @@ -1757,7 +1757,7 @@ def test_collation(self):
next(self.db.test.aggregate_raw_batches([], collation=Collation("en_US")))

def test_monitoring(self):
listener = EventListener()
listener = OvertCommandListener()
client = self.rs_or_single_client(event_listeners=[listener])
c = client.pymongo_test.test
c.drop()
Expand Down
4 changes: 2 additions & 2 deletions test/test_grid_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

sys.path[0:0] = [""]

from test.utils import EventListener
from test.utils import OvertCommandListener

from bson.objectid import ObjectId
from gridfs.errors import NoFile
Expand Down Expand Up @@ -808,7 +808,7 @@ def test_survive_cursor_not_found(self):
# Use 102 batches to cause a single getMore.
chunk_size = 1024
data = b"d" * (102 * chunk_size)
listener = EventListener()
listener = OvertCommandListener()
client = self.rs_or_single_client(event_listeners=[listener])
db = client.pymongo_test
with GridIn(db.fs, chunk_size=chunk_size) as infile:
Expand Down
4 changes: 2 additions & 2 deletions test/test_index_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

from test import IntegrationTest, PyMongoTestCase, unittest
from test.unified_format import generate_test_classes
from test.utils import AllowListEventListener, EventListener
from test.utils import AllowListEventListener, EventListener, OvertCommandListener

from pymongo.errors import OperationFailure
from pymongo.operations import SearchIndexModel
Expand Down Expand Up @@ -88,7 +88,7 @@ def setUpClass(cls) -> None:
url = os.environ.get("MONGODB_URI")
username = os.environ["DB_USER"]
password = os.environ["DB_PASSWORD"]
cls.listener = listener = EventListener()
cls.listener = listener = OvertCommandListener()
cls.client = cls.unmanaged_simple_client(
url, username=username, password=password, event_listeners=[listener]
)
Expand Down
5 changes: 3 additions & 2 deletions test/test_monitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
)
from test.utils import (
EventListener,
OvertCommandListener,
wait_until,
)

Expand All @@ -54,7 +55,7 @@ class TestCommandMonitoring(IntegrationTest):
@client_context.require_connection
def _setup_class(cls):
super()._setup_class()
cls.listener = EventListener()
cls.listener = OvertCommandListener()
cls.client = cls.unmanaged_rs_or_single_client(
event_listeners=[cls.listener], retryWrites=False
)
Expand Down Expand Up @@ -1140,7 +1141,7 @@ class TestGlobalListener(IntegrationTest):
@client_context.require_connection
def _setup_class(cls):
super()._setup_class()
cls.listener = EventListener()
cls.listener = OvertCommandListener()
# We plan to call register(), which internally modifies _LISTENERS.
cls.saved_listeners = copy.deepcopy(monitoring._LISTENERS)
monitoring.register(cls.listener)
Expand Down
6 changes: 3 additions & 3 deletions test/test_read_write_concern_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

from test import IntegrationTest, client_context, unittest
from test.unified_format import generate_test_classes
from test.utils import EventListener
from test.utils import OvertCommandListener

from pymongo import DESCENDING
from pymongo.errors import (
Expand All @@ -44,7 +44,7 @@

class TestReadWriteConcernSpec(IntegrationTest):
def test_omit_default_read_write_concern(self):
listener = EventListener()
listener = OvertCommandListener()
# Client with default readConcern and writeConcern
client = self.rs_or_single_client(event_listeners=[listener])
self.addCleanup(client.close)
Expand Down Expand Up @@ -205,7 +205,7 @@ def test_error_includes_errInfo(self):

@client_context.require_version_min(4, 9)
def test_write_error_details_exposes_errinfo(self):
listener = EventListener()
listener = OvertCommandListener()
client = self.rs_or_single_client(event_listeners=[listener])
self.addCleanup(client.close)
db = client.errinfotest
Expand Down
3 changes: 2 additions & 1 deletion test/test_server_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from test.utils import (
EventListener,
FunctionCallRecorder,
OvertCommandListener,
wait_until,
)
from test.utils_selection_tests import (
Expand Down Expand Up @@ -74,7 +75,7 @@ def custom_selector(servers):
return [servers[idx]]

# Initialize client with appropriate listeners.
listener = EventListener()
listener = OvertCommandListener()
client = self.rs_or_single_client(
server_selector=custom_selector, event_listeners=[listener]
)
Expand Down
3 changes: 2 additions & 1 deletion test/test_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from test.utils import (
EventListener,
ExceptionCatchingThread,
OvertCommandListener,
wait_until,
)

Expand Down Expand Up @@ -198,7 +199,7 @@ def test_implicit_sessions_checkout(self):
lsid_set = set()
failures = 0
for _ in range(5):
listener = EventListener()
listener = OvertCommandListener()
client = self.rs_or_single_client(event_listeners=[listener], maxPoolSize=1)
cursor = client.db.test.find({})
ops: List[Tuple[Callable, List[Any]]] = [
Expand Down
3 changes: 2 additions & 1 deletion test/test_ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
)
from test.utils import (
EventListener,
OvertCommandListener,
cat_files,
ignore_deprecations,
)
Expand Down Expand Up @@ -552,7 +553,7 @@ def test_mongodb_x509_auth(self):
with self.assertRaises(OperationFailure):
noauth.pymongo_test.test.find_one()

listener = EventListener()
listener = OvertCommandListener()
auth = self.simple_client(
client_context.pair,
authMechanism="MONGODB-X509",
Expand Down
Loading