forked from objectbox/objectbox-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_inmemory.py
More file actions
31 lines (28 loc) · 775 Bytes
/
Copy pathtest_inmemory.py
File metadata and controls
31 lines (28 loc) · 775 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
import objectbox
from tests.common import create_test_store
from tests.model import TestEntity
import os.path
import shutil
def test_inmemory():
# Use default path for persistent store
db_name = "testdata"
store = create_test_store(db_name)
box = store.box(TestEntity)
object = TestEntity()
id = box.put(object)
assert id == 1
assert id == object.id
assert os.path.exists(db_name)
del box
store.close()
shutil.rmtree(db_name)
# Expect no path for in-memory store
db_name = "memory:testdata"
store = create_test_store(db_name)
box = store.box(TestEntity)
object = TestEntity()
id = box.put(object)
assert id == 1
assert id == object.id
assert not os.path.exists(db_name)
store.close()