@@ -54,7 +54,8 @@ def test_empty_model(env):
5454
5555 # JSON file didn't exist, user syncs an empty model -> no JSON file is generated
5656 model = Model ()
57- assert not env .sync (model )
57+ with pytest .raises (ValueError ):
58+ assert not env .sync (model )
5859 assert not path .exists (env .model_path )
5960
6061 # Init the JSON file with an entity
@@ -65,31 +66,14 @@ class MyEntity:
6566 model .entity (MyEntity )
6667 assert env .sync (model ) # Model JSON written
6768
68- # JSON file exists, user syncs an empty model -> JSON file is written but entities are cleared (last ID/UID
69- # retained)
69+ # JSON file exists, user tries to sync an empty model: must fail with JSON file untouched
7070 model = Model ()
71- assert env .sync (model )
71+ with pytest .raises (ValueError ):
72+ env .sync (model )
7273
7374 doc = env .json ()
74- assert doc ['_note1' ]
75- assert doc ['_note2' ]
76- assert doc ['_note3' ]
77- assert len (doc ['entities' ]) == 0
78- # Last entity ID/UID will still be set at MyEntity's ID/UID
79- # assert doc['lastEntityId'] == '0:0'
80- # assert doc['lastIndexId'] == '0:0' # NOTE: objectbox-generator outputs ""
81- assert doc ['modelVersionParserMinimum' ] >= 5
82- # debug: pprint(doc)
83- #
84- # TODO: sync with objectbox-generator empty fbs
85- # assert doc['modelVersion'] == 5
86- # assert doc['lastIndex'] == ""
87- # assert doc['lastRelationId'] == ""
88- # assert len(doc['retiredEntityUids']) == 0
89- # assert len(doc['retiredIndexUids']) == 0
90- # assert len(doc['retiredPropertyUids']) == 0
91- # assert len(doc['retiredRelationUids']) == 0
92- # assert len(doc['version']) == 1
75+ assert len (doc ['entities' ]) == 1
76+ assert doc ['entities' ][0 ]['id' ] == str (MyEntity .iduid )
9377
9478
9579def test_json (env ):
@@ -311,6 +295,8 @@ class Entity4:
311295 name = String () # Add one property also
312296
313297 model = Model ()
298+ reset_ids (Entity1 )
299+ reset_ids (Entity3 )
314300 model .entity (Entity1 )
315301 model .entity (Entity3 )
316302 model .entity (Entity4 )
0 commit comments