diff --git a/documentdb_tests/compatibility/tests/core/operator/expressions/misc/sampleRate/test_smoke_sampleRate.py b/documentdb_tests/compatibility/tests/core/operator/expressions/misc/sampleRate/test_smoke_sampleRate.py index e555d4ef5..5d9387f0a 100644 --- a/documentdb_tests/compatibility/tests/core/operator/expressions/misc/sampleRate/test_smoke_sampleRate.py +++ b/documentdb_tests/compatibility/tests/core/operator/expressions/misc/sampleRate/test_smoke_sampleRate.py @@ -1,7 +1,7 @@ """ Smoke test for $sampleRate expression. -Tests basic $sampleRate expression functionality. +Tests basic $sampleRate match expression functionality. """ import pytest @@ -12,11 +12,9 @@ pytestmark = pytest.mark.smoke -def test_smoke_sampleRate(collection): - """Test basic $sampleRate expression behavior.""" - collection.insert_many( - [{"_id": 1, "value": 10}, {"_id": 2, "value": 20}, {"_id": 3, "value": 30}] - ) +def test_smoke_sampleRate_rate_one(collection): + """Test $sampleRate: 1.0 returns all documents (deterministic upper boundary).""" + collection.insert_many([{"_id": 1, "val": "a"}, {"_id": 2, "val": "b"}, {"_id": 3, "val": "c"}]) result = execute_command( collection, @@ -27,5 +25,22 @@ def test_smoke_sampleRate(collection): }, ) - expected = [{"_id": 1, "value": 10}, {"_id": 2, "value": 20}, {"_id": 3, "value": 30}] - assertSuccess(result, expected, msg="Should support $sampleRate expression") + expected = [{"_id": 1, "val": "a"}, {"_id": 2, "val": "b"}, {"_id": 3, "val": "c"}] + assertSuccess(result, expected, msg="$sampleRate: 1.0 should return all documents") + + +def test_smoke_sampleRate_rate_zero(collection): + """Test $sampleRate: 0.0 returns no documents (deterministic lower boundary).""" + collection.insert_many([{"_id": 1, "val": "a"}, {"_id": 2, "val": "b"}, {"_id": 3, "val": "c"}]) + + result = execute_command( + collection, + { + "aggregate": collection.name, + "pipeline": [{"$match": {"$sampleRate": 0.0}}], + "cursor": {}, + }, + ) + + expected = [] + assertSuccess(result, expected, msg="$sampleRate: 0.0 should return no documents")