Skip to content

Commit

Permalink
adding example for speed signs, adding exception if unit is not added…
Browse files Browse the repository at this point in the history
… with a value for signals
  • Loading branch information
mander76 committed Jan 26, 2024
1 parent c922f4c commit bb69109
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
7 changes: 5 additions & 2 deletions scenariogeneration/xodr/signals_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
LaneType,
Access,
)
from .exceptions import GeneralIssueInputArguments
from .exceptions import GeneralIssueInputArguments, NotEnoughInputArguments
from .utils import XodrBase


Expand Down Expand Up @@ -369,9 +369,12 @@ def get_attributes(self):
retdict["countryRevision"] = str(self.countryRevision)
if self.hOffset is not None:
retdict["hOffset"] = str(self.hOffset)
# TODO check if value is supplied --> unit is mandatory in that case
if self.value is not None:
retdict["value"] = str(self.value)
if self.unit is None:
raise NotEnoughInputArguments(
"If value is set for a signal, unit has to be added aswell"
)
retdict["unit"] = str(self.unit)
return retdict

Expand Down
3 changes: 3 additions & 0 deletions tests/test_signals_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,9 @@ def test_signal():
version_validation("t_road", road, wanted_schema="xodr")
== ValidationResponse.OK
)
with pytest.raises(xodr.NotEnoughInputArguments):
sig = xodr.Signal(100, 2, "se", "c", "31", value="10")
sig.get_attributes()


def test_signal_reference():
Expand Down
1 change: 1 addition & 0 deletions tests/test_xml_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ def test_OSC_1_2(tmpdir, python_file):
"clothoid_generation",
"adjustable_planview",
"super_elevation_automation_example",
"road_with_speed_signs",
],
)
def test_ODR(tmpdir, python_file):
Expand Down

0 comments on commit bb69109

Please sign in to comment.