MCPcopy Index your code
hub / github.com/MongoEngine/mongoengine / test_file_boolean

Method test_file_boolean

tests/fields/test_file_field.py:284–299  ·  view source on GitHub ↗

Ensure that a boolean test of a FileField indicates its presence

(self)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 5

TestFileClass · 0.85
drop_collectionMethod · 0.80
putMethod · 0.45
saveMethod · 0.45
firstMethod · 0.45

Tested by

no test coverage detected