
This commit aims to support helm-charts passed as dir, git url or as a .tar package and unit tests for these functionalities. It also removes some of the remanescent Armada sections from the app_manifest.yaml that i forgot to remove in review 902843 and correct some little flake8 warnings. Test Plan: PASS - Helm charts passed as dir in the app_manifest path are working as expected PASS - Helm charts passed as git url in the app_manifest path are working as expected PASS - Helm charts passed as tar packages in the app_manifest path are working as expected Story: 2010937 Task: 49130 Task: 49131 Change-Id: I1fc0e98f731c9a43f742b94d2044c57291876fc0 Signed-off-by: Tomás Barros <tomas.barros@encora.com>
60 lines
2.3 KiB
Python
60 lines
2.3 KiB
Python
"""This testfile tests the common functions used across the repository"""
|
|
import os
|
|
import shutil
|
|
from app_gen_tool.common import to_camel_case
|
|
from app_gen_tool.common import extract, transform_rel_path_into_abs_path
|
|
|
|
class CommonFunctions:
|
|
|
|
def __init__(self):
|
|
self.current_file = os.path.abspath(__file__)
|
|
self.current_folder = os.path.dirname(self.current_file)
|
|
self.resource_folder = os.path.join(self.current_folder, 'resources')
|
|
|
|
def setup_class(cls):
|
|
pass
|
|
|
|
def teardown_class(cls):
|
|
pass
|
|
|
|
def test_camel_case(self):
|
|
|
|
input_string = "ThisIsAString"
|
|
output_string = to_camel_case(input_string)
|
|
|
|
assert output_string == input_string.lower()
|
|
|
|
def test_tar_extraction(self):
|
|
"""Test tar extraction function"""
|
|
tmp_folder = os.path.join('/tmp', "tmp-tar-test")
|
|
try:
|
|
if not os.path.exists(tmp_folder):
|
|
os.makedirs(tmp_folder, exist_ok=False)
|
|
app_name = 'tempo-vulture'
|
|
tarfile = 'tempo-vulture-0.4.1.tgz'
|
|
tarfile_path = os.path.join(self.resource_folder, tarfile)
|
|
extract(tarfile_path, tmp_folder)
|
|
assert os.path.exists(os.path.join(tmp_folder, app_name))
|
|
except Exception as e:
|
|
print(f"Exception error {e} occurred!")
|
|
assert False
|
|
finally:
|
|
if os.path.exists(tmp_folder):
|
|
shutil.rmtree(tmp_folder)
|
|
assert not os.path.exists(tmp_folder)
|
|
|
|
def test_transform_path_function(self):
|
|
rel_path_1 = '../../../../example/poc-starlingx-messages'
|
|
rel_path_2 = '../../../../example/tempo-vulture/tempo-vulture-0.4.1.tgz'
|
|
rel_path_3 = './resources/adminer-0.2.1.tgz'
|
|
tar_name_1 = '/tempo-vulture-0.4.1.tgz'
|
|
tar_name_2 = '/adminer-0.2.1.tgz'
|
|
abs_path_1 = transform_rel_path_into_abs_path(rel_path_1)
|
|
abs_path_2 = transform_rel_path_into_abs_path(rel_path_2)
|
|
abs_path_3 = transform_rel_path_into_abs_path(rel_path_3)
|
|
abs_path_2 = abs_path_2.replace(tar_name_1, '', 1)
|
|
abs_path_3 = abs_path_3.replace(tar_name_2, '', 1)
|
|
if os.path.exists(abs_path_1) and os.path.exists(abs_path_2) and os.path.exists(abs_path_3):
|
|
assert True
|
|
assert False
|