Ensure that a boolean test of a FileField indicates its presence
(self)
| 282 | assert test_file.the_file.get().length == 4971 |
| 283 | |
| 284 | def test_file_boolean(self): |
| 285 | """Ensure that a boolean test of a FileField indicates its presence""" |
| 286 | |
| 287 | class TestFile(Document): |
| 288 | the_file = FileField() |
| 289 | |
| 290 | TestFile.drop_collection() |
| 291 | |
| 292 | test_file = TestFile() |
| 293 | assert not bool(test_file.the_file) |
| 294 | test_file.the_file.put(b"Hello, World!", content_type="text/plain") |
| 295 | test_file.save() |
| 296 | assert bool(test_file.the_file) |
| 297 | |
| 298 | test_file = TestFile.objects.first() |
| 299 | assert test_file.the_file.content_type == "text/plain" |
| 300 | |
| 301 | def test_file_cmp(self): |
| 302 | """Test comparing against other types""" |
nothing calls this directly
no test coverage detected