diff --git a/documentdb_tests/compatibility/tests/changeStreams/createIndexes/test_smoke_changeStream_createIndexes.py b/documentdb_tests/compatibility/tests/changeStreams/createIndexes/test_smoke_changeStream_createIndexes.py index 44041944c..4e1f5cccc 100644 --- a/documentdb_tests/compatibility/tests/changeStreams/createIndexes/test_smoke_changeStream_createIndexes.py +++ b/documentdb_tests/compatibility/tests/changeStreams/createIndexes/test_smoke_changeStream_createIndexes.py @@ -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 @@ -28,8 +28,10 @@ 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, @@ -37,10 +39,7 @@ def test_smoke_changeStream_createIndexes(collection): ) 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") diff --git a/documentdb_tests/compatibility/tests/changeStreams/dropIndexes/test_smoke_changeStream_dropIndexes.py b/documentdb_tests/compatibility/tests/changeStreams/dropIndexes/test_smoke_changeStream_dropIndexes.py index cbac28e18..635ba9a4e 100644 --- a/documentdb_tests/compatibility/tests/changeStreams/dropIndexes/test_smoke_changeStream_dropIndexes.py +++ b/documentdb_tests/compatibility/tests/changeStreams/dropIndexes/test_smoke_changeStream_dropIndexes.py @@ -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 @@ -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") diff --git a/documentdb_tests/compatibility/tests/changeStreams/modify/test_smoke_changeStream_modify.py b/documentdb_tests/compatibility/tests/changeStreams/modify/test_smoke_changeStream_modify.py index 0a98ca8ee..daae9ee2e 100644 --- a/documentdb_tests/compatibility/tests/changeStreams/modify/test_smoke_changeStream_modify.py +++ b/documentdb_tests/compatibility/tests/changeStreams/modify/test_smoke_changeStream_modify.py @@ -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 @@ -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") diff --git a/documentdb_tests/compatibility/tests/core/cursors/commands/getMore/test_smoke_getMore.py b/documentdb_tests/compatibility/tests/core/cursors/commands/getMore/test_smoke_getMore.py index 7c568ffd7..7ce8a168a 100644 --- a/documentdb_tests/compatibility/tests/core/cursors/commands/getMore/test_smoke_getMore.py +++ b/documentdb_tests/compatibility/tests/core/cursors/commands/getMore/test_smoke_getMore.py @@ -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 @@ -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") diff --git a/documentdb_tests/compatibility/tests/core/cursors/commands/killCursors/test_smoke_killCursors.py b/documentdb_tests/compatibility/tests/core/cursors/commands/killCursors/test_smoke_killCursors.py index 1cf50d359..189e65744 100644 --- a/documentdb_tests/compatibility/tests/core/cursors/commands/killCursors/test_smoke_killCursors.py +++ b/documentdb_tests/compatibility/tests/core/cursors/commands/killCursors/test_smoke_killCursors.py @@ -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 @@ -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") diff --git a/documentdb_tests/compatibility/tests/core/indexes/commands/createIndexes/test_smoke_createIndexes.py b/documentdb_tests/compatibility/tests/core/indexes/commands/createIndexes/test_smoke_createIndexes.py index cbbc654c2..6cf3eb8ed 100644 --- a/documentdb_tests/compatibility/tests/core/indexes/commands/createIndexes/test_smoke_createIndexes.py +++ b/documentdb_tests/compatibility/tests/core/indexes/commands/createIndexes/test_smoke_createIndexes.py @@ -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 @@ -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") diff --git a/documentdb_tests/compatibility/tests/core/indexes/properties/hidden/test_smoke_hidden.py b/documentdb_tests/compatibility/tests/core/indexes/properties/hidden/test_smoke_hidden.py index 753f1ab4b..d0cc6f49c 100644 --- a/documentdb_tests/compatibility/tests/core/indexes/properties/hidden/test_smoke_hidden.py +++ b/documentdb_tests/compatibility/tests/core/indexes/properties/hidden/test_smoke_hidden.py @@ -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 @@ -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") diff --git a/documentdb_tests/compatibility/tests/core/indexes/properties/partial/test_smoke_partial.py b/documentdb_tests/compatibility/tests/core/indexes/properties/partial/test_smoke_partial.py index 608755156..7ed911555 100644 --- a/documentdb_tests/compatibility/tests/core/indexes/properties/partial/test_smoke_partial.py +++ b/documentdb_tests/compatibility/tests/core/indexes/properties/partial/test_smoke_partial.py @@ -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 @@ -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") diff --git a/documentdb_tests/compatibility/tests/core/indexes/properties/sparse/test_smoke_sparse.py b/documentdb_tests/compatibility/tests/core/indexes/properties/sparse/test_smoke_sparse.py index c6df27358..7d6872d6e 100644 --- a/documentdb_tests/compatibility/tests/core/indexes/properties/sparse/test_smoke_sparse.py +++ b/documentdb_tests/compatibility/tests/core/indexes/properties/sparse/test_smoke_sparse.py @@ -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 @@ -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") diff --git a/documentdb_tests/compatibility/tests/core/indexes/properties/ttl/test_smoke_ttl.py b/documentdb_tests/compatibility/tests/core/indexes/properties/ttl/test_smoke_ttl.py index 1e23e0768..7c2a1647e 100644 --- a/documentdb_tests/compatibility/tests/core/indexes/properties/ttl/test_smoke_ttl.py +++ b/documentdb_tests/compatibility/tests/core/indexes/properties/ttl/test_smoke_ttl.py @@ -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 @@ -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") diff --git a/documentdb_tests/compatibility/tests/core/indexes/properties/unique/test_smoke_unique.py b/documentdb_tests/compatibility/tests/core/indexes/properties/unique/test_smoke_unique.py index 242c3b30d..7b214638e 100644 --- a/documentdb_tests/compatibility/tests/core/indexes/properties/unique/test_smoke_unique.py +++ b/documentdb_tests/compatibility/tests/core/indexes/properties/unique/test_smoke_unique.py @@ -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 @@ -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") diff --git a/documentdb_tests/compatibility/tests/core/indexes/types/compound/test_smoke_compound.py b/documentdb_tests/compatibility/tests/core/indexes/types/compound/test_smoke_compound.py index 5dd5aebb6..a4df5cc8e 100644 --- a/documentdb_tests/compatibility/tests/core/indexes/types/compound/test_smoke_compound.py +++ b/documentdb_tests/compatibility/tests/core/indexes/types/compound/test_smoke_compound.py @@ -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 @@ -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") diff --git a/documentdb_tests/compatibility/tests/core/indexes/types/geospatial/test_smoke_geospatial.py b/documentdb_tests/compatibility/tests/core/indexes/types/geospatial/test_smoke_geospatial.py index ac4ad9e51..1c6798620 100644 --- a/documentdb_tests/compatibility/tests/core/indexes/types/geospatial/test_smoke_geospatial.py +++ b/documentdb_tests/compatibility/tests/core/indexes/types/geospatial/test_smoke_geospatial.py @@ -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 @@ -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") diff --git a/documentdb_tests/compatibility/tests/core/indexes/types/multikey/test_smoke_multikey.py b/documentdb_tests/compatibility/tests/core/indexes/types/multikey/test_smoke_multikey.py index d5fd56494..f3f76d0be 100644 --- a/documentdb_tests/compatibility/tests/core/indexes/types/multikey/test_smoke_multikey.py +++ b/documentdb_tests/compatibility/tests/core/indexes/types/multikey/test_smoke_multikey.py @@ -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 @@ -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") diff --git a/documentdb_tests/compatibility/tests/core/indexes/types/single/test_smoke_single.py b/documentdb_tests/compatibility/tests/core/indexes/types/single/test_smoke_single.py index d5030ef38..ef5c8030a 100644 --- a/documentdb_tests/compatibility/tests/core/indexes/types/single/test_smoke_single.py +++ b/documentdb_tests/compatibility/tests/core/indexes/types/single/test_smoke_single.py @@ -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 @@ -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") diff --git a/documentdb_tests/compatibility/tests/core/indexes/types/text/test_smoke_indexes_text.py b/documentdb_tests/compatibility/tests/core/indexes/types/text/test_smoke_indexes_text.py index e14852199..2cbdf50c9 100644 --- a/documentdb_tests/compatibility/tests/core/indexes/types/text/test_smoke_indexes_text.py +++ b/documentdb_tests/compatibility/tests/core/indexes/types/text/test_smoke_indexes_text.py @@ -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 @@ -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") diff --git a/documentdb_tests/compatibility/tests/core/indexes/types/wildcard/test_smoke_wildcard.py b/documentdb_tests/compatibility/tests/core/indexes/types/wildcard/test_smoke_wildcard.py index 1bb742ecb..ba9636493 100644 --- a/documentdb_tests/compatibility/tests/core/indexes/types/wildcard/test_smoke_wildcard.py +++ b/documentdb_tests/compatibility/tests/core/indexes/types/wildcard/test_smoke_wildcard.py @@ -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 @@ -22,10 +22,4 @@ def test_smoke_indexes_wildcard(collection): }, ) - expected = { - "numIndexesBefore": 1, - "numIndexesAfter": 2, - "createdCollectionAutomatically": True, - "ok": 1.0, - } - assertSuccessPartial(result, expected, msg="Should support wildcard index type") + assertCommandSupported(result, msg="Should support wildcard index type") diff --git a/documentdb_tests/compatibility/tests/core/operator/accumulators/maxN/test_smoke_accumulator_maxN.py b/documentdb_tests/compatibility/tests/core/operator/accumulators/maxN/test_smoke_accumulator_maxN.py index 5fd69cb5d..528abff90 100644 --- a/documentdb_tests/compatibility/tests/core/operator/accumulators/maxN/test_smoke_accumulator_maxN.py +++ b/documentdb_tests/compatibility/tests/core/operator/accumulators/maxN/test_smoke_accumulator_maxN.py @@ -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 @@ -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") diff --git a/documentdb_tests/compatibility/tests/core/operator/accumulators/minN/test_smoke_accumulator_minN.py b/documentdb_tests/compatibility/tests/core/operator/accumulators/minN/test_smoke_accumulator_minN.py index 679426190..a058bbe3d 100644 --- a/documentdb_tests/compatibility/tests/core/operator/accumulators/minN/test_smoke_accumulator_minN.py +++ b/documentdb_tests/compatibility/tests/core/operator/accumulators/minN/test_smoke_accumulator_minN.py @@ -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 @@ -33,5 +33,4 @@ def test_smoke_accumulator_minN(collection): }, ) - expected = [{"_id": "A", "minTwo": [10, 20]}] - assertSuccess(result, expected, msg="Should support $minN accumulator") + assertCommandSupported(result, msg="Should support $minN accumulator") diff --git a/documentdb_tests/compatibility/tests/core/operator/expressions/array/maxN-array-element/test_smoke_expression_maxN-array-element.py b/documentdb_tests/compatibility/tests/core/operator/expressions/array/maxN-array-element/test_smoke_expression_maxN-array-element.py index 117b5afee..c02284b63 100644 --- a/documentdb_tests/compatibility/tests/core/operator/expressions/array/maxN-array-element/test_smoke_expression_maxN-array-element.py +++ b/documentdb_tests/compatibility/tests/core/operator/expressions/array/maxN-array-element/test_smoke_expression_maxN-array-element.py @@ -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 @@ -27,5 +27,4 @@ def test_smoke_expression_maxN_array_element(collection): }, ) - expected = [{"_id": 1, "maxTwo": [40, 30]}, {"_id": 2, "maxTwo": [35, 25]}] - assertSuccess(result, expected, msg="Should support $maxN-array-element expression") + assertCommandSupported(result, msg="Should support $maxN-array-element expression") diff --git a/documentdb_tests/compatibility/tests/core/operator/expressions/array/minN-array-element/test_smoke_expression_minN-array-element.py b/documentdb_tests/compatibility/tests/core/operator/expressions/array/minN-array-element/test_smoke_expression_minN-array-element.py index 2816c1cc4..401459973 100644 --- a/documentdb_tests/compatibility/tests/core/operator/expressions/array/minN-array-element/test_smoke_expression_minN-array-element.py +++ b/documentdb_tests/compatibility/tests/core/operator/expressions/array/minN-array-element/test_smoke_expression_minN-array-element.py @@ -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 @@ -27,5 +27,4 @@ def test_smoke_expression_minN_array_element(collection): }, ) - expected = [{"_id": 1, "minTwo": [10, 20]}, {"_id": 2, "minTwo": [5, 15]}] - assertSuccess(result, expected, msg="Should support $minN-array-element expression") + assertCommandSupported(result, msg="Should support $minN-array-element expression") diff --git a/documentdb_tests/compatibility/tests/core/operator/window/denseRank/test_smoke_window_denseRank.py b/documentdb_tests/compatibility/tests/core/operator/window/denseRank/test_smoke_window_denseRank.py index 42f43ef81..5bc18186f 100644 --- a/documentdb_tests/compatibility/tests/core/operator/window/denseRank/test_smoke_window_denseRank.py +++ b/documentdb_tests/compatibility/tests/core/operator/window/denseRank/test_smoke_window_denseRank.py @@ -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 @@ -40,10 +40,4 @@ def test_smoke_window_denseRank(collection): }, ) - expected = [ - {"_id": 1, "partition": "A", "score": 100, "rank": 1}, - {"_id": 2, "partition": "A", "score": 100, "rank": 1}, - {"_id": 3, "partition": "A", "score": 90, "rank": 2}, - {"_id": 4, "partition": "B", "score": 80, "rank": 1}, - ] - assertSuccess(result, expected, msg="Should support $denseRank window operator") + assertCommandSupported(result, msg="Should support $denseRank window operator") diff --git a/documentdb_tests/compatibility/tests/core/operator/window/documentNumber/test_smoke_window_documentNumber.py b/documentdb_tests/compatibility/tests/core/operator/window/documentNumber/test_smoke_window_documentNumber.py index 452e587b8..fae9dd823 100644 --- a/documentdb_tests/compatibility/tests/core/operator/window/documentNumber/test_smoke_window_documentNumber.py +++ b/documentdb_tests/compatibility/tests/core/operator/window/documentNumber/test_smoke_window_documentNumber.py @@ -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 @@ -40,10 +40,4 @@ def test_smoke_window_documentNumber(collection): }, ) - expected = [ - {"_id": 1, "partition": "A", "value": 10, "docNumber": 1}, - {"_id": 2, "partition": "A", "value": 20, "docNumber": 2}, - {"_id": 3, "partition": "A", "value": 30, "docNumber": 3}, - {"_id": 4, "partition": "B", "value": 40, "docNumber": 1}, - ] - assertSuccess(result, expected, msg="Should support $documentNumber window operator") + assertCommandSupported(result, msg="Should support $documentNumber window operator") diff --git a/documentdb_tests/compatibility/tests/core/operator/window/maxN/test_smoke_window_maxN.py b/documentdb_tests/compatibility/tests/core/operator/window/maxN/test_smoke_window_maxN.py index 27fe33ddb..0471838bd 100644 --- a/documentdb_tests/compatibility/tests/core/operator/window/maxN/test_smoke_window_maxN.py +++ b/documentdb_tests/compatibility/tests/core/operator/window/maxN/test_smoke_window_maxN.py @@ -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 @@ -44,9 +44,4 @@ def test_smoke_window_maxN(collection): }, ) - expected = [ - {"_id": 1, "partition": "A", "value": 10, "maxValues": [10]}, - {"_id": 2, "partition": "A", "value": 30, "maxValues": [30, 10]}, - {"_id": 3, "partition": "A", "value": 20, "maxValues": [30, 20]}, - ] - assertSuccess(result, expected, msg="Should support $maxN window operator") + assertCommandSupported(result, msg="Should support $maxN window operator") diff --git a/documentdb_tests/compatibility/tests/core/operator/window/minN/test_smoke_window_minN.py b/documentdb_tests/compatibility/tests/core/operator/window/minN/test_smoke_window_minN.py index 63650118d..298374263 100644 --- a/documentdb_tests/compatibility/tests/core/operator/window/minN/test_smoke_window_minN.py +++ b/documentdb_tests/compatibility/tests/core/operator/window/minN/test_smoke_window_minN.py @@ -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 @@ -44,9 +44,4 @@ def test_smoke_window_minN(collection): }, ) - expected = [ - {"_id": 1, "partition": "A", "value": 30, "minValues": [30]}, - {"_id": 2, "partition": "A", "value": 10, "minValues": [10, 30]}, - {"_id": 3, "partition": "A", "value": 20, "minValues": [10, 20]}, - ] - assertSuccess(result, expected, msg="Should support $minN window operator") + assertCommandSupported(result, msg="Should support $minN window operator") diff --git a/documentdb_tests/compatibility/tests/core/operator/window/rank/test_smoke_window_rank.py b/documentdb_tests/compatibility/tests/core/operator/window/rank/test_smoke_window_rank.py index f56180dd3..2df4c86b5 100644 --- a/documentdb_tests/compatibility/tests/core/operator/window/rank/test_smoke_window_rank.py +++ b/documentdb_tests/compatibility/tests/core/operator/window/rank/test_smoke_window_rank.py @@ -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 @@ -39,9 +39,4 @@ def test_smoke_window_rank(collection): }, ) - expected = [ - {"_id": 1, "partition": "A", "score": 100, "rank": 1}, - {"_id": 2, "partition": "A", "score": 100, "rank": 1}, - {"_id": 3, "partition": "A", "score": 90, "rank": 3}, - ] - assertSuccess(result, expected, msg="Should support $rank window operator") + assertCommandSupported(result, msg="Should support $rank window operator") diff --git a/documentdb_tests/compatibility/tests/core/query_planning/commands/planCacheListFilters/test_smoke_planCacheListFilters.py b/documentdb_tests/compatibility/tests/core/query_planning/commands/planCacheListFilters/test_smoke_planCacheListFilters.py index 3461fd151..1f0756334 100644 --- a/documentdb_tests/compatibility/tests/core/query_planning/commands/planCacheListFilters/test_smoke_planCacheListFilters.py +++ b/documentdb_tests/compatibility/tests/core/query_planning/commands/planCacheListFilters/test_smoke_planCacheListFilters.py @@ -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 @@ -16,5 +16,4 @@ def test_smoke_planCacheListFilters(collection): """Test basic planCacheListFilters command behavior.""" result = execute_command(collection, {"planCacheListFilters": collection.name}) - expected = {"filters": [], "ok": 1.0} - assertSuccessPartial(result, expected, msg="Should support planCacheListFilters command") + assertCommandSupported(result, msg="Should support planCacheListFilters command") diff --git a/documentdb_tests/compatibility/tests/core/sessions/commands/abortTransaction/test_smoke_abortTransaction.py b/documentdb_tests/compatibility/tests/core/sessions/commands/abortTransaction/test_smoke_abortTransaction.py index 37b8a5302..11b2c1000 100644 --- a/documentdb_tests/compatibility/tests/core/sessions/commands/abortTransaction/test_smoke_abortTransaction.py +++ b/documentdb_tests/compatibility/tests/core/sessions/commands/abortTransaction/test_smoke_abortTransaction.py @@ -6,15 +6,18 @@ import pytest -from documentdb_tests.framework.assertions import assertFailure +from documentdb_tests.framework.assertions import assertCommandSupported from documentdb_tests.framework.executor import execute_admin_command -pytestmark = pytest.mark.smoke +pytestmark = [pytest.mark.smoke, pytest.mark.admin, pytest.mark.requires(transactions=True)] def test_smoke_abortTransaction(collection): """Test basic abortTransaction command behavior.""" - result = execute_admin_command(collection, {"abortTransaction": 1}) + client = collection.database.client + with client.start_session() as session: + session.start_transaction() + collection.insert_one({"_id": 1}, session=session) + result = execute_admin_command(collection, {"abortTransaction": 1}, session=session) - expected_error = {"code": 125, "msg": "abortTransaction must be run within a transaction"} - assertFailure(result, expected_error, msg="Should support abortTransaction command") + assertCommandSupported(result, msg="Should support abortTransaction command") diff --git a/documentdb_tests/compatibility/tests/core/sessions/commands/commitTransaction/test_smoke_commitTransaction.py b/documentdb_tests/compatibility/tests/core/sessions/commands/commitTransaction/test_smoke_commitTransaction.py index 9d95e6566..6b934b58a 100644 --- a/documentdb_tests/compatibility/tests/core/sessions/commands/commitTransaction/test_smoke_commitTransaction.py +++ b/documentdb_tests/compatibility/tests/core/sessions/commands/commitTransaction/test_smoke_commitTransaction.py @@ -6,15 +6,18 @@ import pytest -from documentdb_tests.framework.assertions import assertFailure +from documentdb_tests.framework.assertions import assertCommandSupported from documentdb_tests.framework.executor import execute_admin_command -pytestmark = [pytest.mark.smoke, pytest.mark.requires(transactions=True)] +pytestmark = [pytest.mark.smoke, pytest.mark.admin, pytest.mark.requires(transactions=True)] def test_smoke_commitTransaction(collection): """Test basic commitTransaction command behavior.""" - result = execute_admin_command(collection, {"commitTransaction": 1}) + client = collection.database.client + with client.start_session() as session: + session.start_transaction() + collection.insert_one({"_id": 1}, session=session) + result = execute_admin_command(collection, {"commitTransaction": 1}, session=session) - expected_error = {"code": 125, "msg": "commitTransaction must be run within a transaction"} - assertFailure(result, expected_error, msg="Should support commitTransaction command") + assertCommandSupported(result, msg="Should support commitTransaction command") diff --git a/documentdb_tests/compatibility/tests/system/diagnostic/commands/collStats/test_smoke_command_collStats.py b/documentdb_tests/compatibility/tests/system/diagnostic/commands/collStats/test_smoke_command_collStats.py index d59d9b618..52f3ceca6 100644 --- a/documentdb_tests/compatibility/tests/system/diagnostic/commands/collStats/test_smoke_command_collStats.py +++ b/documentdb_tests/compatibility/tests/system/diagnostic/commands/collStats/test_smoke_command_collStats.py @@ -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 @@ -18,5 +18,4 @@ def test_smoke_command_collStats(collection): result = execute_command(collection, {"collStats": collection.name}) - expected = {"ok": 1.0, "ns": f"{collection.database.name}.{collection.name}"} - assertSuccessPartial(result, expected, msg="Should support collStats command") + assertCommandSupported(result, msg="Should support collStats command") diff --git a/documentdb_tests/compatibility/tests/system/diagnostic/commands/connectionStatus/test_smoke_connectionStatus.py b/documentdb_tests/compatibility/tests/system/diagnostic/commands/connectionStatus/test_smoke_connectionStatus.py index 2cd7fc2a9..d12b09a8d 100644 --- a/documentdb_tests/compatibility/tests/system/diagnostic/commands/connectionStatus/test_smoke_connectionStatus.py +++ b/documentdb_tests/compatibility/tests/system/diagnostic/commands/connectionStatus/test_smoke_connectionStatus.py @@ -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_admin_command pytestmark = pytest.mark.smoke @@ -16,5 +16,4 @@ def test_smoke_connectionStatus(collection): """Verify connectionStatus executes successfully and returns ok: 1.""" result = execute_admin_command(collection, {"connectionStatus": 1}) - expected = {"ok": 1.0} - assertSuccessPartial(result, expected, msg="Should support connectionStatus command") + assertCommandSupported(result, msg="Should support connectionStatus command") diff --git a/documentdb_tests/compatibility/tests/system/diagnostic/commands/dataSize/test_smoke_dataSize.py b/documentdb_tests/compatibility/tests/system/diagnostic/commands/dataSize/test_smoke_dataSize.py index 4ddbf619d..a4d530b1b 100644 --- a/documentdb_tests/compatibility/tests/system/diagnostic/commands/dataSize/test_smoke_dataSize.py +++ b/documentdb_tests/compatibility/tests/system/diagnostic/commands/dataSize/test_smoke_dataSize.py @@ -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 @@ -20,5 +20,4 @@ def test_smoke_dataSize(collection): collection, {"dataSize": f"{collection.database.name}.{collection.name}"} ) - expected = {"ok": 1.0} - assertSuccessPartial(result, expected, msg="Should support dataSize command") + assertCommandSupported(result, msg="Should support dataSize command") diff --git a/documentdb_tests/compatibility/tests/system/diagnostic/commands/dbStats/test_smoke_dbStats.py b/documentdb_tests/compatibility/tests/system/diagnostic/commands/dbStats/test_smoke_dbStats.py index 73f99172b..011f5f8d4 100644 --- a/documentdb_tests/compatibility/tests/system/diagnostic/commands/dbStats/test_smoke_dbStats.py +++ b/documentdb_tests/compatibility/tests/system/diagnostic/commands/dbStats/test_smoke_dbStats.py @@ -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 @@ -18,5 +18,4 @@ def test_smoke_dbStats(collection): result = execute_command(collection, {"dbStats": 1}) - expected = {"ok": 1.0, "db": collection.database.name} - assertSuccessPartial(result, expected, msg="Should support dbStats command") + assertCommandSupported(result, msg="Should support dbStats command") diff --git a/documentdb_tests/compatibility/tests/system/diagnostic/commands/hostInfo/test_smoke_hostInfo.py b/documentdb_tests/compatibility/tests/system/diagnostic/commands/hostInfo/test_smoke_hostInfo.py index 72e8efa0b..2156f1cc7 100644 --- a/documentdb_tests/compatibility/tests/system/diagnostic/commands/hostInfo/test_smoke_hostInfo.py +++ b/documentdb_tests/compatibility/tests/system/diagnostic/commands/hostInfo/test_smoke_hostInfo.py @@ -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_admin_command pytestmark = pytest.mark.smoke @@ -16,5 +16,4 @@ def test_smoke_hostInfo(collection): """Test basic hostInfo command behavior.""" result = execute_admin_command(collection, {"hostInfo": 1}) - expected = {"ok": 1.0} - assertSuccessPartial(result, expected, msg="Should support hostInfo command") + assertCommandSupported(result, msg="Should support hostInfo command") diff --git a/documentdb_tests/compatibility/tests/system/security/authentication/commands/logout/test_smoke_logout.py b/documentdb_tests/compatibility/tests/system/security/authentication/commands/logout/test_smoke_logout.py index 9e6e209fb..254384a45 100644 --- a/documentdb_tests/compatibility/tests/system/security/authentication/commands/logout/test_smoke_logout.py +++ b/documentdb_tests/compatibility/tests/system/security/authentication/commands/logout/test_smoke_logout.py @@ -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 @@ -16,5 +16,4 @@ def test_smoke_logout(collection): """Test basic logout behavior.""" result = execute_command(collection, {"logout": 1}) - expected = {"ok": 1.0} - assertSuccessPartial(result, expected, msg="Should support logout command") + assertCommandSupported(result, msg="Should support logout command") diff --git a/documentdb_tests/compatibility/tests/system/security/authorization/role/commands/createRole/test_smoke_createRole.py b/documentdb_tests/compatibility/tests/system/security/authorization/role/commands/createRole/test_smoke_createRole.py index 4590c9a58..a831d5723 100644 --- a/documentdb_tests/compatibility/tests/system/security/authorization/role/commands/createRole/test_smoke_createRole.py +++ b/documentdb_tests/compatibility/tests/system/security/authorization/role/commands/createRole/test_smoke_createRole.py @@ -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_admin_command pytestmark = pytest.mark.smoke @@ -22,5 +22,4 @@ def test_smoke_createRole(collection): execute_admin_command(collection, {"dropRole": role_name}) - expected = {"ok": 1.0} - assertSuccessPartial(result, expected, msg="Should support createRole command") + assertCommandSupported(result, msg="Should support createRole command") diff --git a/documentdb_tests/compatibility/tests/system/security/authorization/role/commands/dropAllRolesFromDatabase/test_smoke_dropAllRolesFromDatabase.py b/documentdb_tests/compatibility/tests/system/security/authorization/role/commands/dropAllRolesFromDatabase/test_smoke_dropAllRolesFromDatabase.py index a5d0c2e9f..0eb7ae033 100644 --- a/documentdb_tests/compatibility/tests/system/security/authorization/role/commands/dropAllRolesFromDatabase/test_smoke_dropAllRolesFromDatabase.py +++ b/documentdb_tests/compatibility/tests/system/security/authorization/role/commands/dropAllRolesFromDatabase/test_smoke_dropAllRolesFromDatabase.py @@ -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_admin_command pytestmark = [pytest.mark.smoke, pytest.mark.no_parallel] @@ -16,5 +16,4 @@ def test_smoke_dropAllRolesFromDatabase(collection): """Test basic dropAllRolesFromDatabase behavior.""" result = execute_admin_command(collection, {"dropAllRolesFromDatabase": 1}) - expected = {"ok": 1.0} - assertSuccessPartial(result, expected, msg="Should support dropAllRolesFromDatabase command") + assertCommandSupported(result, msg="Should support dropAllRolesFromDatabase command") diff --git a/documentdb_tests/compatibility/tests/system/security/authorization/role/commands/dropRole/test_smoke_dropRole.py b/documentdb_tests/compatibility/tests/system/security/authorization/role/commands/dropRole/test_smoke_dropRole.py index 5be37d29b..4ed25e60a 100644 --- a/documentdb_tests/compatibility/tests/system/security/authorization/role/commands/dropRole/test_smoke_dropRole.py +++ b/documentdb_tests/compatibility/tests/system/security/authorization/role/commands/dropRole/test_smoke_dropRole.py @@ -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_admin_command pytestmark = pytest.mark.smoke @@ -20,5 +20,4 @@ def test_smoke_dropRole(collection): result = execute_admin_command(collection, {"dropRole": role_name}) - expected = {"ok": 1.0} - assertSuccessPartial(result, expected, msg="Should support dropRole command") + assertCommandSupported(result, msg="Should support dropRole command") diff --git a/documentdb_tests/compatibility/tests/system/security/authorization/role/commands/grantPrivilegesToRole/test_smoke_grantPrivilegesToRole.py b/documentdb_tests/compatibility/tests/system/security/authorization/role/commands/grantPrivilegesToRole/test_smoke_grantPrivilegesToRole.py index 60452e381..8d32b20bb 100644 --- a/documentdb_tests/compatibility/tests/system/security/authorization/role/commands/grantPrivilegesToRole/test_smoke_grantPrivilegesToRole.py +++ b/documentdb_tests/compatibility/tests/system/security/authorization/role/commands/grantPrivilegesToRole/test_smoke_grantPrivilegesToRole.py @@ -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_admin_command pytestmark = pytest.mark.smoke @@ -28,5 +28,4 @@ def test_smoke_grantPrivilegesToRole(collection): execute_admin_command(collection, {"dropRole": role_name}) - expected = {"ok": 1.0} - assertSuccessPartial(result, expected, msg="Should support grantPrivilegesToRole command") + assertCommandSupported(result, msg="Should support grantPrivilegesToRole command") diff --git a/documentdb_tests/compatibility/tests/system/security/authorization/role/commands/grantRolesToRole/test_smoke_grantRolesToRole.py b/documentdb_tests/compatibility/tests/system/security/authorization/role/commands/grantRolesToRole/test_smoke_grantRolesToRole.py index 787d06d4c..78c8ecd33 100644 --- a/documentdb_tests/compatibility/tests/system/security/authorization/role/commands/grantRolesToRole/test_smoke_grantRolesToRole.py +++ b/documentdb_tests/compatibility/tests/system/security/authorization/role/commands/grantRolesToRole/test_smoke_grantRolesToRole.py @@ -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_admin_command pytestmark = pytest.mark.smoke @@ -25,5 +25,4 @@ def test_smoke_grantRolesToRole(collection): execute_admin_command(collection, {"dropRole": role_name}) - expected = {"ok": 1.0} - assertSuccessPartial(result, expected, msg="Should support grantRolesToRole command") + assertCommandSupported(result, msg="Should support grantRolesToRole command") diff --git a/documentdb_tests/compatibility/tests/system/security/authorization/role/commands/revokePrivilegesFromRole/test_smoke_revokePrivilegesFromRole.py b/documentdb_tests/compatibility/tests/system/security/authorization/role/commands/revokePrivilegesFromRole/test_smoke_revokePrivilegesFromRole.py index 535864f0a..9b064db14 100644 --- a/documentdb_tests/compatibility/tests/system/security/authorization/role/commands/revokePrivilegesFromRole/test_smoke_revokePrivilegesFromRole.py +++ b/documentdb_tests/compatibility/tests/system/security/authorization/role/commands/revokePrivilegesFromRole/test_smoke_revokePrivilegesFromRole.py @@ -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_admin_command pytestmark = pytest.mark.smoke @@ -37,5 +37,4 @@ def test_smoke_revokePrivilegesFromRole(collection): execute_admin_command(collection, {"dropRole": role_name}) - expected = {"ok": 1.0} - assertSuccessPartial(result, expected, msg="Should support revokePrivilegesFromRole command") + assertCommandSupported(result, msg="Should support revokePrivilegesFromRole command") diff --git a/documentdb_tests/compatibility/tests/system/security/authorization/role/commands/revokeRolesFromRole/test_smoke_revokeRolesFromRole.py b/documentdb_tests/compatibility/tests/system/security/authorization/role/commands/revokeRolesFromRole/test_smoke_revokeRolesFromRole.py index 6bf413596..369f2da6e 100644 --- a/documentdb_tests/compatibility/tests/system/security/authorization/role/commands/revokeRolesFromRole/test_smoke_revokeRolesFromRole.py +++ b/documentdb_tests/compatibility/tests/system/security/authorization/role/commands/revokeRolesFromRole/test_smoke_revokeRolesFromRole.py @@ -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_admin_command pytestmark = pytest.mark.smoke @@ -28,5 +28,4 @@ def test_smoke_revokeRolesFromRole(collection): execute_admin_command(collection, {"dropRole": role_name}) - expected = {"ok": 1.0} - assertSuccessPartial(result, expected, msg="Should support revokeRolesFromRole command") + assertCommandSupported(result, msg="Should support revokeRolesFromRole command") diff --git a/documentdb_tests/compatibility/tests/system/security/authorization/role/commands/updateRole/test_smoke_updateRole.py b/documentdb_tests/compatibility/tests/system/security/authorization/role/commands/updateRole/test_smoke_updateRole.py index e5abb4394..4e138f726 100644 --- a/documentdb_tests/compatibility/tests/system/security/authorization/role/commands/updateRole/test_smoke_updateRole.py +++ b/documentdb_tests/compatibility/tests/system/security/authorization/role/commands/updateRole/test_smoke_updateRole.py @@ -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_admin_command pytestmark = pytest.mark.smoke @@ -29,5 +29,4 @@ def test_smoke_updateRole(collection): execute_admin_command(collection, {"dropRole": role_name}) - expected = {"ok": 1.0} - assertSuccessPartial(result, expected, msg="Should support updateRole command") + assertCommandSupported(result, msg="Should support updateRole command") diff --git a/documentdb_tests/compatibility/tests/system/security/authorization/user/commands/createUser/test_smoke_createUser.py b/documentdb_tests/compatibility/tests/system/security/authorization/user/commands/createUser/test_smoke_createUser.py index 95ca55b26..d46bc2177 100644 --- a/documentdb_tests/compatibility/tests/system/security/authorization/user/commands/createUser/test_smoke_createUser.py +++ b/documentdb_tests/compatibility/tests/system/security/authorization/user/commands/createUser/test_smoke_createUser.py @@ -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_admin_command pytestmark = pytest.mark.smoke @@ -22,5 +22,4 @@ def test_smoke_createUser(collection): execute_admin_command(collection, {"dropUser": user_name}) - expected = {"ok": 1.0} - assertSuccessPartial(result, expected, msg="Should support createUser command") + assertCommandSupported(result, msg="Should support createUser command") diff --git a/documentdb_tests/compatibility/tests/system/security/authorization/user/commands/dropUser/test_smoke_dropUser.py b/documentdb_tests/compatibility/tests/system/security/authorization/user/commands/dropUser/test_smoke_dropUser.py index 1d9ba3d10..e7f1bfd88 100644 --- a/documentdb_tests/compatibility/tests/system/security/authorization/user/commands/dropUser/test_smoke_dropUser.py +++ b/documentdb_tests/compatibility/tests/system/security/authorization/user/commands/dropUser/test_smoke_dropUser.py @@ -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_admin_command pytestmark = pytest.mark.smoke @@ -20,5 +20,4 @@ def test_smoke_dropUser(collection): result = execute_admin_command(collection, {"dropUser": user_name}) - expected = {"ok": 1.0} - assertSuccessPartial(result, expected, msg="Should support dropUser command") + assertCommandSupported(result, msg="Should support dropUser command") diff --git a/documentdb_tests/compatibility/tests/system/security/authorization/user/commands/grantRolesToUser/test_smoke_grantRolesToUser.py b/documentdb_tests/compatibility/tests/system/security/authorization/user/commands/grantRolesToUser/test_smoke_grantRolesToUser.py index 1fae2b4e7..8d44ce372 100644 --- a/documentdb_tests/compatibility/tests/system/security/authorization/user/commands/grantRolesToUser/test_smoke_grantRolesToUser.py +++ b/documentdb_tests/compatibility/tests/system/security/authorization/user/commands/grantRolesToUser/test_smoke_grantRolesToUser.py @@ -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_admin_command pytestmark = pytest.mark.smoke @@ -25,5 +25,4 @@ def test_smoke_grantRolesToUser(collection): execute_admin_command(collection, {"dropUser": user_name}) - expected = {"ok": 1.0} - assertSuccessPartial(result, expected, msg="Should support grantRolesToUser command") + assertCommandSupported(result, msg="Should support grantRolesToUser command") diff --git a/documentdb_tests/compatibility/tests/system/security/authorization/user/commands/revokeRolesFromUser/test_smoke_revokeRolesFromUser.py b/documentdb_tests/compatibility/tests/system/security/authorization/user/commands/revokeRolesFromUser/test_smoke_revokeRolesFromUser.py index 2a5eb2965..c863aa444 100644 --- a/documentdb_tests/compatibility/tests/system/security/authorization/user/commands/revokeRolesFromUser/test_smoke_revokeRolesFromUser.py +++ b/documentdb_tests/compatibility/tests/system/security/authorization/user/commands/revokeRolesFromUser/test_smoke_revokeRolesFromUser.py @@ -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_admin_command pytestmark = pytest.mark.smoke @@ -32,5 +32,4 @@ def test_smoke_revokeRolesFromUser(collection): execute_admin_command(collection, {"dropUser": user_name}) - expected = {"ok": 1.0} - assertSuccessPartial(result, expected, msg="Should support revokeRolesFromUser command") + assertCommandSupported(result, msg="Should support revokeRolesFromUser command") diff --git a/documentdb_tests/compatibility/tests/system/security/authorization/user/commands/updateUser/test_smoke_updateUser.py b/documentdb_tests/compatibility/tests/system/security/authorization/user/commands/updateUser/test_smoke_updateUser.py index cd65b64d0..131e09049 100644 --- a/documentdb_tests/compatibility/tests/system/security/authorization/user/commands/updateUser/test_smoke_updateUser.py +++ b/documentdb_tests/compatibility/tests/system/security/authorization/user/commands/updateUser/test_smoke_updateUser.py @@ -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_admin_command pytestmark = pytest.mark.smoke @@ -25,5 +25,4 @@ def test_smoke_updateUser(collection): execute_admin_command(collection, {"dropUser": user_name}) - expected = {"ok": 1.0} - assertSuccessPartial(result, expected, msg="Should support updateUser command") + assertCommandSupported(result, msg="Should support updateUser command") diff --git a/documentdb_tests/framework/assertions.py b/documentdb_tests/framework/assertions.py index 3b954abb6..696c0dc25 100644 --- a/documentdb_tests/framework/assertions.py +++ b/documentdb_tests/framework/assertions.py @@ -14,7 +14,7 @@ from documentdb_tests.framework.infra_exceptions import INFRA_EXCEPTION_TYPES as _INFRA_TYPES from documentdb_tests.framework.lazy_payload import materialize from documentdb_tests.framework.override_hook import consult_override -from documentdb_tests.framework.property_checks import _FIELD_ABSENT, Check, PerDoc +from documentdb_tests.framework.property_checks import _FIELD_ABSENT, Check, LenGt, PerDoc _MAX_REPR_LEN = 1000 @@ -683,3 +683,28 @@ def assertProperties( ) -> None: """Assert that a result document satisfies property checks (see ``_assert_properties``).""" assertResult(result, checks, msg=msg, raw_res=raw_res, properties=True) + + +def assertCommandSupported(result: Union[Any, Exception], msg: Optional[str] = None): + """Assert a command is supported: it returned a result rather than erroring. + + This is a capability probe for smoke tests. It answers only "does the engine + support this feature?" and deliberately performs no value or BSON-type + comparison, so cosmetic divergences (e.g. ``ok`` as int32 vs double, extra + response fields, count differences) do NOT make the smoke test fail. Exact + response shape is the job of the feature's detailed tests, not the smoke + test. A command that raises (OperationFailure / unsupported) fails here; + infra exceptions propagate unchanged. + """ + assertResult(result, msg=msg, not_error=True) + + +def assertChangeStreamEvent(result: Union[Any, Exception], msg: Optional[str] = None): + """Assert a change-stream getMore returned at least one event. + + Capability probe for change-stream smoke tests: the getMore must succeed and + ``cursor.nextBatch`` must be non-empty (the expected event was emitted). An + empty batch fails cleanly here instead of raising ``IndexError`` when the + test indexes ``nextBatch[0]``. Performs no comparison of the event contents. + """ + assertResult(result, {"cursor.nextBatch": LenGt(0)}, msg=msg, raw_res=True, properties=True)