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

Method test_alt_collection

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

Source from the content-addressed store, hash-verified

197 )
198
199 def test_alt_collection(self):
200 oid = self.alt.put(b"hello world")
201 self.assertEqual(b"hello world", (self.alt.get(oid)).read())
202 self.assertEqual(1, self.db.alt.files.count_documents({}))
203 self.assertEqual(1, self.db.alt.chunks.count_documents({}))
204
205 self.alt.delete(oid)
206 with self.assertRaises(NoFile):
207 self.alt.get(oid)
208 self.assertEqual(0, self.db.alt.files.count_documents({}))
209 self.assertEqual(0, self.db.alt.chunks.count_documents({}))
210
211 with self.assertRaises(NoFile):
212 self.alt.get("foo")
213 oid = self.alt.put(b"hello world", _id="foo")
214 self.assertEqual("foo", oid)
215 self.assertEqual(b"hello world", (self.alt.get("foo")).read())
216
217 self.alt.put(b"", filename="mike")
218 self.alt.put(b"foo", filename="test")
219 self.alt.put(b"", filename="hello world")
220
221 self.assertEqual({"mike", "test", "hello world"}, set(self.alt.list()))
222
223 def test_threaded_reads(self):
224 self.fs.put(b"hello", _id="test")

Callers

nothing calls this directly

Calls 6

putMethod · 0.45
readMethod · 0.45
getMethod · 0.45
count_documentsMethod · 0.45
deleteMethod · 0.45
listMethod · 0.45

Tested by

no test coverage detected