Skip to content

Commit

Permalink
Small fix
Browse files Browse the repository at this point in the history
  • Loading branch information
leandrodamascena committed Dec 18, 2023
1 parent fec33a6 commit 74fccd7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
6 changes: 3 additions & 3 deletions aws_lambda_powertools/utilities/_data_masking/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from typing import Any, Callable, Iterable, Optional, Union

from aws_lambda_powertools.utilities._data_masking.exceptions import (
DataMaskingFieldNotFound,
DataMaskingFieldNotFoundError,
DataMaskingUnsupportedTypeError,
)
from aws_lambda_powertools.utilities._data_masking.provider import BaseProvider
Expand Down Expand Up @@ -180,7 +180,7 @@ def _apply_action_to_fields(
current_dict = current_dict[int(key)]
except KeyError:
# Handle the case when the key doesn't exist
raise DataMaskingFieldNotFound(f"Key {key} not found in {current_dict}")
raise DataMaskingFieldNotFoundError(f"Key {key} not found in {current_dict}")

last_key = keys[-1]

Expand Down Expand Up @@ -225,6 +225,6 @@ def _apply_action_to_specific_type(self, current_dict: dict, action: Callable, l
current_dict = set(elements_list)
else:
# Handle the case when the last key doesn't exist
raise DataMaskingFieldNotFound(f"Key {last_key} not found in {current_dict}")
raise DataMaskingFieldNotFoundError(f"Key {last_key} not found in {current_dict}")

return current_dict
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class DataMaskingContextMismatchError(Exception):
"""


class DataMaskingFieldNotFound(Exception):
class DataMaskingFieldNotFoundError(Exception):
"""
Field not found.
"""
7 changes: 5 additions & 2 deletions tests/unit/data_masking/test_unit_data_masking.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

from aws_lambda_powertools.utilities._data_masking.base import DataMasking
from aws_lambda_powertools.utilities._data_masking.constants import DATA_MASKING_STRING
from aws_lambda_powertools.utilities._data_masking.exceptions import DataMaskingUnsupportedTypeError
from aws_lambda_powertools.utilities._data_masking.exceptions import (
DataMaskingFieldNotFoundError,
DataMaskingUnsupportedTypeError,
)


@pytest.fixture
Expand Down Expand Up @@ -169,7 +172,7 @@ def test_parsing_nonexistent_fields(data_masker):
}

# WHEN attempting to pass in fields that do not exist in the input data
with pytest.raises(KeyError):
with pytest.raises(DataMaskingFieldNotFoundError):
# THEN the result is a KeyError
data_masker.mask(data, ["3.1.True"])

Expand Down

0 comments on commit 74fccd7

Please sign in to comment.