File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -442,7 +442,7 @@ def decode_dataclass_dict(data):
442442def get_instance (instance_id : str ):
443443 # print(f"get_instance({instance_id})")
444444 # print(" => ", INSTANCES[instance_id])
445- return INSTANCES [ instance_id ]
445+ return INSTANCES . get ( instance_id )
446446
447447
448448class ServerOnly :
Original file line number Diff line number Diff line change 55 StateDataModel ,
66 Sync ,
77 TypeValidation ,
8+ get_instance ,
89)
910
1011
@@ -82,3 +83,12 @@ class BasicSerial(StateDataModel):
8283 assert isinstance (set_as_list , list )
8384 for obj in data .f :
8485 assert obj ._id in set_as_list
86+
87+
88+ def test_get_instance ():
89+ class Dummy (StateDataModel ):
90+ a = Sync (int , 0 )
91+
92+ inst = Dummy ()
93+ assert get_instance (inst ._id ) is inst
94+ assert get_instance ("not an id" ) is None
You can’t perform that action at this time.
0 commit comments