diff --git a/localstack-core/localstack/testing/snapshots/transformer_utility.py b/localstack-core/localstack/testing/snapshots/transformer_utility.py index ef2fdd13e6034..88f32869a330d 100644 --- a/localstack-core/localstack/testing/snapshots/transformer_utility.py +++ b/localstack-core/localstack/testing/snapshots/transformer_utility.py @@ -1,12 +1,10 @@ import json import logging import re -from datetime import datetime from json import JSONDecodeError from re import Pattern from localstack_snapshot.snapshots.transformer import ( - PATTERN_ISO8601, GenericTransformer, JsonpathTransformer, KeyValueBasedTransformer, @@ -900,19 +898,6 @@ def _change_set_id_transformer(key: str, val: str) -> str: # TODO maybe move to a different place? # Basic Transformation - added automatically to each snapshot (in the fixture) -SNAPSHOT_BASIC_TRANSFORMER_NEW = [ - ResponseMetaDataTransformer(), - KeyValueBasedTransformer( - lambda k, v: ( - v - if (isinstance(v, str) and k.lower().endswith("id") and re.match(PATTERN_UUID, v)) - else None - ), - "uuid", - ), - TimestampTransformer(), -] - SNAPSHOT_BASIC_TRANSFORMER = [ ResponseMetaDataTransformer(), KeyValueBasedTransformer( @@ -923,21 +908,5 @@ def _change_set_id_transformer(key: str, val: str) -> str: ), "uuid", ), - RegexTransformer(PATTERN_ISO8601, "date"), - KeyValueBasedTransformer( - lambda k, v: v if isinstance(v, datetime) else None, "datetime", replace_reference=False - ), - KeyValueBasedTransformer( - lambda k, v: ( - str(v) - if ( - re.compile(r"^.*timestamp.*$", flags=re.IGNORECASE).match(k) - or k in ("creationTime", "ingestionTime") - ) - and not PATTERN_ISO8601.match(str(v)) - else None - ), - "timestamp", - replace_reference=False, - ), + TimestampTransformer(), ] diff --git a/tests/aws/conftest.py b/tests/aws/conftest.py index 67a47237f3930..f35afd342e0f1 100644 --- a/tests/aws/conftest.py +++ b/tests/aws/conftest.py @@ -10,7 +10,6 @@ from localstack.testing import config as test_config from localstack.testing.snapshots.transformer_utility import ( SNAPSHOT_BASIC_TRANSFORMER, - SNAPSHOT_BASIC_TRANSFORMER_NEW, TransformerUtility, ) from localstack.utils.aws.arns import get_partition @@ -125,36 +124,7 @@ def snapshot(request, _snapshot_session: SnapshotSession, account_id, region_nam # Removes the 'x-localstack' header from all responses _snapshot_session.add_transformer(_snapshot_session.transform.remove_key("x-localstack")) - # TODO: temporary to migrate to new default transformers. - # remove this after all exemptions are gone - exemptions = [ - "tests/aws/services/acm", - "tests/aws/services/apigateway", - "tests/aws/services/cloudwatch", - "tests/aws/services/cloudformation", - "tests/aws/services/dynamodb", - "tests/aws/services/events", - "tests/aws/services/kinesis", - "tests/aws/services/kms", - "tests/aws/services/lambda_", - "tests/aws/services/logs", - "tests/aws/services/route53", - "tests/aws/services/route53resolver", - "tests/aws/services/s3", - "tests/aws/services/secretsmanager", - "tests/aws/services/ses", - "tests/aws/services/sns", - "tests/aws/services/stepfunctions", - "tests/aws/services/sqs", - "tests/aws/services/transcribe", - "tests/aws/scenario/bookstore", - "tests/aws/scenario/note_taking", - "tests/aws/scenario/lambda_destination", - "tests/aws/scenario/loan_broker", - ] - if any(e in request.fspath.dirname for e in exemptions): - _snapshot_session.add_transformer(SNAPSHOT_BASIC_TRANSFORMER, priority=2) - else: - _snapshot_session.add_transformer(SNAPSHOT_BASIC_TRANSFORMER_NEW, priority=2) + # Adds default transformers + _snapshot_session.add_transformer(SNAPSHOT_BASIC_TRANSFORMER, priority=2) return _snapshot_session diff --git a/tests/aws/services/lambda_/event_source_mapping/conftest.py b/tests/aws/services/lambda_/event_source_mapping/conftest.py index 2a107c7d9f99a..098688a28336b 100644 --- a/tests/aws/services/lambda_/event_source_mapping/conftest.py +++ b/tests/aws/services/lambda_/event_source_mapping/conftest.py @@ -3,7 +3,7 @@ from localstack_snapshot.snapshots.transformer import RegexTransformer from localstack.testing.snapshots.transformer_utility import ( - SNAPSHOT_BASIC_TRANSFORMER_NEW, + SNAPSHOT_BASIC_TRANSFORMER, TransformerUtility, ) from localstack.utils.aws.arns import get_partition @@ -21,6 +21,6 @@ def snapshot(request, _snapshot_session: SnapshotSession, account_id, region_nam RegexTransformer(f"arn:{get_partition(region_name)}:", "arn::"), priority=2 ) - _snapshot_session.add_transformer(SNAPSHOT_BASIC_TRANSFORMER_NEW, priority=0) + _snapshot_session.add_transformer(SNAPSHOT_BASIC_TRANSFORMER, priority=0) return _snapshot_session