Skip to content

Commit aeeac82

Browse files
committed
test_box: check result for get/remove on missing id #32
1 parent e05aa2e commit aeeac82

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

tests/test_box.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,17 @@ def test_box_basics():
7777

7878
# remove
7979
box.remove(object)
80-
box.remove(1)
80+
81+
# remove should return success
82+
success = box.remove(1)
83+
assert success == True
84+
success = box.remove(1)
85+
assert success == False
8186

8287
# check they're gone
8388
assert box.count() == 0
84-
with pytest.raises(objectbox.NotFoundException):
85-
box.get(object.id)
86-
with pytest.raises(objectbox.NotFoundException):
87-
box.get(1)
89+
assert box.get(object.id) == None
90+
assert box.get(1) == None
8891

8992
ob.close()
9093

@@ -166,14 +169,13 @@ def test_datetime():
166169
assert pytest.approx(read.date.timestamp()) == object.date.timestamp()
167170

168171
# remove
169-
box.remove(object)
172+
success = box.remove(object)
173+
assert success == True
170174

171175
# check they're gone
172176
assert box.count() == 0
173-
with pytest.raises(objectbox.NotFoundException):
174-
box.get(object.id)
175-
with pytest.raises(objectbox.NotFoundException):
176-
box.get(1)
177+
assert box.get(object.id) == None
178+
assert box.get(1) == None
177179

178180
ob.close()
179181

0 commit comments

Comments
 (0)