Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import pytest

from documentdb_tests.framework.assertions import assertSuccessPartial
from documentdb_tests.framework.assertions import assertChangeStreamEvent
from documentdb_tests.framework.executor import execute_command

pytestmark = pytest.mark.smoke
Expand All @@ -28,19 +28,18 @@ def test_smoke_changeStream_createIndexes(collection):
"cursor": {},
},
)

cursor_id = result["cursor"]["id"]
# Extract the cursor id defensively: if opening the change stream errored,
# fall back to 0 so the getMore + single assertion below report the failure
# cleanly instead of a TypeError from subscripting an exception object.
cursor_id = result.get("cursor", {}).get("id", 0) if isinstance(result, dict) else 0

execute_command(
collection,
{"createIndexes": collection.name, "indexes": [{"key": {"x": 1}, "name": "x_1"}]},
)

result = execute_command(collection, {"getMore": cursor_id, "collection": collection.name})
result = result["cursor"]["nextBatch"][0]

expected = {
"operationType": "createIndexes",
"ns": {"db": collection.database.name, "coll": collection.name},
}
assertSuccessPartial(result, expected, msg="Should support createIndexes change stream event")
# An empty batch means the expanded createIndexes event was not emitted; fail
# with a clear message instead of an IndexError when indexing nextBatch[0].
assertChangeStreamEvent(result, msg="Should support createIndexes change stream event")
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import pytest

from documentdb_tests.framework.assertions import assertSuccessPartial
from documentdb_tests.framework.assertions import assertChangeStreamEvent
from documentdb_tests.framework.executor import execute_command

pytestmark = pytest.mark.smoke
Expand All @@ -29,17 +29,15 @@ def test_smoke_changeStream_dropIndexes(collection):
"cursor": {},
},
)

cursor_id = result["cursor"]["id"]
# Extract the cursor id defensively: if opening the change stream errored,
# fall back to 0 so the getMore + single assertion below report the failure
# cleanly instead of a TypeError from subscripting an exception object.
cursor_id = result.get("cursor", {}).get("id", 0) if isinstance(result, dict) else 0

execute_command(collection, {"dropIndexes": collection.name, "index": "x_1"})

result = execute_command(collection, {"getMore": cursor_id, "collection": collection.name})

result = result["cursor"]["nextBatch"][0]

expected = {
"operationType": "dropIndexes",
"ns": {"db": collection.database.name, "coll": collection.name},
}
assertSuccessPartial(result, expected, msg="Should support dropIndexes change stream event")
# An empty batch means the expanded dropIndexes event was not emitted; fail
# with a clear message instead of an IndexError when indexing nextBatch[0].
assertChangeStreamEvent(result, msg="Should support dropIndexes change stream event")
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import pytest

from documentdb_tests.framework.assertions import assertSuccessPartial
from documentdb_tests.framework.assertions import assertChangeStreamEvent
from documentdb_tests.framework.executor import execute_command

pytestmark = pytest.mark.smoke
Expand All @@ -28,16 +28,15 @@ def test_smoke_changeStream_modify(collection):
"cursor": {},
},
)

cursor_id = result["cursor"]["id"]
# Extract the cursor id defensively: if opening the change stream errored,
# fall back to 0 so the getMore + single assertion below report the failure
# cleanly instead of a TypeError from subscripting an exception object.
cursor_id = result.get("cursor", {}).get("id", 0) if isinstance(result, dict) else 0

execute_command(collection, {"collMod": collection.name, "validator": {"x": {"$type": "int"}}})

result = execute_command(collection, {"getMore": cursor_id, "collection": collection.name})
result = result["cursor"]["nextBatch"][0]

expected = {
"operationType": "modify",
"ns": {"db": collection.database.name, "coll": collection.name},
}
assertSuccessPartial(result, expected, msg="Should support modify change stream event")
# An empty batch means the expanded modify event was not emitted; fail with a
# clear message instead of an IndexError when indexing nextBatch[0].
assertChangeStreamEvent(result, msg="Should support modify change stream event")
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import pytest

from documentdb_tests.framework.assertions import assertSuccessPartial
from documentdb_tests.framework.assertions import assertCommandSupported
from documentdb_tests.framework.executor import execute_command

pytestmark = pytest.mark.smoke
Expand All @@ -17,10 +17,13 @@ def test_smoke_getMore(collection):
collection.insert_many([{"_id": 1, "value": 1}, {"_id": 2, "value": 2}, {"_id": 3, "value": 3}])

initial_result = execute_command(collection, {"find": collection.name, "batchSize": 2})

