| 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") |