Skip to content

Commit 4514ef3

Browse files
authored
Unskip tests that require replica set (#48)
1 parent fe71b2d commit 4514ef3

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ jobs:
2525
uses: supercharge/[email protected]
2626
with:
2727
mongodb-version: ${{ matrix.mongodb-version }}
28+
mongodb-replica-set: test-rs
2829
# add caching to reduce bandwidth and save time
2930
- uses: actions/cache@v2
3031
with:

pymongoexplain/explainable_collection.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,26 @@ def watch(self, pipeline: Document = None, full_document: Document = None,
100100
max_await_time_ms: int = None, batch_size: int = None,
101101
collation=None, start_at_operation_time=None, session=None,
102102
start_after=None):
103-
change_stream_options = {"start_after":start_after,
104-
"resume_after":resume_after,
105-
"start_at_operation_time":start_at_operation_time,
106-
"full_document":full_document}
103+
104+
change_stream_options = {}
105+
if start_after:
106+
change_stream_options["startAfter"] = start_after
107+
if resume_after:
108+
change_stream_options["resumeAfter"] = resume_after
109+
if start_at_operation_time:
110+
change_stream_options["startAtOperationTime"] = start_at_operation_time
111+
if full_document:
112+
change_stream_options["fullDocument"] = full_document
113+
107114
if pipeline is not None:
108115
pipeline = [{"$changeStream": change_stream_options}]+pipeline
109116
else:
110117
pipeline = [{"$changeStream": change_stream_options}]
111-
118+
cursor_args = {}
119+
if batch_size:
120+
cursor_args["batchSize"] = batch_size
112121
command = AggregateCommand(self.collection, pipeline,
113-
{"batch_size":batch_size},
122+
cursor_args,
114123
{"collation":collation, "max_await_time_ms":
115124
max_await_time_ms})
116125
return self._explain_command(command)

test/test_collection.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,14 @@ def test_delete_many(self):
114114
last_cmd_payload = self.explain.last_cmd_payload
115115
self._compare_command_dicts(last_cmd_payload, last_logger_payload)
116116

117-
@unittest.skip("Travis does not have replica sets set up yet")
118117
def test_watch(self):
119118
res = self.explain.watch()
120119
self.assertIn("queryPlanner", res["stages"][0]["$cursor"])
121120
self.collection.watch(pipeline=[{"$project": {"tags": 1}}],
122-
batch_size=10, full_document="updateLookup")
121+
batch_size=10, full_document="updateLookup")
123122
last_logger_payload = self.logger.cmd_payload
124123
res = self.explain.watch(pipeline=[{"$project": {"tags": 1}}],
125-
batch_size=10, full_document="updateLookup")
124+
batch_size=10, full_document="updateLookup")
126125
self.assertIn("queryPlanner", res["stages"][0]["$cursor"])
127126
last_cmd_payload = self.explain.last_cmd_payload
128127
self._compare_command_dicts(last_cmd_payload, last_logger_payload)

0 commit comments

Comments
 (0)