Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PYTHON-3490 CMAP connection establishment failure tests #1160

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
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
Prev Previous commit
PYTHON-3490 Fix test_5_check_out_fails_auth_error, message is optional
  • Loading branch information
ShaneHarvey committed Feb 23, 2023
commit 47a394097da372a5d0981c6958931cbf34fa9385
13 changes: 8 additions & 5 deletions test/test_cmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,10 @@ def check_events(self, events, ignore):
self.fail("missing events: %r" % (events[len(actual_events) :],))

def check_error(self, actual, expected):
message = expected.pop("message")
message = expected.pop("message", "")
self.check_object(actual, expected)
self.assertIn(message, str(actual))
if message:
self.assertIn(message, str(actual))

def _set_fail_point(self, client, command_args):
cmd = SON([("configureFailPoint", "failCommand")])
Expand Down Expand Up @@ -406,9 +407,11 @@ def test_5_check_out_fails_auth_error(self):
self.assertIsInstance(listener.events[2], ConnectionCheckOutStartedEvent)
self.assertIsInstance(listener.events[3], ConnectionCreatedEvent)
# Error happens here.
self.assertIsInstance(listener.events[4], ConnectionClosedEvent)
self.assertIsInstance(listener.events[5], ConnectionCheckOutFailedEvent)
self.assertEqual(listener.events[5].reason, ConnectionCheckOutFailedReason.CONN_ERROR)
self.assertIsInstance(listener.events[4], PoolClearedEvent)
self.assertIsInstance(listener.events[5], ConnectionClosedEvent)
self.assertEqual(listener.events[5].reason, ConnectionClosedReason.ERROR)
self.assertIsInstance(listener.events[6], ConnectionCheckOutFailedEvent)
self.assertEqual(listener.events[6].reason, ConnectionCheckOutFailedReason.CONN_ERROR)

#
# Extra non-spec tests
Expand Down