def test_multiple_folders(self): """Test multiple folder creation.""" Folders.create(self.tmp_dir, ["foo", "bar"]) assert os.path.exists(os.path.join(self.tmp_dir, "foo")) assert os.path.exists(os.path.join(self.tmp_dir, "bar")) os.rmdir(os.path.join(self.tmp_dir, "foo")) os.rmdir(os.path.join(self.tmp_dir, "bar"))
def test_create_tuple(self): dirpath = tempfile.mkdtemp() Folders.create(dirpath, "foo") Files.create((dirpath, "foo"), "a.txt", b"bar") filepath = os.path.join(dirpath, "foo", "a.txt") assert open(filepath, "rb").read() == b"bar"
def test_delete_invld(self): """Test deletion of a folder we can't access.""" dirpath = tempfile.mkdtemp() os.chmod(dirpath, 0) with pytest.raises(CuckooOperationalError): Folders.delete(dirpath) os.chmod(dirpath, 0o775) Folders.delete(dirpath)
def test_create_invld_linux(self): """Test creation of a folder we can't access.""" with pytest.raises(CuckooOperationalError): Folders.create("/invalid/directory")
def test_delete_folder2(self): """Test folder deletion #2.""" Folders.create(self.tmp_dir, "foo") assert os.path.exists(os.path.join(self.tmp_dir, "foo")) Folders.delete(self.tmp_dir, "foo") assert not os.path.exists(os.path.join(self.tmp_dir, "foo"))
def test_duplicate_folder(self): """Test a duplicate folder creation.""" Folders.create(self.tmp_dir, "foo") assert os.path.exists(os.path.join(self.tmp_dir, "foo")) Folders.create(self.tmp_dir, "foo") os.rmdir(os.path.join(self.tmp_dir, "foo"))
def test_copy_folder(self, dir_setup): """Test recursive folder copy.""" Folders.copy(dir_setup[0], dir_setup[1]) assert os.path.isfile("%s/%s" % (dir_setup[0], dir_setup[2]))
def test_single_folder(self): """Test single folder creation.""" Folders.create(self.tmp_dir, "foo") assert os.path.exists(os.path.join(self.tmp_dir, "foo")) os.rmdir(os.path.join(self.tmp_dir, "foo"))
def test_root_folder(self): """Test single folder creation based on the root parameter.""" Folders.create(os.path.join(self.tmp_dir, "foo")) assert os.path.exists(os.path.join(self.tmp_dir, "foo")) os.rmdir(os.path.join(self.tmp_dir, "foo"))
def test_create_invld_windows(self): """Test creation of a folder we can't access.""" with pytest.raises(CuckooOperationalError): Folders.create("Z:\\invalid\\directory")