Skip to content

Commit 42aa78f

Browse files
authored
PLM-191: Fix ensure_collection collections on source only (#129)
1 parent 71b3917 commit 42aa78f

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

tests/test_collections.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@
1111
from bson.decimal128 import Decimal128
1212

1313

14-
def ensure_collection(source: MongoClient, target: MongoClient, db: str, coll: str, **kwargs):
15-
"""Create a collection in the source and target MongoDB."""
14+
def ensure_collection(source: MongoClient, db: str, coll: str, **kwargs):
15+
"""Create a collection in the source MongoDB."""
1616
source[db].drop_collection(coll)
17-
target[db].drop_collection(coll)
1817
source[db].create_collection(coll, **kwargs)
19-
target[db].create_collection(coll, **kwargs)
2018

2119

2220
@pytest.mark.parametrize("phase", [Runner.Phase.APPLY, Runner.Phase.CLONE])
@@ -192,7 +190,7 @@ def test_create_with_validation(t: Testing, phase: Runner.Phase):
192190

193191
@pytest.mark.parametrize("phase", [Runner.Phase.APPLY, Runner.Phase.CLONE])
194192
def test_drop_collection(t: Testing, phase: Runner.Phase):
195-
ensure_collection(t.source, t.target, "db_1", "coll_1")
193+
ensure_collection(t.source, "db_1", "coll_1")
196194

197195
with t.run(phase):
198196
t.source["db_1"].drop_collection("coll_1")
@@ -213,10 +211,9 @@ def test_drop_capped_collection(t: Testing, phase: Runner.Phase):
213211

214212
@pytest.mark.parametrize("phase", [Runner.Phase.APPLY, Runner.Phase.CLONE])
215213
def test_drop_view(t: Testing, phase: Runner.Phase):
216-
ensure_collection(t.source, t.target, "db_1", "coll_1")
214+
ensure_collection(t.source, "db_1", "coll_1")
217215
ensure_collection(
218216
t.source,
219-
t.target,
220217
"db_1",
221218
"view_1",
222219
viewOn="coll_1",
@@ -232,10 +229,9 @@ def test_drop_view(t: Testing, phase: Runner.Phase):
232229

233230
@pytest.mark.parametrize("phase", [Runner.Phase.APPLY, Runner.Phase.CLONE])
234231
def test_drop_view_source_collection(t: Testing, phase: Runner.Phase):
235-
ensure_collection(t.source, t.target, "db_1", "coll_1")
232+
ensure_collection(t.source, "db_1", "coll_1")
236233
ensure_collection(
237234
t.source,
238-
t.target,
239235
"db_1",
240236
"view_1",
241237
viewOn="coll_1",
@@ -294,9 +290,9 @@ def test_modify_clustered_ttl_ignored(t: Testing, phase: Runner.Phase):
294290

295291
@pytest.mark.parametrize("phase", [Runner.Phase.APPLY, Runner.Phase.CLONE])
296292
def test_modify_capped_size(t: Testing, phase: Runner.Phase):
297-
ensure_collection(t.source, t.target, "db_1", "coll_1", capped=True, size=1111, max=222)
298-
ensure_collection(t.source, t.target, "db_1", "coll_2", capped=True, size=1111, max=222)
299-
ensure_collection(t.source, t.target, "db_1", "coll_3", capped=True, size=1111, max=222)
293+
ensure_collection(t.source, "db_1", "coll_1", capped=True, size=1111, max=222)
294+
ensure_collection(t.source, "db_1", "coll_2", capped=True, size=1111, max=222)
295+
ensure_collection(t.source, "db_1", "coll_3", capped=True, size=1111, max=222)
300296

301297
with t.run(phase):
302298
t.source["db_1"].command({"collMod": "coll_1", "cappedSize": 3333, "cappedMax": 444})
@@ -431,7 +427,7 @@ def test_modify_validation_unset(t: Testing, phase: Runner.Phase):
431427

432428
@pytest.mark.parametrize("phase", [Runner.Phase.APPLY, Runner.Phase.CLONE])
433429
def test_modify_capped_size_with_validation(t: Testing, phase: Runner.Phase):
434-
ensure_collection(t.source, t.target, "db_1", "coll_1", capped=True, size=1111)
430+
ensure_collection(t.source, "db_1", "coll_1", capped=True, size=1111)
435431

436432
with t.run(phase):
437433
t.source["db_1"].command(

0 commit comments

Comments
 (0)