Skip to content

Commit 04522b9

Browse files
committed
store options: add unit test #41
1 parent ed66f7d commit 04522b9

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

tests/test_store_options.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
from objectbox.c import * # TODO ideally we wouldn't have to import c.py
2+
from objectbox.store_options import StoreOptions
3+
4+
5+
def test_set_options():
6+
""" Test setting dummy values for each option.
7+
Checks that Python types are correctly forwarded to C API. """
8+
9+
options = StoreOptions()
10+
options.directory("test-db")
11+
options.max_db_size_in_kb(8192)
12+
options.max_data_size_in_kb(4096)
13+
options.file_mode(755)
14+
options.max_readers(10)
15+
options.no_reader_thread_locals(False)
16+
# options.model
17+
# options.model_bytes
18+
# options.model_bytes_direct
19+
# options.validate_on_open_pages
20+
# options.validate_on_open_kv
21+
options.put_padding_mode(OBXPutPaddingMode_PaddingAutomatic)
22+
options.read_schema(False)
23+
options.use_previous_commit(False)
24+
options.read_only(True)
25+
options.debug_flags(OBXDebugFlags_LOG_TRANSACTIONS_READ)
26+
options.add_debug_flags(OBXDebugFlags_LOG_CACHE_HITS)
27+
options.async_max_queue_length(100)
28+
options.async_throttle_at_queue_length(1024)
29+
options.async_throttle_micros(1000)
30+
options.async_max_in_tx_duration(1000)
31+
options.async_max_in_tx_operations(20)
32+
options.async_pre_txn_delay(500)
33+
options.async_pre_txn_delay4(500, 700, 100)
34+
options.async_post_txn_delay(500)
35+
options.async_post_txn_delay5(500, 700, 100, False)
36+
options.async_minor_refill_threshold(100)
37+
options.async_minor_refill_max_count(500)
38+
options.async_max_tx_pool_size(100)
39+
options.async_object_bytes_max_cache_size(4096)
40+
options.async_object_bytes_max_size_to_cache(4096)
41+
# options.log_callback
42+
# options.backup_restore
43+
44+
assert options.get_directory() == "test-db"
45+
assert options.get_max_db_size_in_kb() == 8192
46+
assert options.get_max_data_size_in_kb() == 4096
47+
assert options.get_debug_flags() == (OBXDebugFlags_LOG_TRANSACTIONS_READ | OBXDebugFlags_LOG_CACHE_HITS)
48+
49+
del options

0 commit comments

Comments
 (0)