def test_rmdir_no_such_file_or_directory(mocker, prefix, ls_result): ls_mock = mocker.patch("faculty.datasets.ls", return_value=ls_result) with pytest.raises(DatasetsError, match="No such file or directory"): datasets.rmdir(prefix + "project-path", project_id=PROJECT_ID) ls_mock.assert_called_once_with( prefix=prefix + "project-path", project_id=PROJECT_ID, show_hidden=True, object_client=None, )
def test_rmdir_not_a_directory(mocker, prefix): ls_mock = mocker.patch("faculty.datasets.ls", return_value=["/project-path"]) with pytest.raises(DatasetsError, match="Not a directory"): datasets.rmdir(prefix + "project-path", project_id=PROJECT_ID) ls_mock.assert_called_once_with( prefix=prefix + "project-path", project_id=PROJECT_ID, show_hidden=True, object_client=None, )
def test_rmdir(mocker, prefix): ls_mock = mocker.patch("faculty.datasets.ls", return_value=["/project-path/"]) rm_mock = mocker.patch("faculty.datasets.rm") datasets.rmdir(prefix + "project-path", project_id=PROJECT_ID) ls_mock.assert_called_once_with( prefix=prefix + "project-path", project_id=PROJECT_ID, show_hidden=True, object_client=None, ) rm_mock.assert_called_once_with( "/project-path/", project_id=PROJECT_ID, object_client=None, recursive=True, )