Skip to content

Unskip tests that require replica set #48

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

Merged
merged 2 commits into from
Dec 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
uses: supercharge/[email protected]
with:
mongodb-version: ${{ matrix.mongodb-version }}
mongodb-replica-set: test-rs
# add caching to reduce bandwidth and save time
- uses: actions/cache@v2
with:
Expand Down
21 changes: 15 additions & 6 deletions pymongoexplain/explainable_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,26 @@ def watch(self, pipeline: Document = None, full_document: Document = None,
max_await_time_ms: int = None, batch_size: int = None,
collation=None, start_at_operation_time=None, session=None,
start_after=None):
change_stream_options = {"start_after":start_after,
"resume_after":resume_after,
"start_at_operation_time":start_at_operation_time,
"full_document":full_document}

change_stream_options = {}
if start_after:
change_stream_options["startAfter"] = start_after
if resume_after:
change_stream_options["resumeAfter"] = resume_after
if start_at_operation_time:
change_stream_options["startAtOperationTime"] = start_at_operation_time
if full_document:
change_stream_options["fullDocument"] = full_document

if pipeline is not None:
pipeline = [{"$changeStream": change_stream_options}]+pipeline
else:
pipeline = [{"$changeStream": change_stream_options}]

cursor_args = {}
if batch_size:
cursor_args["batchSize"] = batch_size
command = AggregateCommand(self.collection, pipeline,
{"batch_size":batch_size},
cursor_args,
{"collation":collation, "max_await_time_ms":
max_await_time_ms})
return self._explain_command(command)
Expand Down
5 changes: 2 additions & 3 deletions test/test_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,14 @@ def test_delete_many(self):
last_cmd_payload = self.explain.last_cmd_payload
self._compare_command_dicts(last_cmd_payload, last_logger_payload)

@unittest.skip("Travis does not have replica sets set up yet")
def test_watch(self):
res = self.explain.watch()
self.assertIn("queryPlanner", res["stages"][0]["$cursor"])
self.collection.watch(pipeline=[{"$project": {"tags": 1}}],
batch_size=10, full_document="updateLookup")
batch_size=10, full_document="updateLookup")
last_logger_payload = self.logger.cmd_payload
res = self.explain.watch(pipeline=[{"$project": {"tags": 1}}],
batch_size=10, full_document="updateLookup")
batch_size=10, full_document="updateLookup")
self.assertIn("queryPlanner", res["stages"][0]["$cursor"])
last_cmd_payload = self.explain.last_cmd_payload
self._compare_command_dicts(last_cmd_payload, last_logger_payload)
Expand Down