Changeset 2fb99de in flex_extract.git for python/pythontest/TestInstall.py


Ignore:
Timestamp:
Sep 20, 2018, 11:56:37 AM (6 years ago)
Author:
Anne Philipp <anne.philipp@…>
Branches:
master, ctbto, dev
Children:
5d42acd
Parents:
3232589
Message:

introduced config with path definitions and changed py files accordingly; Installation works; some tests were added for tarball making; Problems in submission to ecgate

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/pythontest/TestInstall.py

    r067a0c3 r2fb99de  
    66import os
    77import inspect
    8 sys.path.append('../python')
     8sys.path.append('../')
     9import _config
    910import install
     11from tools import make_dir
    1012
    1113
     
    1719        pass
    1820
     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
    1931
    2032    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
    2534
     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)
    2693
    2794
Note: See TracChangeset for help on using the changeset viewer.
hosted by ZAMG