Commit 6f94bba1 authored by xaingling's avatar xaingling
Browse files

update and disable compress function

parent 45f6f2c0
......@@ -8,7 +8,7 @@ from app_common.test_common.base import TestBase
from app_common.linux_file_handler.remote_server_connector import RemoteServer
def test_fun1(a):
def example_test_fun1(a):
return a + "_decorated"
......@@ -23,7 +23,7 @@ class TestLinuxFileSystemController(unittest.TestCase):
:return:
"""
decorated_func = self.file_controller.send_decorate(test_fun1)
decorated_func = self.file_controller.send_decorate(example_test_fun1)
test_res = decorated_func('ls')
res = self.file_controller._un_commit_list
expected_res = 'ls_decorated'
......@@ -137,31 +137,31 @@ class TestLocalLinuxFileSystemController(TestBase):
res = self.file_controller.get_result()
self.assertTrue(current_path in str(res[0][0]))
def test_compress_dir(self):
""" create a file first and then compress it
"""
# first test compress a dir
dir_name = "test"
dir_path = os.path.join(self.output_dir, dir_name)
res_name = "test.bar.gz"
res_path = os.path.join(self.output_dir, res_name)
os.mkdir(dir_path)
self.file_controller.compress_files(dir_path, self.output_dir, res_name)
self.file_controller.commit()
self.assertTrue(os.path.isfile(res_path))
# second test compress a list of dirs
file_name1 = "sample1.txt"
file_name2 = "sample2.txt"
file_name3 = "sample3.txt"
file_name_list = [file_name1, file_name2, file_name3]
file_path_list = []
res_name2 = "test2.bar.gz"
res_path2 = os.path.join(self.output_dir, res_name2)
for x in file_name_list:
file_path_list.append(os.path.join(self.output_dir, x))
self.file_controller.compress_files(file_name_list, self.output_dir, res_name2)
self.file_controller.commit()
self.assertTrue(os.path.isfile(res_path2))
# def test_compress_dir(self):
# """ create a file first and then compress it
# """
# # first test compress a dir
# dir_name = "test"
# dir_path = os.path.join(self.output_dir, dir_name)
# res_name = "test.bar.gz"
# res_path = os.path.join(self.output_dir, res_name)
# os.mkdir(dir_path)
# self.file_controller.compress_files(dir_path, self.output_dir, res_name)
# self.file_controller.commit()
# self.assertTrue(os.path.isfile(res_path))
# # second test compress a list of dirs
# file_name1 = "sample1.txt"
# file_name2 = "sample2.txt"
# file_name3 = "sample3.txt"
# file_name_list = [file_name1, file_name2, file_name3]
# file_path_list = []
# res_name2 = "test2.bar.gz"
# res_path2 = os.path.join(self.output_dir, res_name2)
# for x in file_name_list:
# file_path_list.append(os.path.join(self.output_dir, x))
# self.file_controller.compress_files(file_name_list, self.output_dir, res_name2)
# self.file_controller.commit()
# self.assertTrue(os.path.isfile(res_path2))
def test_make_soft_link(self):
"""
......
......@@ -99,15 +99,15 @@ class TestLinuxCommand(unittest.TestCase):
Test Compress file command
"""
def test_compress_file1(self):
"""test compress a file with no dst_dir
"""
test_file_name = "/test/file/name/file_name.txt"
test_dst_file_dir = "test/dst/dir/"
test_dst_file_name = "dst_file_name.tar"
expected_command1 = "tar -cjvf {} {}".format(test_file_name, os.path.join(test_dst_file_dir, test_dst_file_name))
res1 = LinuxCommand.compress_files(test_file_name, test_dst_file_dir, test_dst_file_name)
self.assertEqual(expected_command1, res1)
# def test_compress_file1(self):
# """test compress a file with no dst_dir
# """
# test_file_name = "/test/file/name/file_name.txt"
# test_dst_file_dir = "test/dst/dir/"
# test_dst_file_name = "dst_file_name.tar"
# expected_command1 = "tar -cjvf {} {}".format(test_file_name, os.path.join(test_dst_file_dir, test_dst_file_name))
# res1 = LinuxCommand.compress_files(test_file_name, test_dst_file_dir, test_dst_file_name)
# self.assertEqual(expected_command1, res1)
# def test_compress_file2(self):
# """ test compress a one list with one file with dst_dir and dst_name
......@@ -155,20 +155,20 @@ class TestLinuxCommand(unittest.TestCase):
Test uncompress command
"""
def test_uncompress_file_with_path_to_extract_dir(self):
"""Test uncompress files Linux command
"""
path_to_extract_dir = "/usr/file/"
target_file = "/path/to/target/compress_file"
expected_command = "tar -xzvf {} -C {}".format(target_file, path_to_extract_dir)
res_command = LinuxCommand.uncompress_files(target_file, path_to_extract_dir)
self.assertEqual(res_command, expected_command)
def test_uncompress_file_with_no_path_to_extract_dir(self):
target_file = "/path/to/target/compress_file"
expected_command = "tar -xzvf {}".format(target_file)
res_command = LinuxCommand.uncompress_files(target_file)
self.assertEqual(res_command.strip(), expected_command.strip())
# def test_uncompress_file_with_path_to_extract_dir(self):
# """Test uncompress files Linux command
# """
# path_to_extract_dir = "/usr/file/"
# target_file = "/path/to/target/compress_file"
# expected_command = "tar -xzvf {} -C {}".format(target_file, path_to_extract_dir)
# res_command = LinuxCommand.uncompress_files(target_file, path_to_extract_dir)
# self.assertEqual(res_command, expected_command)
#
# def test_uncompress_file_with_no_path_to_extract_dir(self):
# target_file = "/path/to/target/compress_file"
# expected_command = "tar -xzvf {}".format(target_file)
# res_command = LinuxCommand.uncompress_files(target_file)
# self.assertEqual(res_command.strip(), expected_command.strip())
"""
copy file
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment