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

Method test_get_version_with_metadata

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

Source from the content-addressed store, hash-verified

314 self.fs.get_version("test", -4)
315
316 def test_get_version_with_metadata(self):
317 one = self.fs.put(b"foo", filename="test", author="author1")
318 time.sleep(0.01)
319 two = self.fs.put(b"bar", filename="test", author="author1")
320 time.sleep(0.01)
321 three = self.fs.put(b"baz", filename="test", author="author2")
322
323 self.assertEqual(
324 b"foo",
325 (self.fs.get_version(filename="test", author="author1", version=-2)).read(),
326 )
327 self.assertEqual(
328 b"bar",
329 (self.fs.get_version(filename="test", author="author1", version=-1)).read(),
330 )
331 self.assertEqual(
332 b"foo",
333 (self.fs.get_version(filename="test", author="author1", version=0)).read(),
334 )
335 self.assertEqual(
336 b"bar",
337 (self.fs.get_version(filename="test", author="author1", version=1)).read(),
338 )
339 self.assertEqual(
340 b"baz",
341 (self.fs.get_version(filename="test", author="author2", version=0)).read(),
342 )
343 self.assertEqual(b"baz", (self.fs.get_version(filename="test", version=-1)).read())
344 self.assertEqual(b"baz", (self.fs.get_version(filename="test", version=2)).read())
345
346 with self.assertRaises(NoFile):
347 self.fs.get_version(filename="test", author="author3")
348 with self.assertRaises(NoFile):
349 self.fs.get_version(filename="test", author="author1", version=2)
350
351 self.fs.delete(one)
352 self.fs.delete(two)
353 self.fs.delete(three)
354
355 def test_put_filelike(self):
356 oid = self.fs.put(BytesIO(b"hello world"), chunk_size=1)

Callers

nothing calls this directly

Calls 4

putMethod · 0.45
readMethod · 0.45
get_versionMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected