-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathtest_blob.py
More file actions
34 lines (24 loc) · 812 Bytes
/
test_blob.py
File metadata and controls
34 lines (24 loc) · 812 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import pytest
from sqlobject import BLOBCol, SQLObject
from sqlobject.compat import PY2
from sqlobject.tests.dbtest import setupClass, supports
########################################
# BLOB columns
########################################
class ImageData(SQLObject):
image = BLOBCol(default=b'emptydata', length=256)
def test_BLOBCol():
if not supports('blobData'):
pytest.skip("blobData isn't supported")
setupClass(ImageData)
if PY2:
data = ''.join([chr(x) for x in range(256)])
else:
data = bytes(range(256))
prof = ImageData(image=data)
iid = prof.id
ImageData._connection.cache.clear()
prof2 = ImageData.get(iid)
assert prof2.image == data
ImageData(image=b'string')
assert ImageData.selectBy(image=b'string').count() == 1