def test_handle_oss_error(): """Test airfs.oss._handle_oss_error""" from airfs.storage.oss import _handle_oss_error from oss2.exceptions import OssError # type: ignore from airfs._core.exceptions import ObjectNotFoundError, ObjectPermissionError kwargs = dict(headers={}, body=None, details={"Message": ""}) # Any error with pytest.raises(OssError): with _handle_oss_error(): raise OssError(416, **kwargs) # 404 error with pytest.raises(ObjectNotFoundError): with _handle_oss_error(): raise OssError(404, **kwargs) # 403 error with pytest.raises(ObjectPermissionError): with _handle_oss_error(): raise OssError(403, **kwargs)
def test_handle_oss_error(): """Test pycosio.oss._handle_oss_error""" from pycosio.storage.oss import _handle_oss_error from oss2.exceptions import OssError from pycosio._core.exceptions import ( ObjectNotFoundError, ObjectPermissionError) kwargs = dict(headers={}, body=None, details={'Message': ''}) # Any error with pytest.raises(OssError): with _handle_oss_error(): raise OssError(416, **kwargs) # 404 error with pytest.raises(ObjectNotFoundError): with _handle_oss_error(): raise OssError(404, **kwargs) # 403 error with pytest.raises(ObjectPermissionError): with _handle_oss_error(): raise OssError(403, **kwargs)
def raise_500(): """Raise 500 error""" raise OssError(500, headers={}, body=None, details={"Message": ""})
def raise_416(): """Raise 416 error""" raise OssError(416, headers={}, body=None, details={"Message": ""})
def raise_404(): """Raise 404 error""" raise OssError(404, headers={}, body=None, details={"Message": ""})