Skip to content

Commit

Permalink
Merge pull request #267 from RondoRondoRondo/dev
Browse files Browse the repository at this point in the history
Added fixtures/test.xml and test_scan_xml.py
  • Loading branch information
phutelmyer authored Dec 29, 2022
2 parents 5f5a0e2 + b256534 commit 695503e
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/python/strelka/tests/fixtures/test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0"?>
<package format="2">
<name>flea3</name>
<version>0.1.0</version>
<description>The flea3 package</description>

<maintainer email="[email protected]">Chao Qu</maintainer>

<license>WTFPL</license>
<buildtool_depend>catkin</buildtool_depend>

<depend>roscpp</depend>
<depend>nodelet</depend>
<depend>camera_base</depend>
<!--<depend>std_msgs</depend>-->
<depend>dynamic_reconfigure</depend>
<build_depend>message_generation</build_depend>
<exec_depend>message_runtime</exec_depend>

<export>
<nodelet plugin="${prefix}/nodelet_plugins.xml"/>
</export>
</package>
43 changes: 43 additions & 0 deletions src/python/strelka/tests/test_scan_xml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
from pathlib import Path
from unittest import TestCase, mock

from strelka.scanners.scan_xml import ScanXml as ScanUnderTest
from strelka.tests import run_test_scan


def test_scan_xml(mocker):
"""
Pass: Sample event matches output of scanner.
Failure: Unable to load file or sample event fails to match.
"""
test_scan_event = {
"elapsed": mock.ANY,
"namespaces": [None],
"tag_data": [],
"flags": [],
"tags": [
"package",
"name",
"version",
"description",
"maintainer",
"license",
"buildtool_depend",
"depend",
"build_depend",
"exec_depend",
"export",
"nodelet",
],
"total": {"extracted": 0, "tags": 15},
"version": "1.0",
}

scanner_event = run_test_scan(
mocker=mocker,
scan_class=ScanUnderTest,
fixture_path=Path(__file__).parent / "fixtures/test.xml",
)

TestCase.maxDiff = None
TestCase().assertDictEqual(test_scan_event, scanner_event)

0 comments on commit 695503e

Please sign in to comment.