Skip to content

Commit c6cfc4b

Browse files
committed
cp to tests
1 parent 6935e87 commit c6cfc4b

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

tests/test_bypass_serialization.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import datajoint as dj
2+
import numpy as np
3+
4+
from . import PREFIX, CONN_INFO
5+
from numpy.testing import assert_array_equal
6+
from nose.tools import assert_true
7+
8+
9+
schema_in = dj.Schema(
10+
PREFIX + "_test_bypass_serialization_in", connection=dj.conn(**CONN_INFO)
11+
)
12+
13+
schema_out = dj.Schema(
14+
PREFIX + "_test_blob_bypass_serialization_out", connection=dj.conn(**CONN_INFO)
15+
)
16+
17+
18+
test_blob = np.array([1, 2, 3])
19+
20+
21+
@schema_in
22+
class Input(dj.Lookup):
23+
definition = """
24+
id: int
25+
---
26+
data: blob
27+
"""
28+
contents = [(0, test_blob)]
29+
30+
31+
@schema_out
32+
class Output(dj.Manual):
33+
definition = """
34+
id: int
35+
---
36+
data: blob
37+
"""
38+
39+
40+
def test_bypass_serialization():
41+
dj.blob.bypass_serialization = True
42+
contents = Input.fetch(as_dict=True)
43+
assert_true(isinstance(contents[0]["data"], bytes))
44+
Output.insert(contents)
45+
dj.blob.bypass_serialization = False
46+
assert_array_equal(Input.fetch1("data"), Output.fetch1("data"))

0 commit comments

Comments
 (0)