source: flex_extract.git/python/pythontest/TestInstall.py @ 2fb99de

ctbtodev
Last change on this file since 2fb99de was 2fb99de, checked in by Anne Philipp <anne.philipp@…>, 6 years ago

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

  • Property mode set to 100644
File size: 3.0 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3
4import unittest
5import sys
6import os
7import inspect
8sys.path.append('../')
9import _config
10import install
11from tools import make_dir
12
13
14class TestTools(unittest.TestCase):
15    '''
16    '''
17
18    def setUp(self):
19        pass
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
31
32    def test_mk_tarball(self):
33        import tarfile
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)
93
94
95if __name__ == "__main__":
96    unittest.main()
Note: See TracBrowser for help on using the repository browser.
hosted by ZAMG