Changeset 25b14be in flex_extract.git for source/pythontest/TestInstall.py


Ignore:
Timestamp:
Sep 23, 2018, 11:40:28 AM (2 years ago)
Author:
Anne Philipp <anne.philipp@…>
Branches:
master, ctbto, dev, feature/makefiles, origin/task/language-editing, task/language-editing
Children:
4971f63
Parents:
5d42acd
Message:

changed whole tree structure of flex_extract to have better overview

File:
1 moved

Legend:

Unmodified
Added
Removed
  • source/pythontest/TestInstall.py

    r2fb99de r25b14be  
    22# -*- coding: utf-8 -*-
    33
    4 import unittest
     4
    55import sys
    66import os
    77import inspect
    8 sys.path.append('../')
     8import pytest
     9
     10sys.path.append('../python')
    911import _config
    1012import install
    11 from tools import make_dir
     13from mods.tools import make_dir
    1214
    1315
    14 class TestTools(unittest.TestCase):
     16class TestTools():
    1517    '''
    1618    '''
    1719
    18     def setUp(self):
    19         pass
    2020
    2121    #    - main
     
    3030    #    - make_convert_build
    3131
    32     def test_mk_tarball(self):
     32    def test_mk_tarball_local(self):
    3333        import tarfile
    3434
     
    3838        tar_test_dir = os.path.join(_config.PATH_TEST_DIR +
    3939                                    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))
     40        tar_test_file = os.path.join(tar_test_dir,
     41                                     'flex_extract_v7.1_local.tar')
     42        with tarfile.open(tar_test_file, 'r') as tar_handle:
     43            comparison_list = tar_handle.getnames()
    4744
    4845        # create test tarball and list its content files
    49         tarballname = _config.FLEXEXTRACT_DIRNAME + '_test.tar'
    50         install.mk_tarball(ecd + tarballname)
     46        tarballname = _config.FLEXEXTRACT_DIRNAME + '_localtest.tar'
     47        install.mk_tarball(ecd + tarballname, 'local')
     48        with tarfile.open(ecd + tarballname, 'r') as tar_handle:
     49            tar_content_list = tar_handle.getnames()
     50
     51        # remove test tar file from flex_extract directory
     52        os.remove(ecd + tarballname)
     53
     54        # test if comparison filelist is equal to the
     55        # filelist of tarball content
     56        assert sorted(comparison_list) == sorted(tar_content_list)
     57
     58    def test_mk_tarball_ecgate(self):
     59        import tarfile
     60
     61        ecd = _config.PATH_FLEXEXTRACT_DIR + os.path.sep
     62
     63        # list comparison files for tarball content
     64        tar_test_dir = os.path.join(_config.PATH_TEST_DIR +
     65                                    os.path.sep + 'TestInstallTar')
     66        tar_test_file = os.path.join(tar_test_dir,
     67                                     'flex_extract_v7.1_ecgate.tar')
     68        with tarfile.open(tar_test_file, 'r') as tar_handle:
     69            comparison_list = tar_handle.getnames()
     70
     71        # create test tarball and list its content files
     72        tarballname = _config.FLEXEXTRACT_DIRNAME + '_ecgatetest.tar'
     73        install.mk_tarball(ecd + tarballname, 'ecgate')
    5174        with tarfile.open(ecd + tarballname, 'r') as tar_handle:
    5275            tar_content_list = tar_handle.getnames()
     
    6891        tar_test_dir = os.path.join(_config.PATH_TEST_DIR +
    6992                                        os.path.sep + 'TestInstallTar')
    70         tar_test_fedir = os.path.join(tar_test_dir, 'flex_extract_v7.1')
     93        tar_test_fedir = os.path.join(tar_test_dir, 'flex_extract_v7.1_ecgate')
    7194        comparison_list = []
    7295        for path, subdirs, files in os.walk(tar_test_fedir):
    7396            for name in files:
    7497                if 'tar' not in name:
    75                     comparison_list.append(os.path.relpath(os.path.join(path, name), tar_test_fedir))
     98                    comparison_list.append(os.path.relpath(
     99                        os.path.join(path, name), tar_test_fedir))
    76100
    77101        # untar in test directory
     
    79103        make_dir(test_dir)
    80104        os.chdir(test_dir)
    81         tarballname = _config.FLEXEXTRACT_DIRNAME + '.tar'
     105        tarballname = _config.FLEXEXTRACT_DIRNAME + '_ecgate.tar'
    82106        install.un_tarball(os.path.join(tar_test_dir, tarballname))
    83107        tarfiles_list = []
    84108        for path, subdirs, files in os.walk(test_dir):
    85109            for name in files:
    86                 tarfiles_list.append(os.path.relpath(os.path.join(path, name), test_dir))
     110                tarfiles_list.append(os.path.relpath(
     111                    os.path.join(path, name), test_dir))
    87112
    88113        # test for equality
     
    91116        # clean up temp test dir
    92117        shutil.rmtree(test_dir)
    93 
    94 
    95 if __name__ == "__main__":
    96     unittest.main()
Note: See TracChangeset for help on using the changeset viewer.
hosted by ZAMG