| 346 | four.name |
| 347 | |
| 348 | def test_write_file_like(self): |
| 349 | one = GridIn(self.db.fs) |
| 350 | one.write(b"hello world") |
| 351 | one.close() |
| 352 | |
| 353 | two = GridOut(self.db.fs, one._id) |
| 354 | |
| 355 | three = GridIn(self.db.fs) |
| 356 | three.write(two) |
| 357 | three.close() |
| 358 | |
| 359 | four = GridOut(self.db.fs, three._id) |
| 360 | self.assertEqual(b"hello world", four.read()) |
| 361 | |
| 362 | five = GridIn(self.db.fs, chunk_size=2) |
| 363 | five.write(b"hello") |
| 364 | buffer = BytesIO(b" world") |
| 365 | five.write(buffer) |
| 366 | five.write(b" and mongodb") |
| 367 | five.close() |
| 368 | self.assertEqual(b"hello world and mongodb", GridOut(self.db.fs, five._id).read()) |
| 369 | |
| 370 | def test_write_lines(self): |
| 371 | a = GridIn(self.db.fs) |