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-2806 Fix test_aggregate_raw_transaction #673

Merged
merged 1 commit into from Jul 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 10 additions & 3 deletions test/test_cursor.py
Expand Up @@ -1483,10 +1483,13 @@ def test_find_raw_transaction(self):
session=session).sort('_id'))
cmd = listener.results['started'][0]
self.assertEqual(cmd.command_name, 'find')
self.assertEqual(cmd.command['$clusterTime'],
decode_all(session.cluster_time.raw)[0])
self.assertIn('$clusterTime', cmd.command)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we only care that $clusterTime was added to the outgoing command.

self.assertEqual(cmd.command['startTransaction'], True)
self.assertEqual(cmd.command['txnNumber'], 1)
# Ensure we update $clusterTime from the command response.
last_cmd = listener.results['succeeded'][-1]
self.assertEqual(last_cmd.reply['$clusterTime']['clusterTime'],
session.cluster_time['clusterTime'])
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we check that the most recent command response using the session is equal to the session's $clusterTime. I used ['clusterTime'] to workaround the RawBSONDocument issue; ['clusterTime'] will always be a bson Timestamp.


self.assertEqual(1, len(batches))
self.assertEqual(docs, decode_all(batches[0]))
Expand Down Expand Up @@ -1677,9 +1680,13 @@ def test_aggregate_raw_transaction(self):
[{'$sort': {'_id': 1}}], session=session))
cmd = listener.results['started'][0]
self.assertEqual(cmd.command_name, 'aggregate')
self.assertEqual(cmd.command['$clusterTime'], session.cluster_time)
self.assertIn('$clusterTime', cmd.command)
self.assertEqual(cmd.command['startTransaction'], True)
self.assertEqual(cmd.command['txnNumber'], 1)
# Ensure we update $clusterTime from the command response.
last_cmd = listener.results['succeeded'][-1]
self.assertEqual(last_cmd.reply['$clusterTime']['clusterTime'],
session.cluster_time['clusterTime'])
self.assertEqual(1, len(batches))
self.assertEqual(docs, decode_all(batches[0]))

Expand Down