Skip to content

Commit e4d9062

Browse files
committed
[test/versionConv] Add _handle_repository test
1 parent 32e8eee commit e4d9062

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

test/test_version_converter.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
from contextlib import contextmanager
1414
from lxml import etree as ET
15+
from odml.terminology import REPOSITORY_BASE
1516
from odml.tools.version_converter import VersionConverter
1617

1718
try:
@@ -519,6 +520,31 @@ def test_convert_odml_file_value(self):
519520
self.assertEqual(len(prop), 1)
520521
self.assertEqual(len(prop.findall("name")), 1)
521522

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+
522548
def test_convert_xml_file(self):
523549
# Test minimal reading from an xml file.
524550
basefile = os.path.join(self.basepath, "version_conversion.xml")

0 commit comments

Comments
 (0)