-
Notifications
You must be signed in to change notification settings - Fork 37
/
plugin_xml_parsing_test.py
62 lines (54 loc) · 2.33 KB
/
plugin_xml_parsing_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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()