MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / test_aggregate

Method test_aggregate

test/test_collection.py:1535–1550  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1533 self.assertEqual(db.test.estimated_document_count(), 2)
1534
1535 def test_aggregate(self):
1536 db = self.db
1537 db.drop_collection("test")
1538 db.test.insert_one({"foo": [1, 2]})
1539
1540 with self.assertRaises(TypeError):
1541 db.test.aggregate("wow") # type: ignore[arg-type]
1542
1543 pipeline = {"$project": {"_id": False, "foo": True}}
1544 result = db.test.aggregate([pipeline])
1545 self.assertIsInstance(result, CommandCursor)
1546 self.assertEqual([{"foo": [1, 2]}], result.to_list())
1547
1548 # Test write concern.
1549 with self.write_concern_collection() as coll:
1550 coll.aggregate([{"$out": "output-collection"}])
1551
1552 def test_aggregate_raw_bson(self):
1553 db = self.db

Callers

nothing calls this directly

Calls 5

drop_collectionMethod · 0.45
insert_oneMethod · 0.45
aggregateMethod · 0.45
to_listMethod · 0.45

Tested by

no test coverage detected