Skip to content

Commit fea3308

Browse files
author
Peng Ren
committed
Add some test cases
1 parent 37c6ad3 commit fea3308

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ MANIFEST
2727
.vscode/
2828
.idea/
2929

30+
# Test configuration
31+
pytest.ini
32+
3033
# Environments
3134
.env
3235
.envrc

pymongosql/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
if TYPE_CHECKING:
77
from .connection import Connection
88

9-
__version__: str = "0.4.1"
9+
__version__: str = "0.4.2"
1010

1111
# Globals https://www.python.org/dev/peps/pep-0249/#globals
1212
apilevel: str = "2.0"

tests/test_cursor_aggregate.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,4 +273,15 @@ def test_aggregate_multiple_stages(self, conn):
273273
# Should have one row with aggregated stats
274274
assert len(rows) == 1
275275
row = rows[0]
276-
assert len(row) >= 2 # Should have average_age and total_users
276+
277+
# Verify projections defined in pipeline appear in the result
278+
col_names = [desc[0] for desc in cursor.result_set.description]
279+
assert "average_age" in col_names, "average_age should be in result columns"
280+
assert "total_users" in col_names, "total_users should be in result columns"
281+
assert "_id" not in col_names, "_id should be excluded from result columns"
282+
283+
# Verify the values are present and valid
284+
avg_age_idx = col_names.index("average_age")
285+
total_users_idx = col_names.index("total_users")
286+
assert row[avg_age_idx] is not None and isinstance(row[avg_age_idx], (int, float))
287+
assert row[total_users_idx] is not None and isinstance(row[total_users_idx], (int, float))

0 commit comments

Comments
 (0)