예제 #1
0
    def test_cp_file_same(self):
        """Function:  test_cp_file_same

        Description:  Test copy of file to same name.

        Arguments:

        """

        gen_libs.touch(os.path.join(self.cp_file_dir2, "testme"))

        self.assertEqual((gen_libs.cp_file(self.src_file, self.cp_file_dir,
                                           self.cp_file_dir2)), (True, None))
예제 #2
0
    def test_cp_file_dir(self):
        """Function:  test_cp_file_dir

        Description:  Test copy of file in different directory.

        Arguments:

        """

        gen_libs.touch(os.path.join(self.cp_file_dir2, "testme"))

        self.assertEqual((gen_libs.cp_file(self.src_file, self.cp_file_dir,
                                           self.cp_file_dir2, self.dest_file)),
                         (True, None))
예제 #3
0
    def test_fail_dest_perm(self):
        """Function:  test_fail_dest_perm

        Description:  Test failure on directory permission.

        Arguments:

        """

        gen_libs.touch(os.path.join(self.cp_file_dir2, self.src_file))
        os.chmod(self.cp_file_dir2, 0444)

        self.assertEqual((gen_libs.cp_file(self.src_file, self.cp_file_dir,
                                           self.cp_file_dir2, self.dest_file)),
                         (False, "Permission denied"))
예제 #4
0
    def setUp(self):
        """Function:  setUp

        Description:  Initialization for unit testing.

        Arguments:

        """

        self.err_mask = "No such file or directory: %s"
        self.base_path = "test/unit/gen_libs/tmp"
        self.cp_file_dir = os.path.join(self.base_path, "cp_file_dir")
        self.cp_file_dir2 = os.path.join(self.base_path, "cp_file_dir2")
        self.dir_fail = os.path.join(self.base_path, "not_cp_file_dir")
        self.src_file = "src_cp_file.txt"
        self.dest_file = "src_cp_file2.txt"

        gen_libs.touch(os.path.join(self.cp_file_dir, self.src_file))
예제 #5
0
    def test_create_path(self):
        """Function:  test_create_path

        Description:  Test creating part of path to file.

        Arguments:

        """

        self.assertEqual((gen_libs.touch(self.dir_create)), (True, None))
예제 #6
0
    def test_existing_file(self):
        """Function:  test_existing_file

        Description:  Test on existing file.

        Arguments:

        """

        status, msg = gen_libs.touch(self.exist_file)
        f_status = True if os.stat(self.exist_file).st_size > 0 else False
        self.assertEqual((status, msg, f_status), (True, None, True))
예제 #7
0
    def test_touch_file(self):
        """Function:  test_touch_file

        Description:  Test creating file.

        Arguments:

        """

        status, msg = gen_libs.touch(self.file_name)
        f_status = True if os.stat(self.file_name).st_size == 0 else False
        self.assertEqual((status, msg, f_status), (True, None, True))
예제 #8
0
    def test_file_create_fail(self):
        """Function:  test_file_create_fail

        Description:  Test failure to create file.

        Arguments:

        """

        os.makedirs(self.dir_path)
        os.chmod(self.dir_path, 0444)

        self.assertEqual((gen_libs.touch(self.file_fail)),
                         (False, self.file_msg))