Beispiel #1
0
 def test_copy_dir(self):
     """
     Test that copying a directory works as expected
     """
     # TODO: Test that all subfiles and folders are copied.
     test_dir = 'test'
     test_path = os.path.join(DIR_TO_BACKUP, test_dir)
     os.mkdir(test_path)
     copy_dir_if_valid(test_path, BACKUP_DIR)
     assert os.path.isdir(test_path)
     assert os.path.isdir(os.path.join(BACKUP_DIR, test_dir))
    def test_copy_dir(self):
        """
        Test that copying a directory works as expected
        """
        # TODO: Test that all subfiles and folders are copied.
        test_file_name = 'test-file.txt'
        test_dir_name = 'subdir-to-copy'
        os.mkdir(os.path.join(FAKE_HOME_DIR, test_dir_name))
        with open(os.path.join(FAKE_HOME_DIR, test_file_name), "w+") as file:
            file.write("TRASH")

        copy_dir_if_valid(FAKE_HOME_DIR, BACKUP_DEST_DIR)
        assert os.path.isfile(os.path.join(BACKUP_DEST_DIR, test_file_name))
        assert os.path.isdir(os.path.join(BACKUP_DEST_DIR, test_dir_name))
Beispiel #3
0
 def test_copy_dir(self):
     """
     Test that copying a directory works as expected
     """
     # TODO: Test that all subfiles and folders are copied.
     test_dir = 'subdir-to-copy'
     test_path = os.path.join(FAKE_HOME_DIR, test_dir)
     os.mkdir(test_path)
     copy_dir_if_valid(FAKE_HOME_DIR, BACKUP_DEST_DIR)
     assert os.path.isdir(test_path)
     assert os.path.isfile(
         os.path.join(BACKUP_DEST_DIR,
                      os.path.split(TEST_TEXT_FILE)[1]))
     assert os.path.isdir(os.path.join(BACKUP_DEST_DIR, test_dir))
Beispiel #4
0
 def test_copy_dir_invalid(self, invalid):
     """
     Test that attempting to copy an invalid directory fails
     """
     copy_dir_if_valid(invalid, DIR_TO_BACKUP)
     assert not os.path.isdir(os.path.join(BACKUP_DIR, invalid))