Skip to content

Commit

Permalink
MOTOR-1098 Skip synchro test_typing and encrypted coll tests on stand…
Browse files Browse the repository at this point in the history
…alones (#200)

Snapshot session test needs to wait for the documents to be visible in the latest snapshot.
  • Loading branch information
ShaneHarvey committed Apr 6, 2023
1 parent 16c476e commit f9aed97
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
5 changes: 3 additions & 2 deletions synchro/synchrotest.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
"test.test_session",
# Deprecated in PyMongo, removed in Motor 2.0.
"test.test_gridfs",
# Skip mypy tests.
"test.test_mypy",
# Skip mypy/typing tests.
"test.test_typing",
]


Expand Down Expand Up @@ -126,6 +126,7 @@
"TestCursor.test_comment",
"TestCursor.test_where",
"TestGridfs.test_gridfs_find",
"TestKmsTLSOptions.test_05_tlsDisableOCSPEndpointCheck_is_permitted",
# Tests that use "authenticate" or "logoout", removed in Motor 2.0.
"TestSASLPlain.test_sasl_plain_bad_credentials",
"TestSCRAM.test_scram",
Expand Down
1 change: 1 addition & 0 deletions test/asyncio_tests/test_asyncio_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ def test_sub_collection(self):
self.assertEqual(codec_options, c.codec_options)

@env.require_version_min(6, 2, -1, -1)
@env.require_no_standalone
@asyncio_test
async def test_async_create_encrypted_collection(self):
if pymongo.version_tuple < (4, 4, 0):
Expand Down
6 changes: 4 additions & 2 deletions test/asyncio_tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -1397,8 +1397,9 @@ async def check_for_snapshot(self, collection):
client = collection.database.client
async with await client.start_session(snapshot=True) as s:
try:
await collection.aggregate([], session=s).to_list(None)
return True
if await collection.find_one(session=s):
return True
return False
except OperationFailure as e:
# Retry them as the server demands...
if e.code == 246: # SnapshotUnavailable
Expand All @@ -1417,6 +1418,7 @@ class TestQueryableEncryptionDocsExample(AsyncIOTestCase):
# Queryable Encryption is not supported on Standalone topology.

@env.require_version_min(6, 0)
@env.require_version_max(6, 9) # TODO remove in MOTOR-1100
@asyncio_test
@env.require_replica_set
async def test_queryable_encryption(self):
Expand Down
4 changes: 4 additions & 0 deletions test/test_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,10 @@ def require_version_max(self, *ver):
"Server version must be at most %s" % str(other_version),
)

def require_no_standalone(self, func):
"""Run a test only if the client is not connected to a standalone."""
return self.require(lambda: not self.is_standalone, "Connected to a standalone", func=func)

def require_replica_set(self, func):
"""Run a test only if the client is connected to a replica set."""
return self.require(
Expand Down
1 change: 1 addition & 0 deletions test/tornado_tests/test_motor_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ def test_sub_collection(self):
self.assertEqual(codec_options, c.codec_options)

@env.require_version_min(6, 2, -1, -1)
@env.require_no_standalone
@gen_test
async def test_async_create_encrypted_collection(self):
if pymongo.version_tuple < (4, 4, 0):
Expand Down

0 comments on commit f9aed97

Please sign in to comment.