Skip to content

Commit

Permalink
tests: fix prop name not specified in constructors objectbox#24
Browse files Browse the repository at this point in the history
  • Loading branch information
loryruta committed Apr 10, 2024
1 parent 018af55 commit 42eae0b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 20 deletions.
9 changes: 0 additions & 9 deletions tests/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,20 @@ class TestEntity:
flex = Property(Generic, type=PropertyType.flex, id=27, uid=1027)
transient = "" # not "Property" so it's not stored

def __init__(self, string: str = ""):
self.str = string


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

def __init__(self, string: str = ""):
self.str = string


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

def __init__(self, string: str = ""):
self.str = string


@Entity(id=4, uid=4)
class VectorEntity:
Expand Down
11 changes: 5 additions & 6 deletions tests/test_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ def test_box_bulk():
ob = load_empty_test_objectbox()
box = objectbox.Box(ob, TestEntity)

box.put(TestEntity("first"))
box.put(TestEntity(str="first"))

objects = [TestEntity("second"), TestEntity("third"),
TestEntity("fourth"), box.get(1)]
objects = [TestEntity(str="second"), TestEntity(str="third"),
TestEntity(str="fourth"), box.get(1)]
box.put(objects)
assert box.count() == 4
assert objects[0].id == 2
Expand Down Expand Up @@ -185,7 +185,6 @@ def test_datetime():


def test_flex():

def test_put_get(object: TestEntity, box: objectbox.Box, property):
object.flex = property
id = box.put(object)
Expand Down Expand Up @@ -221,7 +220,7 @@ def test_put_get(object: TestEntity, box: objectbox.Box, property):

# Update to dict
test_put_get(object, box, {"a": 1, "b": 2})

# Update to bool
test_put_get(object, box, True)

Expand Down Expand Up @@ -252,4 +251,4 @@ def test_flex_dict():
assert id == object.id
read = box.get(object.id)
assert read.flex_dict == object.flex_dict
assert read.flex_int == object.flex_int
assert read.flex_int == object.flex_int
10 changes: 5 additions & 5 deletions tests/test_transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ def test_transactions():
assert box.is_empty()

with ob.write_tx():
box.put(TestEntity("first"))
box.put(TestEntity("second"))
box.put(TestEntity(str="first"))
box.put(TestEntity(str="second"))

assert box.count() == 2

try:
with ob.write_tx():
box.put(TestEntity("third"))
box.put(TestEntity("fourth"))
box.put(TestEntity(str="third"))
box.put(TestEntity(str="fourth"))
raise Exception("mission abort!")

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

# exception must be propagated so this line must not execute
assert 0
Expand Down

0 comments on commit 42eae0b

Please sign in to comment.