From 2aed29c681fc7b460496a091411b00e68d44afb6 Mon Sep 17 00:00:00 2001 From: jonathan343 Date: Tue, 8 Oct 2024 17:05:59 -0400 Subject: [PATCH] Fix CRT only tests --- tests/functional/test_httpchecksum.py | 85 +++++++++++++++------------ 1 file changed, 47 insertions(+), 38 deletions(-) diff --git a/tests/functional/test_httpchecksum.py b/tests/functional/test_httpchecksum.py index a6c78556af..67d36c8d36 100644 --- a/tests/functional/test_httpchecksum.py +++ b/tests/functional/test_httpchecksum.py @@ -14,6 +14,7 @@ import pytest +from botocore.compat import HAS_CRT from tests import ClientHTTPStubber, patch_load_service_model TEST_CHECKSUM_SERVICE_MODEL = { @@ -147,7 +148,7 @@ def _request_checksum_calculation_cases(): request_payload = "Hello world" - return ( + cases = [ ( "CRC32", request_payload, @@ -156,22 +157,6 @@ def _request_checksum_calculation_cases(): "x-amz-checksum-crc32": "i9aeUg==", }, ), - ( - "CRC32C", - request_payload, - { - "x-amz-request-algorithm": "CRC32C", - "x-amz-checksum-crc32c": "crUfeA==", - }, - ), - ( - "CRC64NVME", - request_payload, - { - "x-amz-request-algorithm": "CRC64NVME", - "x-amz-checksum-crc64nvme": "OOJZ0D8xKts=", - }, - ), ( "SHA1", request_payload, @@ -188,7 +173,27 @@ def _request_checksum_calculation_cases(): "x-amz-checksum-sha256": "ZOyIygCyaOW6GjVnihtTFtIS9PNmskdyMlNKiuyjfzw=", }, ), - ) + ] + if HAS_CRT: + cases.append( + ( + "CRC32C", + request_payload, + { + "x-amz-request-algorithm": "CRC32C", + "x-amz-checksum-crc32c": "crUfeA==", + }, + ), + ( + "CRC64NVME", + request_payload, + { + "x-amz-request-algorithm": "CRC64NVME", + "x-amz-checksum-crc64nvme": "OOJZ0D8xKts=", + }, + ), + ) + return cases @pytest.mark.parametrize( @@ -225,7 +230,7 @@ def test_request_checksum_calculation( def _streaming_request_checksum_calculation_cases(): request_payload = "Hello world" - return ( + cases = [ ( "CRC32", request_payload, @@ -235,24 +240,6 @@ def _streaming_request_checksum_calculation_cases(): }, {"x-amz-checksum-crc32": "i9aeUg=="}, ), - ( - "CRC32C", - request_payload, - { - "content-encoding": "aws-chunked", - "x-amz-trailer": "x-amz-checksum-crc32c", - }, - {"x-amz-checksum-crc32c": "crUfeA=="}, - ), - ( - "CRC64NVME", - request_payload, - { - "content-encoding": "aws-chunked", - "x-amz-trailer": "x-amz-checksum-crc64nvme", - }, - {"x-amz-checksum-crc64nvme": "OOJZ0D8xKts="}, - ), ( "SHA1", request_payload, @@ -273,7 +260,29 @@ def _streaming_request_checksum_calculation_cases(): "x-amz-checksum-sha256": "ZOyIygCyaOW6GjVnihtTFtIS9PNmskdyMlNKiuyjfzw=" }, ), - ) + ] + if HAS_CRT: + cases.append( + ( + "CRC32C", + request_payload, + { + "content-encoding": "aws-chunked", + "x-amz-trailer": "x-amz-checksum-crc32c", + }, + {"x-amz-checksum-crc32c": "crUfeA=="}, + ), + ( + "CRC64NVME", + request_payload, + { + "content-encoding": "aws-chunked", + "x-amz-trailer": "x-amz-checksum-crc64nvme", + }, + {"x-amz-checksum-crc64nvme": "OOJZ0D8xKts="}, + ), + ) + return cases @pytest.mark.parametrize(