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

Method test_basic

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

Source from the content-addressed store, hash-verified

102 )
103
104 def test_basic(self):
105 oid = self.fs.put(b"hello world")
106 self.assertEqual(b"hello world", (self.fs.get(oid)).read())
107 self.assertEqual(1, self.db.fs.files.count_documents({}))
108 self.assertEqual(1, self.db.fs.chunks.count_documents({}))
109
110 self.fs.delete(oid)
111 with self.assertRaises(NoFile):
112 self.fs.get(oid)
113 self.assertEqual(0, self.db.fs.files.count_documents({}))
114 self.assertEqual(0, self.db.fs.chunks.count_documents({}))
115
116 with self.assertRaises(NoFile):
117 self.fs.get("foo")
118 oid = self.fs.put(b"hello world", _id="foo")
119 self.assertEqual("foo", oid)
120 self.assertEqual(b"hello world", (self.fs.get("foo")).read())
121
122 def test_multi_chunk_delete(self):
123 self.db.fs.drop()

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected