From 40b641b5b5f519555eafd71a8c8090ae3ccfdd5b Mon Sep 17 00:00:00 2001 From: Ante Spajic Date: Tue, 21 Jul 2026 16:07:26 +0100 Subject: [PATCH 1/4] test: cover construct_s3_location_object with StorageMode Isolates CodeUri/ContentUri to Lambda Code translation logic, including S3ObjectStorageMode pass-through added in #3959. --- tests/model/s3_utils/test_uri_parser.py | 42 +++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/tests/model/s3_utils/test_uri_parser.py b/tests/model/s3_utils/test_uri_parser.py index b6a85ead2..5edb808eb 100644 --- a/tests/model/s3_utils/test_uri_parser.py +++ b/tests/model/s3_utils/test_uri_parser.py @@ -37,6 +37,48 @@ def test_unresolved_cdk_token_returns_none(self): self.assertIsNone(parse_s3_uri("s3://bucket-[TOKEN.25]/key")) +class TestConstructS3LocationObject(TestCase): + def test_dict_with_bucket_and_key(self): + result = construct_s3_location_object({"Bucket": "b", "Key": "k"}, "Fn", "CodeUri") + self.assertEqual(result, {"S3Bucket": "b", "S3Key": "k"}) + + def test_dict_with_version(self): + result = construct_s3_location_object( + {"Bucket": "b", "Key": "k", "Version": "v1"}, "Fn", "CodeUri" + ) + self.assertEqual(result, {"S3Bucket": "b", "S3Key": "k", "S3ObjectVersion": "v1"}) + + def test_dict_with_storage_mode(self): + result = construct_s3_location_object( + {"Bucket": "b", "Key": "k", "StorageMode": "SingleObject"}, "Fn", "CodeUri" + ) + self.assertEqual(result, {"S3Bucket": "b", "S3Key": "k", "S3ObjectStorageMode": "SingleObject"}) + + def test_dict_with_all_optional_fields(self): + result = construct_s3_location_object( + {"Bucket": "b", "Key": "k", "Version": "v1", "StorageMode": "SingleObject"}, "Fn", "CodeUri" + ) + self.assertEqual( + result, {"S3Bucket": "b", "S3Key": "k", "S3ObjectVersion": "v1", "S3ObjectStorageMode": "SingleObject"} + ) + + def test_s3_uri_string(self): + result = construct_s3_location_object("s3://bucket/path/key", "Fn", "CodeUri") + self.assertEqual(result, {"S3Bucket": "bucket", "S3Key": "path/key"}) + + def test_dict_missing_bucket_raises(self): + with self.assertRaises(InvalidResourceException): + construct_s3_location_object({"Key": "k"}, "Fn", "CodeUri") + + def test_dict_missing_key_raises(self): + with self.assertRaises(InvalidResourceException): + construct_s3_location_object({"Bucket": "b"}, "Fn", "CodeUri") + + def test_invalid_type_raises(self): + with self.assertRaises(InvalidResourceException): + construct_s3_location_object(42, "Fn", "CodeUri") # type: ignore[arg-type] + + class TestConstructS3LocationObjectWithMalformedUri(TestCase): """Verify that the top-level helper raises InvalidResourceException with the logical id instead of letting the underlying urllib ValueError propagate. From 5eaa0322d7fe4573fea2f3e9c2e6f1f8d87051e1 Mon Sep 17 00:00:00 2001 From: Ante Spajic Date: Tue, 21 Jul 2026 16:42:45 +0100 Subject: [PATCH 2/4] test: drop redundant combined-fields case Version and StorageMode are independent pass-throughs, each covered alone. --- tests/model/s3_utils/test_uri_parser.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/tests/model/s3_utils/test_uri_parser.py b/tests/model/s3_utils/test_uri_parser.py index 5edb808eb..9e17d7b76 100644 --- a/tests/model/s3_utils/test_uri_parser.py +++ b/tests/model/s3_utils/test_uri_parser.py @@ -54,14 +54,6 @@ def test_dict_with_storage_mode(self): ) self.assertEqual(result, {"S3Bucket": "b", "S3Key": "k", "S3ObjectStorageMode": "SingleObject"}) - def test_dict_with_all_optional_fields(self): - result = construct_s3_location_object( - {"Bucket": "b", "Key": "k", "Version": "v1", "StorageMode": "SingleObject"}, "Fn", "CodeUri" - ) - self.assertEqual( - result, {"S3Bucket": "b", "S3Key": "k", "S3ObjectVersion": "v1", "S3ObjectStorageMode": "SingleObject"} - ) - def test_s3_uri_string(self): result = construct_s3_location_object("s3://bucket/path/key", "Fn", "CodeUri") self.assertEqual(result, {"S3Bucket": "bucket", "S3Key": "path/key"}) From 685d7bfa5a7e49a888366c28f34c6967794f22d1 Mon Sep 17 00:00:00 2001 From: Ante Spajic Date: Tue, 21 Jul 2026 16:43:45 +0100 Subject: [PATCH 3/4] test: use valid StorageMode value REFERENCE --- tests/model/s3_utils/test_uri_parser.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/model/s3_utils/test_uri_parser.py b/tests/model/s3_utils/test_uri_parser.py index 9e17d7b76..633b0d46f 100644 --- a/tests/model/s3_utils/test_uri_parser.py +++ b/tests/model/s3_utils/test_uri_parser.py @@ -50,9 +50,9 @@ def test_dict_with_version(self): def test_dict_with_storage_mode(self): result = construct_s3_location_object( - {"Bucket": "b", "Key": "k", "StorageMode": "SingleObject"}, "Fn", "CodeUri" + {"Bucket": "b", "Key": "k", "StorageMode": "REFERENCE"}, "Fn", "CodeUri" ) - self.assertEqual(result, {"S3Bucket": "b", "S3Key": "k", "S3ObjectStorageMode": "SingleObject"}) + self.assertEqual(result, {"S3Bucket": "b", "S3Key": "k", "S3ObjectStorageMode": "REFERENCE"}) def test_s3_uri_string(self): result = construct_s3_location_object("s3://bucket/path/key", "Fn", "CodeUri") From 993277cca5c135b7bfc06cf18ba40baba01c778b Mon Sep 17 00:00:00 2001 From: Ante Spajic Date: Tue, 21 Jul 2026 16:44:42 +0100 Subject: [PATCH 4/4] test: apply black formatting --- tests/model/s3_utils/test_uri_parser.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/model/s3_utils/test_uri_parser.py b/tests/model/s3_utils/test_uri_parser.py index 633b0d46f..6fccf6827 100644 --- a/tests/model/s3_utils/test_uri_parser.py +++ b/tests/model/s3_utils/test_uri_parser.py @@ -43,15 +43,11 @@ def test_dict_with_bucket_and_key(self): self.assertEqual(result, {"S3Bucket": "b", "S3Key": "k"}) def test_dict_with_version(self): - result = construct_s3_location_object( - {"Bucket": "b", "Key": "k", "Version": "v1"}, "Fn", "CodeUri" - ) + result = construct_s3_location_object({"Bucket": "b", "Key": "k", "Version": "v1"}, "Fn", "CodeUri") self.assertEqual(result, {"S3Bucket": "b", "S3Key": "k", "S3ObjectVersion": "v1"}) def test_dict_with_storage_mode(self): - result = construct_s3_location_object( - {"Bucket": "b", "Key": "k", "StorageMode": "REFERENCE"}, "Fn", "CodeUri" - ) + result = construct_s3_location_object({"Bucket": "b", "Key": "k", "StorageMode": "REFERENCE"}, "Fn", "CodeUri") self.assertEqual(result, {"S3Bucket": "b", "S3Key": "k", "S3ObjectStorageMode": "REFERENCE"}) def test_s3_uri_string(self):