File tree Expand file tree Collapse file tree 5 files changed +38
-2
lines changed Expand file tree Collapse file tree 5 files changed +38
-2
lines changed Original file line number Diff line number Diff line change @@ -154,3 +154,4 @@ dmypy.json
154
154
155
155
# MacOS specific
156
156
.DS_Store
157
+ results
Original file line number Diff line number Diff line change 1
- git+https://github.com/eclipse-velocitas/
[email protected] .
0
1
+ git+https://github.com/eclipse-velocitas/
[email protected] .
1
Original file line number Diff line number Diff line change @@ -826,6 +826,21 @@ class Model(Node):
826
826
def set_many (self ) -> BatchSetBuilder :
827
827
return BatchSetBuilder (self .get_client ())
828
828
829
+ def getNode (self , datapoint_str : str ) -> Node :
830
+ if self .get_path () not in datapoint_str :
831
+ raise ValueError ("Input string has to start with the root" )
832
+ nodes = datapoint_str .split ("." )
833
+ dataPoint = self
834
+
835
+ if len (nodes ) > 1 :
836
+ for node in nodes [1 :]:
837
+ try :
838
+ dataPoint = getattr (dataPoint , node )
839
+ except Exception as err :
840
+ raise AttributeError ("Node not found" ) from err
841
+
842
+ return dataPoint
843
+
829
844
830
845
class Service (Node ):
831
846
"""The Service class contains a set of gRPC methods"""
Original file line number Diff line number Diff line change 70
70
71
71
setup (
72
72
name = "sdv" ,
73
- version = "0.10.0 " ,
73
+ version = "0.10.1 " ,
74
74
description = "A Python SDK for Vehicle app" ,
75
75
long_description = long_description ,
76
76
long_description_content_type = "text/markdown" ,
Original file line number Diff line number Diff line change @@ -1512,6 +1512,26 @@ async def test_fail_setting_multiple_data_points_atomically():
1512
1512
)
1513
1513
1514
1514
1515
+ @pytest .mark .asyncio
1516
+ async def test_get_node__available ():
1517
+ vehicle = get_vehicle_instance ()
1518
+ assert vehicle .getNode (vehicle .Speed .get_path ()) == vehicle .Speed
1519
+
1520
+
1521
+ @pytest .mark .asyncio
1522
+ async def test_get_node__not_available ():
1523
+ vehicle = get_vehicle_instance ()
1524
+ with pytest .raises (AttributeError ):
1525
+ vehicle .getNode ("Vehicle.NotAvailable" )
1526
+
1527
+
1528
+ @pytest .mark .asyncio
1529
+ async def test_get_node__root_not_in_string ():
1530
+ vehicle = get_vehicle_instance ()
1531
+ with pytest .raises (ValueError ):
1532
+ vehicle .getNode ("Speed" )
1533
+
1534
+
1515
1535
DoorSides = ["Left" , "Right" ]
1516
1536
TrunkOptions = ["Front" , "Rear" ]
1517
1537
You can’t perform that action at this time.
0 commit comments