Skip to content

Commit eaa905c

Browse files
committed
Tests: put objects in one call, update in one write tx #64
1 parent 6a9ca1f commit eaa905c

1 file changed

Lines changed: 7 additions & 14 deletions

File tree

‎tests/test_box.py‎

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,7 @@ def test_flex_values(test_store):
287287
def test_contains(test_store):
288288
box = test_store.box(TestEntity)
289289

290-
box.put(TestEntity(str="Object 1"))
291-
box.put(TestEntity(str="Object 2"))
292-
box.put(TestEntity(str="Object 3"))
290+
box.put([TestEntity(str=f"Object {i}") for i in range(1, 4)])
293291
assert box.count() == 3
294292

295293
assert box.contains(1)
@@ -305,14 +303,13 @@ def test_contains(test_store):
305303
def test_update(test_store):
306304
box = test_store.box(TestEntity)
307305

308-
box.put(TestEntity(str="Object 1"))
309-
box.put(TestEntity(str="Object 2"))
310-
box.put(TestEntity(str="Object 3"))
306+
box.put([TestEntity(str=f"Object {i}") for i in range(1, 4)])
311307
assert box.count() == 3
312308

313-
for obj in box.get_all():
314-
obj.str += " (updated)"
315-
box.update(obj)
309+
with test_store.write_tx():
310+
for obj in box.get_all():
311+
obj.str += " (updated)"
312+
box.update(obj)
316313

317314
assert box.get(1).str == "Object 1 (updated)"
318315
assert box.get(2).str == "Object 2 (updated)"
@@ -332,11 +329,7 @@ def test_update(test_store):
332329
def test_get_many(test_store):
333330
box = test_store.box(TestEntity)
334331

335-
box.put(TestEntity(str="Object 1"))
336-
box.put(TestEntity(str="Object 2"))
337-
box.put(TestEntity(str="Object 3"))
338-
box.put(TestEntity(str="Object 4"))
339-
box.put(TestEntity(str="Object 5"))
332+
box.put([TestEntity(str=f"Object {i}") for i in range(1, 6)])
340333
assert box.count() == 5
341334

342335
objects = box.get_many([1, 3, 4])

0 commit comments

Comments
 (0)