Skip to content

Commit

Permalink
Merge pull request #16 from asam-ev/2024-07-10
Browse files Browse the repository at this point in the history
Remove file type from result format and add a minor improvement
  • Loading branch information
pmai authored Jul 18, 2024
2 parents 41924ab + 7db3796 commit 914e1f2
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 10 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ def main():
issue_id=issue_id,
row=1,
column=0,
file_type="odr",
description="Location for issue",
)

Expand Down
1 change: 0 additions & 1 deletion qc_baselib/models/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class InertialLocationType(BaseXmlModel):
class FileLocationType(BaseXmlModel):
column: int = attr(name="column")
row: int = attr(name="row")
file_type: str = attr(name="fileType")


class LocationType(BaseXmlModel):
Expand Down
14 changes: 9 additions & 5 deletions qc_baselib/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,11 @@ def add_file_location(
issue_id: int,
row: int,
column: int,
file_type: str,
description: str,
) -> None:
file_location = result.FileLocationType(
row=row,
column=column,
file_type=file_type,
)

bundle = self._get_checker_bundle(checker_bundle_name=checker_bundle_name)
Expand All @@ -282,18 +280,24 @@ def add_xml_location(
checker_bundle_name: str,
checker_id: str,
issue_id: int,
xpath: str,
xpath: Union[str, List[str]],
description: str,
) -> None:
xml_location = result.XMLLocationType(xpath=xpath)
xml_locations = []

if type(xpath) == str:
xml_locations.append(result.XMLLocationType(xpath=xpath))
elif type(xpath) == list:
for path in xpath:
xml_locations.append(result.XMLLocationType(xpath=path))

bundle = self._get_checker_bundle(checker_bundle_name=checker_bundle_name)

checker = self._get_checker(bundle=bundle, checker_id=checker_id)
issue = self._get_issue(checker=checker, issue_id=issue_id)

issue.locations.append(
result.LocationType(xml_location=[xml_location], description=description)
result.LocationType(xml_location=xml_locations, description=description)
)

def add_inertial_location(
Expand Down
6 changes: 5 additions & 1 deletion tests/data/result_test_output.xqar
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@
<AddressedRule ruleUID="test.com:qc:1.0.0:qwerty.qwerty"/>
<Issue issueId="0" description="Issue found at odr" level="3" ruleUID="test.com:qc:1.0.0:qwerty.qwerty">
<Locations description="Location for issue">
<FileLocation column="0" row="1" fileType="odr"/>
<FileLocation column="0" row="1"/>
</Locations>
<Locations description="Location for issue">
<XMLLocation xpath="/foo/test/path"/>
</Locations>
<Locations description="Location for issue with list">
<XMLLocation xpath="/foo/test/path"/>
<XMLLocation xpath="/bar/test/path"/>
</Locations>
<Locations description="Location for issue">
<InertialLocation x="1.0" y="2.0" z="3.0"/>
</Locations>
Expand Down
9 changes: 7 additions & 2 deletions tests/test_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ def test_result_write() -> None:
issue_id=issue_id,
row=1,
column=0,
file_type="odr",
description="Location for issue",
)
result.add_xml_location(
Expand All @@ -89,6 +88,13 @@ def test_result_write() -> None:
xpath="/foo/test/path",
description="Location for issue",
)
result.add_xml_location(
checker_bundle_name="TestBundle",
checker_id="TestChecker",
issue_id=issue_id,
xpath=["/foo/test/path", "/bar/test/path"],
description="Location for issue with list",
)
result.add_inertial_location(
checker_bundle_name="TestBundle",
checker_id="TestChecker",
Expand Down Expand Up @@ -439,7 +445,6 @@ def test_domain_specific_info_add():
issue_id=issue_id,
row=1,
column=0,
file_type="odr",
description="Location for issue",
)

Expand Down

0 comments on commit 914e1f2

Please sign in to comment.