Skip to content

Commit 2857ea6

Browse files
committed
Merge branch 'master' of github.com:mongodb/mongo-python-driver
2 parents 8333290 + 50586ba commit 2857ea6

File tree

6 files changed

+58
-114
lines changed

6 files changed

+58
-114
lines changed

CONTRIBUTING.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,3 +244,7 @@ The `-b` flag adds as a regex pattern to block files you do not wish to
244244
update in PyMongo. This is primarily helpful if you are implementing a
245245
new feature in PyMongo that has spec tests already implemented, or if
246246
you are attempting to validate new spec tests in PyMongo.
247+
248+
## Making a Release
249+
250+
Follow the [Python Driver Release Process Wiki](https://wiki.corp.mongodb.com/display/DRIVERS/Python+Driver+Release+Process).

RELEASE.md

Lines changed: 0 additions & 109 deletions
This file was deleted.

bson/tz_util.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ def __init__(self, offset: Union[float, timedelta], name: str) -> None:
3939
def __getinitargs__(self) -> Tuple[timedelta, str]:
4040
return self.__offset, self.__name
4141

42+
def __repr__(self) -> str:
43+
return f"{self.__class__.__name__}({self.__offset!r}, {self.__name!r})"
44+
4245
def utcoffset(self, dt: Optional[datetime]) -> timedelta:
4346
return self.__offset
4447

doc/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ PyMongo 4.9 brings a number of improvements including:
3030
:class:`~pymongo.operations.DeleteOne`, and
3131
:class:`~pymongo.operations.DeleteMany` operations, so
3232
they can be used in the new :meth:`~pymongo.mongo_client.MongoClient.bulk_write`.
33+
- Added :func:`repr` support to :class:`bson.tz_util.FixedOffset`.
3334

3435
Issues Resolved
3536
...............

test/auth_oidc/test_auth_oidc.py

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,7 @@
4040
from pymongo.errors import AutoReconnect, ConfigurationError, OperationFailure
4141
from pymongo.hello import HelloCompat
4242
from pymongo.operations import InsertOne
43-
from pymongo.synchronous.auth_oidc import (
44-
OIDCCallback,
45-
OIDCCallbackContext,
46-
OIDCCallbackResult,
47-
)
43+
from pymongo.synchronous.auth_oidc import OIDCCallback, OIDCCallbackContext, OIDCCallbackResult
4844
from pymongo.uri_parser import parse_uri
4945

5046
ROOT = Path(__file__).parent.parent.resolve()
@@ -1019,6 +1015,51 @@ def fetch(self, _):
10191015
# Close the client.
10201016
client.close()
10211017

1018+
def test_4_4_speculative_authentication_should_be_ignored_on_reauthentication(self):
1019+
# Create an OIDC configured client that can listen for `SaslStart` commands.
1020+
listener = EventListener()
1021+
client = self.create_client(event_listeners=[listener])
1022+
1023+
# Preload the *Client Cache* with a valid access token to enforce Speculative Authentication.
1024+
client2 = self.create_client()
1025+
client2.test.test.find_one()
1026+
client.options.pool_options._credentials.cache.data = (
1027+
client2.options.pool_options._credentials.cache.data
1028+
)
1029+
client2.close()
1030+
self.request_called = 0
1031+
1032+
# Perform an `insert` operation that succeeds.
1033+
client.test.test.insert_one({})
1034+
1035+
# Assert that the callback was not called.
1036+
self.assertEqual(self.request_called, 0)
1037+
1038+
# Assert there were no `SaslStart` commands executed.
1039+
assert not any(
1040+
event.command_name.lower() == "saslstart" for event in listener.started_events
1041+
)
1042+
listener.reset()
1043+
1044+
# Set a fail point for `insert` commands of the form:
1045+
with self.fail_point(
1046+
{
1047+
"mode": {"times": 1},
1048+
"data": {"failCommands": ["insert"], "errorCode": 391},
1049+
}
1050+
):
1051+
# Perform an `insert` operation that succeeds.
1052+
client.test.test.insert_one({})
1053+
1054+
# Assert that the callback was called once.
1055+
self.assertEqual(self.request_called, 1)
1056+
1057+
# Assert there were `SaslStart` commands executed.
1058+
assert any(event.command_name.lower() == "saslstart" for event in listener.started_events)
1059+
1060+
# Close the client.
1061+
client.close()
1062+
10221063
def test_5_1_azure_with_no_username(self):
10231064
if ENVIRON != "azure":
10241065
raise unittest.SkipTest("Test is only supported on Azure")

test/test_bson.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1019,6 +1019,10 @@ def test_tzinfo(self):
10191019
tz = FixedOffset(42, "forty-two")
10201020
self.assertRaises(ValueError, CodecOptions, tzinfo=tz)
10211021
self.assertEqual(tz, CodecOptions(tz_aware=True, tzinfo=tz).tzinfo)
1022+
self.assertEqual(repr(tz), "FixedOffset(datetime.timedelta(seconds=2520), 'forty-two')")
1023+
self.assertEqual(
1024+
repr(eval(repr(tz))), "FixedOffset(datetime.timedelta(seconds=2520), 'forty-two')"
1025+
)
10221026

10231027
def test_codec_options_repr(self):
10241028
r = (

0 commit comments

Comments
 (0)