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

Method test_gridfs

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

Source from the content-addressed store, hash-verified

506 )
507
508 def test_gridfs(self):
509 client = self.client
510 fs = GridFS(client.pymongo_test)
511
512 def new_file(session=None):
513 grid_file = fs.new_file(_id=1, filename="f", session=session)
514 # 1 MB, 5 chunks, to test that each chunk is fetched with same lsid.
515 grid_file.write(b"a" * 1048576)
516 grid_file.close()
517
518 def find(session=None):
519 files = fs.find({"_id": 1}, session=session).to_list()
520 for f in files:
521 f.read()
522
523 def get(session=None):
524 (fs.get(1, session=session)).read()
525
526 def get_version(session=None):
527 (fs.get_version("f", session=session)).read()
528
529 def get_last_version(session=None):
530 (fs.get_last_version("f", session=session)).read()
531
532 def find_list(session=None):
533 fs.find(session=session).to_list()
534
535 self._test_ops(
536 client,
537 (new_file, [], {}),
538 (fs.put, [b"data"], {}),
539 (get, [], {}),
540 (get_version, [], {}),
541 (get_last_version, [], {}),
542 (fs.list, [], {}),
543 (fs.find_one, [1], {}),
544 (find_list, [], {}),
545 (fs.exists, [1], {}),
546 (find, [], {}),
547 (fs.delete, [1], {}),
548 )
549
550 def test_gridfs_bucket(self):
551 client = self.client

Callers

nothing calls this directly

Calls 2

_test_opsMethod · 0.95
GridFSClass · 0.90

Tested by

no test coverage detected