MCPcopy Create free account
hub / github.com/mongodb/mongo-python-driver / test_empty_file

Method test_empty_file

test/test_gridfs_bucket.py:129–141  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

127 self.assertEqual(0, self.db.fs.chunks.count_documents({}))
128
129 def test_empty_file(self):
130 oid = self.fs.upload_from_stream("test_filename", b"")
131 self.assertEqual(b"", (self.fs.open_download_stream(oid)).read())
132 self.assertEqual(1, self.db.fs.files.count_documents({}))
133 self.assertEqual(0, self.db.fs.chunks.count_documents({}))
134
135 raw = self.db.fs.files.find_one()
136 assert raw is not None
137 self.assertEqual(0, raw["length"])
138 self.assertEqual(oid, raw["_id"])
139 self.assertIsInstance(raw["uploadDate"], datetime.datetime)
140 self.assertEqual(255 * 1024, raw["chunkSize"])
141 self.assertNotIn("md5", raw)
142
143 def test_corrupt_chunk(self):
144 files_id = self.fs.upload_from_stream("test_filename", b"foobar")

Callers

nothing calls this directly

Calls 5

upload_from_streamMethod · 0.45
readMethod · 0.45
open_download_streamMethod · 0.45
count_documentsMethod · 0.45
find_oneMethod · 0.45

Tested by

no test coverage detected