-
Notifications
You must be signed in to change notification settings - Fork 33
Add skip_localhost mark, skip shutdown on local #614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
PatersonProjects
wants to merge
15
commits into
documentdb:main
Choose a base branch
from
PatersonProjects:shutdown_smoke_fix
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,288
−4
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
dfdf73b
Add a skip localhost mark to conditionally skip the destructive shutd…
PatersonProjects 5d59367
Merge remote-tracking branch 'origin/main' into shutdown_smoke_fix
PatersonProjects 542cb02
Merge branch 'main' into shutdown_smoke_fix
PatersonProjects 51a482a
Added tests
PatersonProjects 014f2bc
Added docStrings to all files
PatersonProjects 37407ae
Revert "Added docStrings to all files"
PatersonProjects f851712
Revert "Added tests"
PatersonProjects b03fb59
Merge branch 'main' of https://github.com/PatersonProjects/functional…
PatersonProjects 0fa5e10
Merge branch 'main' into shutdown_smoke_fix
PatersonProjects 6cfdd1d
Base Tests
PatersonProjects 92c7160
Merge branch 'shutdown_smoke_fix' of https://github.com/PatersonProje…
PatersonProjects a49322d
Fix to enable CI passing rather than skipping
PatersonProjects b873d7e
Merge branch 'main' of https://github.com/PatersonProjects/functional…
PatersonProjects 89e0657
Changed fix to implement the new preconditions feature
PatersonProjects f16acf8
Merge branch 'main' into shutdown_smoke_fix
PatersonProjects File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
218 changes: 218 additions & 0 deletions
218
.../compatibility/tests/core/operator/expressions/arithmetic/subtract/test_subtract_basic.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,218 @@ | ||
| from __future__ import annotations | ||
|
|
||
| import pytest | ||
| from bson import Decimal128, Int64 | ||
|
|
||
| from documentdb_tests.compatibility.tests.core.operator.expressions.utils.expression_test_case import ( # noqa: E501 | ||
| ExpressionTestCase, | ||
| ) | ||
| from documentdb_tests.compatibility.tests.core.operator.expressions.utils.utils import ( | ||
| assert_expression_result, | ||
| execute_expression_with_insert, | ||
| ) | ||
| from documentdb_tests.framework.parametrize import pytest_params | ||
|
|
||
| # Property [Same Type]: $subtract returns the correct difference for each numeric type. | ||
| SUBTRACT_SAME_TYPE_TESTS: list[ExpressionTestCase] = [ | ||
| ExpressionTestCase( | ||
| "same_type_int32", | ||
| doc={"a": 10, "b": 3}, | ||
| expression={"$subtract": ["$a", "$b"]}, | ||
| expected=7, | ||
| msg="Should subtract int32 values", | ||
| ), | ||
| ExpressionTestCase( | ||
| "same_type_int64", | ||
| doc={"a": Int64(20), "b": Int64(5)}, | ||
| expression={"$subtract": ["$a", "$b"]}, | ||
| expected=Int64(15), | ||
| msg="Should subtract int64 values", | ||
| ), | ||
| ExpressionTestCase( | ||
| "same_type_double", | ||
| doc={"a": 10.5, "b": 2.5}, | ||
| expression={"$subtract": ["$a", "$b"]}, | ||
| expected=8.0, | ||
| msg="Should subtract double values", | ||
| ), | ||
| ExpressionTestCase( | ||
| "same_type_decimal", | ||
| doc={"a": Decimal128("20.5"), "b": Decimal128("10.5")}, | ||
| expression={"$subtract": ["$a", "$b"]}, | ||
| expected=Decimal128("10.0"), | ||
| msg="Should subtract decimal128 values", | ||
| ), | ||
| ] | ||
|
|
||
| # Property [Mixed Type]: $subtract promotes mixed numeric types per the arithmetic rules. | ||
| SUBTRACT_MIXED_TYPE_TESTS: list[ExpressionTestCase] = [ | ||
| ExpressionTestCase( | ||
| "int32_int64", | ||
| doc={"a": 10, "b": Int64(3)}, | ||
| expression={"$subtract": ["$a", "$b"]}, | ||
| expected=Int64(7), | ||
| msg="Should subtract int64 from int32", | ||
| ), | ||
| ExpressionTestCase( | ||
| "int32_double", | ||
| doc={"a": 10, "b": 2.5}, | ||
| expression={"$subtract": ["$a", "$b"]}, | ||
| expected=7.5, | ||
| msg="Should subtract double from int32", | ||
| ), | ||
| ExpressionTestCase( | ||
| "int32_decimal", | ||
| doc={"a": 10, "b": Decimal128("2.5")}, | ||
| expression={"$subtract": ["$a", "$b"]}, | ||
| expected=Decimal128("7.5"), | ||
| msg="Should subtract decimal128 from int32", | ||
| ), | ||
| ExpressionTestCase( | ||
| "int64_double", | ||
| doc={"a": Int64(20), "b": 5.5}, | ||
| expression={"$subtract": ["$a", "$b"]}, | ||
| expected=14.5, | ||
| msg="Should subtract double from int64", | ||
| ), | ||
| ExpressionTestCase( | ||
| "int64_decimal", | ||
| doc={"a": Int64(20), "b": Decimal128("5.5")}, | ||
| expression={"$subtract": ["$a", "$b"]}, | ||
| expected=Decimal128("14.5"), | ||
| msg="Should subtract decimal128 from int64", | ||
| ), | ||
| ExpressionTestCase( | ||
| "double_decimal", | ||
| doc={"a": 10.5, "b": Decimal128("2.5")}, | ||
| expression={"$subtract": ["$a", "$b"]}, | ||
| expected=Decimal128("8.0000000000000"), | ||
| msg="Should subtract decimal128 from double", | ||
| ), | ||
| ] | ||
|
|
||
| # Property [Sign and Zero]: $subtract handles positive, negative, and zero operands. | ||
| SUBTRACT_SIGN_TESTS: list[ExpressionTestCase] = [ | ||
| ExpressionTestCase( | ||
| "positive_positive", | ||
| doc={}, | ||
| expression={"$subtract": [10, 3]}, | ||
| expected=7, | ||
| msg="Should subtract two positive values", | ||
| ), | ||
| ExpressionTestCase( | ||
| "negative_positive", | ||
| doc={}, | ||
| expression={"$subtract": [-10, 3]}, | ||
| expected=-13, | ||
| msg="Should subtract positive from negative", | ||
| ), | ||
| ExpressionTestCase( | ||
| "positive_negative", | ||
| doc={}, | ||
| expression={"$subtract": [10, -3]}, | ||
| expected=13, | ||
| msg="Should subtract negative from positive", | ||
| ), | ||
| ExpressionTestCase( | ||
| "both_negative", | ||
| doc={}, | ||
| expression={"$subtract": [-10, -3]}, | ||
| expected=-7, | ||
| msg="Should subtract two negative values", | ||
| ), | ||
| ExpressionTestCase( | ||
| "zero_minuend", | ||
| doc={}, | ||
| expression={"$subtract": [0, 5]}, | ||
| expected=-5, | ||
| msg="Should subtract from zero", | ||
| ), | ||
| ExpressionTestCase( | ||
| "zero_subtrahend", | ||
| doc={}, | ||
| expression={"$subtract": [5, 0]}, | ||
| expected=5, | ||
| msg="Should subtract zero", | ||
| ), | ||
| ExpressionTestCase( | ||
| "zeros", | ||
| doc={}, | ||
| expression={"$subtract": [0, 0]}, | ||
| expected=0, | ||
| msg="Should subtract zero from zero", | ||
| ), | ||
| ExpressionTestCase( | ||
| "zero_negative_zero", | ||
| doc={}, | ||
| expression={"$subtract": [0, -0.0]}, | ||
| expected=0.0, | ||
| msg="Should subtract negative zero from zero", | ||
| ), | ||
| ExpressionTestCase( | ||
| "negative_zero_zero", | ||
| doc={}, | ||
| expression={"$subtract": [-0.0, 0]}, | ||
| expected=-0.0, | ||
| msg="Should subtract zero from negative zero", | ||
| ), | ||
| ExpressionTestCase( | ||
| "result_negative", | ||
| doc={}, | ||
| expression={"$subtract": [5, 10]}, | ||
| expected=-5, | ||
| msg="Should produce a negative result", | ||
| ), | ||
| ExpressionTestCase( | ||
| "result_negative_double", | ||
| doc={}, | ||
| expression={"$subtract": [5.5, 10]}, | ||
| expected=-4.5, | ||
| msg="Should produce a negative double result", | ||
| ), | ||
| ] | ||
|
|
||
| # Property [Precision]: $subtract preserves decimal128 precision. | ||
| SUBTRACT_PRECISION_TESTS: list[ExpressionTestCase] = [ | ||
| ExpressionTestCase( | ||
| "decimal_precision", | ||
| doc={}, | ||
| expression={"$subtract": [Decimal128("10.5"), Decimal128("2.5")]}, | ||
| expected=Decimal128("8.0"), | ||
| msg="Should preserve decimal128 precision", | ||
| ), | ||
| ExpressionTestCase( | ||
| "decimal_precision_small", | ||
| doc={}, | ||
| expression={"$subtract": [Decimal128("0.3"), Decimal128("0.1")]}, | ||
| expected=Decimal128("0.2"), | ||
| msg="Should preserve decimal128 precision for small values", | ||
| ), | ||
| ExpressionTestCase( | ||
| "decimal_large_precision", | ||
| doc={}, | ||
| expression={ | ||
| "$subtract": [ | ||
| Decimal128("1000000000000000000000000000000000"), | ||
| Decimal128("1"), | ||
| ] | ||
| }, | ||
| expected=Decimal128("999999999999999999999999999999999"), | ||
| msg="Should preserve decimal128 precision for large values", | ||
| ), | ||
| ] | ||
|
|
||
| SUBTRACT_BASIC_TESTS = ( | ||
| SUBTRACT_SAME_TYPE_TESTS | ||
| + SUBTRACT_MIXED_TYPE_TESTS | ||
| + SUBTRACT_SIGN_TESTS | ||
| + SUBTRACT_PRECISION_TESTS | ||
| ) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("test_case", pytest_params(SUBTRACT_BASIC_TESTS)) | ||
| def test_subtract_basic(collection, test_case: ExpressionTestCase): | ||
| """Test $subtract basic numeric cases.""" | ||
| result = execute_expression_with_insert(collection, test_case.expression, test_case.doc) | ||
| assert_expression_result( | ||
| result, expected=test_case.expected, error_code=test_case.error_code, msg=test_case.msg | ||
| ) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Were subtract related files unintentionally added?