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_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_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")