-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix plugin xml parsing with multiple library tags (#268)
* Fix plugin xml parsing with multiple library tags * Add bazel_ros2_rules tests to CI
- Loading branch information
Showing
6 changed files
with
111 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import tempfile | ||
import unittest | ||
|
||
from ros2bzl.scraping.metadata import parse_plugins_description_xml | ||
|
||
|
||
class PluginXmlParsingTest(unittest.TestCase): | ||
|
||
def test_one_library(self): | ||
with tempfile.NamedTemporaryFile(mode='w') as pxml: | ||
pxml.write(""" | ||
<library path="foobar"> | ||
<class type="pkg::FooBar" base_class_type="pkg::World"> | ||
<description>baz</description> | ||
</class> | ||
</library> | ||
""") | ||
pxml.flush() | ||
result = parse_plugins_description_xml(pxml.name) | ||
self.assertIn('plugin_libraries', result) | ||
self.assertEqual(['foobar'], result['plugin_libraries']) | ||
|
||
def test_class_libraries_one_library(self): | ||
with tempfile.NamedTemporaryFile(mode='w') as pxml: | ||
pxml.write(""" | ||
<class_libraries> | ||
<library path="foobar"> | ||
<class type="pkg::FooBar" base_class_type="pkg::World"> | ||
<description>foobar?</description> | ||
</class> | ||
</library> | ||
</class_libraries> | ||
""") | ||
pxml.flush() | ||
result = parse_plugins_description_xml(pxml.name) | ||
self.assertIn('plugin_libraries', result) | ||
self.assertEqual(['foobar'], result['plugin_libraries']) | ||
|
||
def test_class_libraries_two_library(self): | ||
with tempfile.NamedTemporaryFile(mode='w') as pxml: | ||
pxml.write(""" | ||
<class_libraries> | ||
<library path="foobar"> | ||
<class type="pkg::FooBar" base_class_type="pkg::World"> | ||
<description>foobar?</description> | ||
</class> | ||
</library> | ||
<library path="bazfoo"> | ||
<class type="pkg::BazFoo" base_class_type="pkg::World"> | ||
<description>bazfoo?</description> | ||
</class> | ||
</library> | ||
</class_libraries> | ||
""") | ||
pxml.flush() | ||
result = parse_plugins_description_xml(pxml.name) | ||
self.assertIn('plugin_libraries', result) | ||
self.assertEqual(['foobar', 'bazfoo'], result['plugin_libraries']) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters