|
12 | 12 |
|
13 | 13 | from contextlib import contextmanager
|
14 | 14 | from lxml import etree as ET
|
| 15 | +from odml.terminology import REPOSITORY_BASE |
15 | 16 | from odml.tools.version_converter import VersionConverter
|
16 | 17 |
|
17 | 18 | try:
|
@@ -519,6 +520,31 @@ def test_convert_odml_file_value(self):
|
519 | 520 | self.assertEqual(len(prop), 1)
|
520 | 521 | self.assertEqual(len(prop.findall("name")), 1)
|
521 | 522 |
|
| 523 | + def test_handle_repository(self): |
| 524 | + repo = ET.Element("repository") |
| 525 | + |
| 526 | + # Test working and valid repository link |
| 527 | + repo.text = '/'.join([REPOSITORY_BASE, 'v1.1', 'analysis', 'analysis.xml']) |
| 528 | + vc = self.VC("") |
| 529 | + self.assertIsNone(vc._handle_repository(repo)) |
| 530 | + self.assertEqual(vc.conversion_log, []) |
| 531 | + |
| 532 | + # Test replaced working repository link |
| 533 | + repo.text = '/'.join([REPOSITORY_BASE, 'v1.0', 'analysis', 'analysis.xml']) |
| 534 | + self.assertIsNone(vc._handle_repository(repo)) |
| 535 | + self.assertEqual(repo.text, '/'.join([REPOSITORY_BASE, 'v1.1', |
| 536 | + 'analysis', 'analysis.xml'])) |
| 537 | + self.assertEqual(len(vc.conversion_log), 1) |
| 538 | + self.assertTrue("[Info]" in vc.conversion_log[0]) |
| 539 | + |
| 540 | + # Test invalid repository link |
| 541 | + invalid = "I am leading nowhere" |
| 542 | + repo.text = invalid |
| 543 | + self.assertIsNone(vc._handle_repository(repo)) |
| 544 | + self.assertEqual(len(vc.conversion_log), 2) |
| 545 | + self.assertTrue("[Warning]" in vc.conversion_log[1]) |
| 546 | + self.assertEqual(repo.text, invalid) |
| 547 | + |
522 | 548 | def test_convert_xml_file(self):
|
523 | 549 | # Test minimal reading from an xml file.
|
524 | 550 | basefile = os.path.join(self.basepath, "version_conversion.xml")
|
|
0 commit comments