def setUp(self):
"""Setup test."""
from base64 import b64encode, b64decode
from bson.binary import Binary, BINARY_SUBTYPE
class BinaryTest(db.Document):
text = db.BinaryField()
self.model_cls = BinaryTest
self.data = {
"text": {
"data": b64encode(
("This is a test").encode("utf-8")
).decode("utf-8"),
"type": BINARY_SUBTYPE
}
}
self.expected_data = {
"text": Binary(
b64decode(self.data["text"]["data"]),
self.data["text"]["type"]
)
}
self.data = json.dumps(self.data)
self.hook = generate_object_hook(BinaryTest)
评论列表
文章目录