cursor_id = initial_result["cursor"]["id"]
# Extract the cursor id defensively: if the setup find errored (returning an
# exception rather than a dict) fall back to 0 so getMore reports the failure
# cleanly, instead of a TypeError from subscripting an exception object.
cursor_id = 0
if isinstance(initial_result, dict):
cursor_id = initial_result.get("cursor", {}).get("id", 0)

result = execute_command(collection, {"getMore": cursor_id, "collection": collection.name})

expected = {"ok": 1.0}
assertSuccessPartial(result, expected, msg="Should support getMore command")
assertCommandSupported(result, msg="Should support getMore command")
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import pytest

from documentdb_tests.framework.assertions import assertSuccessPartial
from documentdb_tests.framework.assertions import assertCommandSupported
from documentdb_tests.framework.executor import execute_command

pytestmark = pytest.mark.smoke
Expand All @@ -17,10 +17,13 @@ def test_smoke_killCursors(collection):
collection.insert_many([{"_id": 1, "value": 1}, {"_id": 2, "value": 2}])

initial_result = execute_command(collection, {"find": collection.name, "batchSize": 1})

cursor_id = initial_result["cursor"]["id"]
# Extract the cursor id defensively: if the setup find errored (returning an
# exception rather than a dict) fall back to 0 so killCursors reports the
# failure cleanly, instead of a TypeError from subscripting an exception.
cursor_id = 0
if isinstance(initial_result, dict):
cursor_id = initial_result.get("cursor", {}).get("id", 0)

result = execute_command(collection, {"killCursors": collection.name, "cursors": [cursor_id]})

expected = {"ok": 1.0}
assertSuccessPartial(result, expected, msg="Should support killCursors command")
assertCommandSupported(result, msg="Should support killCursors command")
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import pytest

from documentdb_tests.framework.assertions import assertSuccessPartial
from documentdb_tests.framework.assertions import assertCommandSupported
from documentdb_tests.framework.executor import execute_command

pytestmark = pytest.mark.smoke
Expand All @@ -21,5 +21,4 @@ def test_smoke_createIndexes(collection):
{"createIndexes": collection.name, "indexes": [{"key": {"name": 1}, "name": "name_1"}]},
)

expected = {"ok": 1.0}
assertSuccessPartial(result, expected, msg="Should support createIndexes command")
assertCommandSupported(result, msg="Should support createIndexes command")
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import pytest

from documentdb_tests.framework.assertions import assertSuccessPartial
from documentdb_tests.framework.assertions import assertCommandSupported
from documentdb_tests.framework.executor import execute_command

pytestmark = pytest.mark.smoke
Expand All @@ -22,10 +22,4 @@ def test_smoke_indexes_hidden(collection):
},
)

expected = {
"numIndexesBefore": 1,
"numIndexesAfter": 2,
"createdCollectionAutomatically": True,
"ok": 1.0,
}
assertSuccessPartial(result, expected, msg="Should support hidden index property")
assertCommandSupported(result, msg="Should support hidden index property")
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import pytest

from documentdb_tests.framework.assertions import assertSuccessPartial
from documentdb_tests.framework.assertions import assertCommandSupported
from documentdb_tests.framework.executor import execute_command

pytestmark = pytest.mark.smoke
Expand All @@ -28,10 +28,4 @@ def test_smoke_indexes_partial(collection):
},
)

expected = {
"numIndexesBefore": 1,
"numIndexesAfter": 2,
"createdCollectionAutomatically": True,
"ok": 1.0,
}
assertSuccessPartial(result, expected, msg="Should support partial index property")
assertCommandSupported(result, msg="Should support partial index property")
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import pytest

from documentdb_tests.framework.assertions import assertSuccessPartial
from documentdb_tests.framework.assertions import assertCommandSupported
from documentdb_tests.framework.executor import execute_command

pytestmark = pytest.mark.smoke
Expand All @@ -22,10 +22,4 @@ def test_smoke_indexes_sparse(collection):
},
)

expected = {
"numIndexesBefore": 1,
"numIndexesAfter": 2,
"createdCollectionAutomatically": True,
"ok": 1.0,
}
assertSuccessPartial(result, expected, msg="Should support sparse index property")
assertCommandSupported(result, msg="Should support sparse index property")
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import pytest

from documentdb_tests.framework.assertions import assertSuccessPartial
from documentdb_tests.framework.assertions import assertCommandSupported
from documentdb_tests.framework.executor import execute_command

pytestmark = pytest.mark.smoke
Expand All @@ -24,10 +24,4 @@ def test_smoke_indexes_ttl(collection):
},
)

