def test_SADParser_usesdeviceref(self):
sad = parsers.SADParser.parse("sdr/parser_tests/usesdeviceref.sad.xml")
self.assertEqual(sad.get_id(), "colloc_usesdev_1")
self.assertEqual(sad.get_name(), "colloc_usesdev")
self.assertEqual(len(sad.componentfiles.get_componentfile()), 1)
self.assertEqual(len(sad.partitioning.get_hostcollocation()), 1)
colloc=sad.partitioning.get_hostcollocation()[0]
self.assertEqual(len(colloc.get_componentplacement()),1)
comp_place =colloc.get_componentplacement()[0]
self.assertEqual(len(comp_place.get_componentinstantiation()),1)
comp_ci=comp_place.get_componentinstantiation()[0]
self.assertEqual(comp_ci.id_, "P1_1")
self.assertEqual(comp_ci.get_usagename(), "P1_1")
self.assertEqual(len(colloc.get_usesdeviceref()),1)
udev_ref =colloc.get_usesdeviceref()[0]
self.assertEqual(udev_ref.refid, "FrontEndTuner_1")
# Verify that we can write the output and still be DTD valid
tmpfile = tempfile.mktemp()
try:
tmp = open(tmpfile, "w")
sad.export(tmp, 0)
tmp.close()
status = self._xmllint(tmpfile, "SAD")
self.assertEqual(status, 0, "Python parser did not emit DTD compliant XML")
finally:
try:
os.remove(tmpfile)
except OSError:
pass
test_07_PythonParsers.py 文件源码
python
阅读 32
收藏 0
点赞 0
评论 0
评论列表
文章目录