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

Method test_basic

test/test_grid_file.py:103–126  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

101 self.cleanup_colls(self.db.fs.files, self.db.fs.chunks)
102
103 def test_basic(self):
104 f = GridIn(self.db.fs, filename="test")
105 f.write(b"hello world")
106 f.close()
107 self.assertEqual(1, self.db.fs.files.count_documents({}))
108 self.assertEqual(1, self.db.fs.chunks.count_documents({}))
109
110 g = GridOut(self.db.fs, f._id)
111 self.assertEqual(b"hello world", g.read())
112
113 # make sure it's still there...
114 g = GridOut(self.db.fs, f._id)
115 self.assertEqual(b"hello world", g.read())
116
117 f = GridIn(self.db.fs, filename="test")
118 f.close()
119 self.assertEqual(2, self.db.fs.files.count_documents({}))
120 self.assertEqual(1, self.db.fs.chunks.count_documents({}))
121
122 g = GridOut(self.db.fs, f._id)
123 self.assertEqual(b"", g.read())
124
125 # test that reading 0 returns proper type
126 self.assertEqual(b"", g.read(0))
127
128 def test_md5(self):
129 f = GridIn(self.db.fs)

Callers

nothing calls this directly

Calls 6

writeMethod · 0.95
closeMethod · 0.95
readMethod · 0.95
GridInClass · 0.90
GridOutClass · 0.90
count_documentsMethod · 0.45

Tested by

no test coverage detected