expected = {
"numIndexesBefore": 1,
"numIndexesAfter": 2,
"createdCollectionAutomatically": True,
"ok": 1.0,
}
assertSuccessPartial(result, expected, msg="Should support ttl index property")
assertCommandSupported(result, msg="Should support ttl index property")
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import pytest

from documentdb_tests.framework.assertions import assertSuccessPartial
from documentdb_tests.framework.assertions import assertCommandSupported
from documentdb_tests.framework.executor import execute_command

pytestmark = pytest.mark.smoke
Expand All @@ -22,10 +22,4 @@ def test_smoke_indexes_unique(collection):
},
)

expected = {
"numIndexesBefore": 1,
"numIndexesAfter": 2,
"createdCollectionAutomatically": True,
"ok": 1.0,
}
assertSuccessPartial(result, expected, msg="Should support unique index property")
assertCommandSupported(result, msg="Should support unique index property")
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import pytest

from documentdb_tests.framework.assertions import assertSuccessPartial
from documentdb_tests.framework.assertions import assertCommandSupported
from documentdb_tests.framework.executor import execute_command

pytestmark = pytest.mark.smoke
Expand All @@ -22,10 +22,4 @@ def test_smoke_indexes_compound(collection):
},
)

expected = {
"numIndexesBefore": 1,
"numIndexesAfter": 2,
"createdCollectionAutomatically": True,
"ok": 1.0,
}
assertSuccessPartial(result, expected, msg="Should support compound index type")
assertCommandSupported(result, msg="Should support compound index type")
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import pytest

from documentdb_tests.framework.assertions import assertSuccessPartial
from documentdb_tests.framework.assertions import assertCommandSupported
from documentdb_tests.framework.executor import execute_command

pytestmark = pytest.mark.smoke
Expand All @@ -22,10 +22,4 @@ def test_smoke_indexes_geospatial(collection):
},
)

expected = {
"numIndexesBefore": 1,
"numIndexesAfter": 2,
"createdCollectionAutomatically": True,
"ok": 1.0,
}
assertSuccessPartial(result, expected, msg="Should support geospatial index type")
assertCommandSupported(result, msg="Should support geospatial index type")
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import pytest

from documentdb_tests.framework.assertions import assertSuccessPartial
from documentdb_tests.framework.assertions import assertCommandSupported
from documentdb_tests.framework.executor import execute_command

pytestmark = pytest.mark.smoke
Expand All @@ -26,10 +26,4 @@ def test_smoke_indexes_multikey(collection):
},
)

expected = {
"numIndexesBefore": 1,
"numIndexesAfter": 2,
"createdCollectionAutomatically": False,
"ok": 1.0,
}
assertSuccessPartial(result, expected, msg="Should support multikey index type")
assertCommandSupported(result, msg="Should support multikey index type")
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import pytest

from documentdb_tests.framework.assertions import assertSuccessPartial
from documentdb_tests.framework.assertions import assertCommandSupported
from documentdb_tests.framework.executor import execute_command

pytestmark = pytest.mark.smoke
Expand All @@ -19,10 +19,4 @@ def test_smoke_indexes_single(collection):
{"createIndexes": collection.name, "indexes": [{"key": {"name": 1}, "name": "name_1"}]},
)

expected = {
"numIndexesBefore": 1,
"numIndexesAfter": 2,
"createdCollectionAutomatically": True,
"ok": 1.0,
}
assertSuccessPartial(result, expected, msg="Should support single field index type")
assertCommandSupported(result, msg="Should support single field index type")
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import pytest

from documentdb_tests.framework.assertions import assertSuccessPartial
from documentdb_tests.framework.assertions import assertCommandSupported
from documentdb_tests.framework.executor import execute_command

pytestmark = pytest.mark.smoke
Expand All @@ -22,10 +22,4 @@ def test_smoke_indexes_text(collection):
},
)

expected = {
"numIndexesBefore": 1,
"numIndexesAfter": 2,
"createdCollectionAutomatically": True,
"ok": 1.0,
}
assertSuccessPartial(result, expected, msg="Should support text index type")
assertCommandSupported(result, msg="Should support text index type")
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import pytest

from documentdb_tests.framework.assertions import assertSuccess
from documentdb_tests.framework.assertions import assertCommandSupported
from documentdb_tests.framework.executor import execute_command

pytestmark = pytest.mark.smoke
Expand All @@ -33,5 +33,4 @@ def test_smoke_accumulator_maxN(collection):
},
)

expected = [{"_id": "A", "maxTwo": [30, 20]}]
assertSuccess(result, expected, msg="Should support $maxN accumulator")
assertCommandSupported(result, msg="Should support $maxN accumulator")
Loading
Loading