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

Method test_gridfs_bucket

test/test_session.py:550–595  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

548 )
549
550 def test_gridfs_bucket(self):
551 client = self.client
552 bucket = GridFSBucket(client.pymongo_test)
553
554 def upload(session=None):
555 stream = bucket.open_upload_stream("f", session=session)
556 stream.write(b"a" * 1048576)
557 stream.close()
558
559 def upload_with_id(session=None):
560 stream = bucket.open_upload_stream_with_id(1, "f1", session=session)
561 stream.write(b"a" * 1048576)
562 stream.close()
563
564 def open_download_stream(session=None):
565 stream = bucket.open_download_stream(1, session=session)
566 stream.read()
567
568 def open_download_stream_by_name(session=None):
569 stream = bucket.open_download_stream_by_name("f", session=session)
570 stream.read()
571
572 def find(session=None):
573 files = bucket.find({"_id": 1}, session=session).to_list()
574 for f in files:
575 f.read()
576
577 sio = BytesIO()
578
579 self._test_ops(
580 client,
581 (upload, [], {}),
582 (upload_with_id, [], {}),
583 (bucket.upload_from_stream, ["f", b"data"], {}),
584 (bucket.upload_from_stream_with_id, [2, "f", b"data"], {}),
585 (open_download_stream, [], {}),
586 (open_download_stream_by_name, [], {}),
587 (bucket.download_to_stream, [1, sio], {}),
588 (bucket.download_to_stream_by_name, ["f", sio], {}),
589 (find, [], {}),
590 (bucket.rename, [1, "f2"], {}),
591 (bucket.rename_by_name, ["f2", "f3"], {}),
592 # Delete both files so _test_ops can run these operations twice.
593 (bucket.delete, [1], {}),
594 (bucket.delete_by_name, ["f"], {}),
595 )
596
597 def test_gridfsbucket_cursor(self):
598 client = self.client

Callers

nothing calls this directly

Calls 2

_test_opsMethod · 0.95
GridFSBucketClass · 0.90

Tested by

no test coverage detected