Changeset 2fb99de in flex_extract.git for python/pythontest/TestInstall.py
- Timestamp:
- Sep 20, 2018, 11:56:37 AM (6 years ago)
- Branches:
- master, ctbto, dev
- Children:
- 5d42acd
- Parents:
- 3232589
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/pythontest/TestInstall.py
r067a0c3 r2fb99de 6 6 import os 7 7 import inspect 8 sys.path.append('../python') 8 sys.path.append('../') 9 import _config 9 10 import install 11 from tools import make_dir 10 12 11 13 … … 17 19 pass 18 20 21 # - main 22 # - get_install_cmdline_arguments 23 # - install_via_gateway 24 #! - mk_tarball 25 #! - un_tarball 26 # - mk_env_vars 27 # - mk_compilejob 28 # - mk_job_template 29 # - delete_convert_build 30 # - make_convert_build 19 31 20 32 def test_mk_tarball(self): 21 ecd = os.path.dirname(os.path.abspath(inspect.getfile( 22 inspect.currentframe()))) + '/../' 23 #print ecd 24 install.mk_tarball(ecd) 33 import tarfile 25 34 35 ecd = _config.PATH_FLEXEXTRACT_DIR + os.path.sep 36 37 # list comparison files for tarball content 38 tar_test_dir = os.path.join(_config.PATH_TEST_DIR + 39 os.path.sep + 'TestInstallTar') 40 tar_test_fedir = os.path.join(tar_test_dir, 'flex_extract_v7.1') 41 42 comparison_list = [] 43 for path, subdirs, files in os.walk(tar_test_fedir): 44 for name in files: 45 if 'tar' not in name: 46 comparison_list.append(os.path.relpath(os.path.join(path, name), tar_test_fedir)) 47 48 # create test tarball and list its content files 49 tarballname = _config.FLEXEXTRACT_DIRNAME + '_test.tar' 50 install.mk_tarball(ecd + tarballname) 51 with tarfile.open(ecd + tarballname, 'r') as tar_handle: 52 tar_content_list = tar_handle.getnames() 53 54 # remove test tar file from flex_extract directory 55 os.remove(ecd + tarballname) 56 57 # test if comparison filelist is equal to the 58 # filelist of tarball content 59 assert sorted(comparison_list) == sorted(tar_content_list) 60 61 def test_un_tarball(self): 62 import tarfile 63 import shutil 64 65 ecd = _config.PATH_FLEXEXTRACT_DIR + os.path.sep 66 67 # list comparison files for tarball content 68 tar_test_dir = os.path.join(_config.PATH_TEST_DIR + 69 os.path.sep + 'TestInstallTar') 70 tar_test_fedir = os.path.join(tar_test_dir, 'flex_extract_v7.1') 71 comparison_list = [] 72 for path, subdirs, files in os.walk(tar_test_fedir): 73 for name in files: 74 if 'tar' not in name: 75 comparison_list.append(os.path.relpath(os.path.join(path, name), tar_test_fedir)) 76 77 # untar in test directory 78 test_dir = os.path.join(tar_test_dir, 'test_untar') 79 make_dir(test_dir) 80 os.chdir(test_dir) 81 tarballname = _config.FLEXEXTRACT_DIRNAME + '.tar' 82 install.un_tarball(os.path.join(tar_test_dir, tarballname)) 83 tarfiles_list = [] 84 for path, subdirs, files in os.walk(test_dir): 85 for name in files: 86 tarfiles_list.append(os.path.relpath(os.path.join(path, name), test_dir)) 87 88 # test for equality 89 assert sorted(tarfiles_list) == sorted(comparison_list) 90 91 # clean up temp test dir 92 shutil.rmtree(test_dir) 26 93 27 94
Note: See TracChangeset
for help on using the changeset viewer.