MCPcopy Create free account
hub / github.com/cosdata/cosdata / test_bulk_upsert

Function test_bulk_upsert

tests/test-key-value-store.py:252–271  ·  view source on GitHub ↗

Test bulk upsert of multiple items

(name)

Source from the content-addressed store, hash-verified

250 results.fail(f"json: {key}", expected, actual)
251
252def test_bulk_upsert(name):
253 """Test bulk upsert of multiple items"""
254 print("\n[Test: Bulk Upsert]")
255
256 items = [(f"bulk_{i}", f"value_{i}") for i in range(100)]
257
258 run_in_txn(name, lambda t: bulk_upsert(name, t, items))
259
260 # Verify random samples
261 sample_indices = [0, 25, 50, 75, 99]
262 all_ok = True
263 for i in sample_indices:
264 key, expected = items[i]
265 actual = lookup(name, key)
266 if actual != expected:
267 all_ok = False
268 results.fail(f"bulk item {i}", expected, actual)
269
270 if all_ok:
271 results.ok("bulk upsert (100 items, sampled)")
272
273def test_key_not_found(name):
274 """Test lookup of non-existent key"""

Callers 1

mainFunction · 0.85

Calls 5

run_in_txnFunction · 0.85
bulk_upsertFunction · 0.85
failMethod · 0.80
okMethod · 0.80
lookupFunction · 0.70

Tested by

no test coverage detected