Support .zip and .csar extension for CSAR files
Support .csar as well as .zip for input CSAR files. Add unit tests to verify that both .zip and .csar extensions are validated and parsed properly. Change-Id: I9d531ceb0e2e1bd36817692677dcbf2b5d5520a9 Closes-Bug: #1506163
This commit is contained in:
parent
fe83d5977f
commit
96c16ad97a
BIN
toscaparser/tests/data/CSAR/csar_elk.csar
Normal file
BIN
toscaparser/tests/data/CSAR/csar_elk.csar
Normal file
Binary file not shown.
@ -221,3 +221,10 @@ class CSARPrereqTest(TestCase):
|
||||
shutil.rmtree(csar.temp_dir)
|
||||
self.assertTrue(csar.temp_dir is None or
|
||||
not os.path.exists(csar.temp_dir))
|
||||
|
||||
def test_alternate_csar_extension(self):
|
||||
path = os.path.join(self.base_path, "data/CSAR/csar_elk.csar")
|
||||
csar = CSAR(path)
|
||||
self.assertIsNone(csar.validate())
|
||||
self.assertTrue(csar.temp_dir is None or
|
||||
not os.path.exists(csar.temp_dir))
|
||||
|
@ -456,3 +456,10 @@ class ToscaTemplateTest(TestCase):
|
||||
ValueError,
|
||||
lambda: ToscaTemplate(template_file, None, False))
|
||||
self.assertEqual(expected_msg, err.__str__())
|
||||
|
||||
def test_csar_with_alternate_extenstion(self):
|
||||
tosca_tpl = os.path.join(
|
||||
os.path.dirname(os.path.abspath(__file__)),
|
||||
"data/CSAR/csar_elk.csar")
|
||||
tosca = ToscaTemplate(tosca_tpl)
|
||||
self.assertTrue(tosca.topology_template.custom_defs)
|
||||
|
@ -170,7 +170,7 @@ class ToscaTemplate(object):
|
||||
def _get_path(self, path):
|
||||
if path.lower().endswith('.yaml'):
|
||||
return path
|
||||
elif path.lower().endswith('.zip'):
|
||||
elif path.lower().endswith(('.zip', '.csar')):
|
||||
# a CSAR archive
|
||||
csar = CSAR(path, self.a_file)
|
||||
csar.validate()
|
||||
|
Loading…
x
Reference in New Issue
Block a user