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

Method test_empty_file

test/test_gridfs.py:150–162  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

148 self.assertEqual({"mike", "test", "hello world"}, set(self.fs.list()))
149
150 def test_empty_file(self):
151 oid = self.fs.put(b"")
152 self.assertEqual(b"", (self.fs.get(oid)).read())
153 self.assertEqual(1, self.db.fs.files.count_documents({}))
154 self.assertEqual(0, self.db.fs.chunks.count_documents({}))
155
156 raw = self.db.fs.files.find_one()
157 assert raw is not None
158 self.assertEqual(0, raw["length"])
159 self.assertEqual(oid, raw["_id"])
160 self.assertIsInstance(raw["uploadDate"], datetime.datetime)
161 self.assertEqual(255 * 1024, raw["chunkSize"])
162 self.assertNotIn("md5", raw)
163
164 def test_corrupt_chunk(self):
165 files_id = self.fs.put(b"foobar")

Callers

nothing calls this directly

Calls 5

putMethod · 0.45
readMethod · 0.45
getMethod · 0.45
count_documentsMethod · 0.45
find_oneMethod · 0.45

Tested by

no test coverage detected