Skip to content

Commit 42eae0b

Browse files
committed
tests: fix prop name not specified in constructors objectbox#24
1 parent 018af55 commit 42eae0b

File tree

3 files changed

+10
-20
lines changed

3 files changed

+10
-20
lines changed

tests/model.py

-9
Original file line numberDiff line numberDiff line change
@@ -39,29 +39,20 @@ class TestEntity:
3939
flex = Property(Generic, type=PropertyType.flex, id=27, uid=1027)
4040
transient = "" # not "Property" so it's not stored
4141

42-
def __init__(self, string: str = ""):
43-
self.str = string
44-
4542

4643
@Entity(id=2, uid=2)
4744
class TestEntityDatetime:
4845
id = Id(id=1, uid=2001)
4946
date = Property(datetime, type=PropertyType.date, id=2, uid=2002)
5047
date_nano = Property(datetime, type=PropertyType.dateNano, id=3, uid=2003)
5148

52-
def __init__(self, string: str = ""):
53-
self.str = string
54-
5549

5650
@Entity(id=3, uid=3)
5751
class TestEntityFlex:
5852
id = Id(id=1, uid=3001)
5953
flex_dict = Property(Dict[str, Any], type=PropertyType.flex, id=2, uid=3002)
6054
flex_int = Property(int, type=PropertyType.flex, id=3, uid=3003)
6155

62-
def __init__(self, string: str = ""):
63-
self.str = string
64-
6556

6657
@Entity(id=4, uid=4)
6758
class VectorEntity:

tests/test_box.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ def test_box_bulk():
9999
ob = load_empty_test_objectbox()
100100
box = objectbox.Box(ob, TestEntity)
101101

102-
box.put(TestEntity("first"))
102+
box.put(TestEntity(str="first"))
103103

104-
objects = [TestEntity("second"), TestEntity("third"),
105-
TestEntity("fourth"), box.get(1)]
104+
objects = [TestEntity(str="second"), TestEntity(str="third"),
105+
TestEntity(str="fourth"), box.get(1)]
106106
box.put(objects)
107107
assert box.count() == 4
108108
assert objects[0].id == 2
@@ -185,7 +185,6 @@ def test_datetime():
185185

186186

187187
def test_flex():
188-
189188
def test_put_get(object: TestEntity, box: objectbox.Box, property):
190189
object.flex = property
191190
id = box.put(object)
@@ -221,7 +220,7 @@ def test_put_get(object: TestEntity, box: objectbox.Box, property):
221220

222221
# Update to dict
223222
test_put_get(object, box, {"a": 1, "b": 2})
224-
223+
225224
# Update to bool
226225
test_put_get(object, box, True)
227226

@@ -252,4 +251,4 @@ def test_flex_dict():
252251
assert id == object.id
253252
read = box.get(object.id)
254253
assert read.flex_dict == object.flex_dict
255-
assert read.flex_int == object.flex_int
254+
assert read.flex_int == object.flex_int

tests/test_transactions.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ def test_transactions():
1010
assert box.is_empty()
1111

1212
with ob.write_tx():
13-
box.put(TestEntity("first"))
14-
box.put(TestEntity("second"))
13+
box.put(TestEntity(str="first"))
14+
box.put(TestEntity(str="second"))
1515

1616
assert box.count() == 2
1717

1818
try:
1919
with ob.write_tx():
20-
box.put(TestEntity("third"))
21-
box.put(TestEntity("fourth"))
20+
box.put(TestEntity(str="third"))
21+
box.put(TestEntity(str="fourth"))
2222
raise Exception("mission abort!")
2323

2424
# exception must be propagated so this line must not execute
@@ -32,7 +32,7 @@ def test_transactions():
3232
# can't write in a read TX
3333
try:
3434
with ob.read_tx():
35-
box.put(TestEntity("third"))
35+
box.put(TestEntity(str="third"))
3636

3737
# exception must be propagated so this line must not execute
3838
assert 0

0 commit comments

Comments
 (0)