2022-08-12 16:44:10 +00:00
import re
# Regex patterns of status codes of Container service (https://github.com/nspcc-dev/neofs-spec/blob/98b154848116223e486ce8b43eaa35fec08b4a99/20-api-v2/container.md)
CONTAINER_NOT_FOUND = " code = 3072.*message = container not found "
# Regex patterns of status codes of Object service (https://github.com/nspcc-dev/neofs-spec/blob/98b154848116223e486ce8b43eaa35fec08b4a99/20-api-v2/object.md)
2022-11-10 14:56:25 +00:00
MALFORMED_REQUEST = " code = 1024.*message = malformed request "
2022-08-12 16:44:10 +00:00
OBJECT_ACCESS_DENIED = " code = 2048.*message = access to object operation denied "
OBJECT_NOT_FOUND = " code = 2049.*message = object not found "
OBJECT_ALREADY_REMOVED = " code = 2052.*message = object already removed "
2022-09-05 09:35:46 +00:00
SESSION_NOT_FOUND = " code = 4096.*message = session token not found "
2022-11-01 16:11:26 +00:00
OUT_OF_RANGE = " code = 2053.*message = out of range "
2022-11-25 12:44:47 +00:00
# TODO: Due to https://github.com/nspcc-dev/neofs-node/issues/2092 we have to check only codes until fixed
# OBJECT_IS_LOCKED = "code = 2050.*message = object is locked"
# LOCK_NON_REGULAR_OBJECT = "code = 2051.*message = ..." will be available once 2092 is fixed
OBJECT_IS_LOCKED = " code = 2050 "
LOCK_NON_REGULAR_OBJECT = " code = 2051 "
LIFETIME_REQUIRED = " either expiration epoch of a lifetime is required "
LOCK_OBJECT_REMOVAL = " lock object removal "
LOCK_OBJECT_EXPIRATION = " lock object expiration: {expiration_epoch} ; current: {current_epoch} "
2022-08-12 16:44:10 +00:00
def error_matches_status ( error : Exception , status_pattern : str ) - > bool :
"""
Determines whether exception matches specified status pattern .
We use re . search to be consistent with pytest . raises .
"""
match = re . search ( status_pattern , str ( error ) )
return match is not None