Techdebt: Replace sure with regular assertions in Firehose (#6565)

This commit is contained in:
Bert Blommers 2023-07-27 22:25:43 +00:00 committed by GitHub
parent 689c93376a
commit a68a035038
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 166 additions and 185 deletions

View File

@ -1,6 +1,5 @@
"""Unit tests verifying various delivery stream destination content.""" """Unit tests verifying various delivery stream destination content."""
import boto3 import boto3
import sure # noqa # pylint: disable=unused-import
from moto import mock_firehose from moto import mock_firehose
from moto import settings from moto import settings
@ -118,11 +117,10 @@ def test_create_redshift_delivery_stream():
stream_description = response["DeliveryStreamDescription"] stream_description = response["DeliveryStreamDescription"]
# Sure and Freezegun don't play nicely together # Sure and Freezegun don't play nicely together
_ = stream_description.pop("CreateTimestamp") stream_description.pop("CreateTimestamp")
_ = stream_description.pop("LastUpdateTimestamp") stream_description.pop("LastUpdateTimestamp")
stream_description.should.equal( assert stream_description == {
{
"DeliveryStreamName": stream_name, "DeliveryStreamName": stream_name,
"DeliveryStreamARN": stream_arn, "DeliveryStreamARN": stream_arn,
"DeliveryStreamStatus": "ACTIVE", "DeliveryStreamStatus": "ACTIVE",
@ -154,7 +152,6 @@ def test_create_redshift_delivery_stream():
], ],
"HasMoreDestinations": False, "HasMoreDestinations": False,
} }
)
@mock_firehose @mock_firehose
@ -170,11 +167,10 @@ def test_create_extended_s3_delivery_stream():
stream_description = response["DeliveryStreamDescription"] stream_description = response["DeliveryStreamDescription"]
# Sure and Freezegun don't play nicely together # Sure and Freezegun don't play nicely together
_ = stream_description.pop("CreateTimestamp") stream_description.pop("CreateTimestamp")
_ = stream_description.pop("LastUpdateTimestamp") stream_description.pop("LastUpdateTimestamp")
stream_description.should.equal( assert stream_description == {
{
"DeliveryStreamName": stream_name, "DeliveryStreamName": stream_name,
"DeliveryStreamARN": stream_arn, "DeliveryStreamARN": stream_arn,
"DeliveryStreamStatus": "ACTIVE", "DeliveryStreamStatus": "ACTIVE",
@ -194,9 +190,7 @@ def test_create_extended_s3_delivery_stream():
"Deserializer": {"HiveJsonSerDe": {}} "Deserializer": {"HiveJsonSerDe": {}}
}, },
"OutputFormatConfiguration": { "OutputFormatConfiguration": {
"Serializer": { "Serializer": {"ParquetSerDe": {"Compression": "SNAPPY"}}
"ParquetSerDe": {"Compression": "SNAPPY"}
}
}, },
"SchemaConfiguration": { "SchemaConfiguration": {
"DatabaseName": stream_name, "DatabaseName": stream_name,
@ -215,7 +209,6 @@ def test_create_extended_s3_delivery_stream():
], ],
"HasMoreDestinations": False, "HasMoreDestinations": False,
} }
)
@mock_firehose @mock_firehose
@ -234,8 +227,7 @@ def test_create_elasticsearch_delivery_stream():
_ = stream_description.pop("CreateTimestamp") _ = stream_description.pop("CreateTimestamp")
_ = stream_description.pop("LastUpdateTimestamp") _ = stream_description.pop("LastUpdateTimestamp")
stream_description.should.equal( assert stream_description == {
{
"DeliveryStreamName": stream_name, "DeliveryStreamName": stream_name,
"DeliveryStreamARN": stream_arn, "DeliveryStreamARN": stream_arn,
"DeliveryStreamStatus": "ACTIVE", "DeliveryStreamStatus": "ACTIVE",
@ -267,7 +259,6 @@ def test_create_elasticsearch_delivery_stream():
], ],
"HasMoreDestinations": False, "HasMoreDestinations": False,
} }
)
@mock_firehose @mock_firehose
@ -292,11 +283,10 @@ def test_create_s3_delivery_stream():
stream_description = response["DeliveryStreamDescription"] stream_description = response["DeliveryStreamDescription"]
# Sure and Freezegun don't play nicely together # Sure and Freezegun don't play nicely together
_ = stream_description.pop("CreateTimestamp") stream_description.pop("CreateTimestamp")
_ = stream_description.pop("LastUpdateTimestamp") stream_description.pop("LastUpdateTimestamp")
stream_description.should.equal( assert stream_description == {
{
"DeliveryStreamName": stream_name, "DeliveryStreamName": stream_name,
"DeliveryStreamARN": stream_arn, "DeliveryStreamARN": stream_arn,
"DeliveryStreamStatus": "ACTIVE", "DeliveryStreamStatus": "ACTIVE",
@ -316,4 +306,3 @@ def test_create_s3_delivery_stream():
], ],
"HasMoreDestinations": False, "HasMoreDestinations": False,
} }
)

View File

@ -19,7 +19,7 @@ def test_firehose_without_encryption():
resp = client.describe_delivery_stream(DeliveryStreamName=name)[ resp = client.describe_delivery_stream(DeliveryStreamName=name)[
"DeliveryStreamDescription" "DeliveryStreamDescription"
] ]
resp.shouldnt.have.key("DeliveryStreamEncryptionConfiguration") assert "DeliveryStreamEncryptionConfiguration" not in resp
client.start_delivery_stream_encryption( client.start_delivery_stream_encryption(
DeliveryStreamName=name, DeliveryStreamName=name,
@ -29,12 +29,10 @@ def test_firehose_without_encryption():
stream = client.describe_delivery_stream(DeliveryStreamName=name)[ stream = client.describe_delivery_stream(DeliveryStreamName=name)[
"DeliveryStreamDescription" "DeliveryStreamDescription"
] ]
stream.should.have.key("DeliveryStreamEncryptionConfiguration").equals( assert stream["DeliveryStreamEncryptionConfiguration"] == {
{
"KeyType": "AWS_OWNED_CMK", "KeyType": "AWS_OWNED_CMK",
"Status": "ENABLED", "Status": "ENABLED",
} }
)
@mock_firehose @mock_firehose
@ -50,18 +48,16 @@ def test_firehose_with_encryption():
stream = client.describe_delivery_stream(DeliveryStreamName=name)[ stream = client.describe_delivery_stream(DeliveryStreamName=name)[
"DeliveryStreamDescription" "DeliveryStreamDescription"
] ]
stream.should.have.key("DeliveryStreamEncryptionConfiguration").equals( assert stream["DeliveryStreamEncryptionConfiguration"] == {
{"KeyType": "AWS_OWNED_CMK"} "KeyType": "AWS_OWNED_CMK"
) }
client.stop_delivery_stream_encryption(DeliveryStreamName=name) client.stop_delivery_stream_encryption(DeliveryStreamName=name)
stream = client.describe_delivery_stream(DeliveryStreamName=name)[ stream = client.describe_delivery_stream(DeliveryStreamName=name)[
"DeliveryStreamDescription" "DeliveryStreamDescription"
] ]
stream.should.have.key("DeliveryStreamEncryptionConfiguration").should.have.key( assert stream["DeliveryStreamEncryptionConfiguration"]["Status"] == "DISABLED"
"Status"
).equals("DISABLED")
@mock_firehose @mock_firehose
@ -74,8 +70,8 @@ def test_start_encryption_on_unknown_stream():
DeliveryStreamEncryptionConfigurationInput={"KeyType": "AWS_OWNED_CMK"}, DeliveryStreamEncryptionConfigurationInput={"KeyType": "AWS_OWNED_CMK"},
) )
err = exc.value.response["Error"] err = exc.value.response["Error"]
err["Code"].should.equal("ResourceNotFoundException") assert err["Code"] == "ResourceNotFoundException"
err["Message"].should.equal("Firehose ? under account 123456789012 not found.") assert err["Message"] == "Firehose ? under account 123456789012 not found."
@mock_firehose @mock_firehose
@ -85,5 +81,5 @@ def test_stop_encryption_on_unknown_stream():
with pytest.raises(ClientError) as exc: with pytest.raises(ClientError) as exc:
client.stop_delivery_stream_encryption(DeliveryStreamName="?") client.stop_delivery_stream_encryption(DeliveryStreamName="?")
err = exc.value.response["Error"] err = exc.value.response["Error"]
err["Code"].should.equal("ResourceNotFoundException") assert err["Code"] == "ResourceNotFoundException"
err["Message"].should.equal("Firehose ? under account 123456789012 not found.") assert err["Message"] == "Firehose ? under account 123456789012 not found."

View File

@ -1,6 +1,5 @@
"""Unit tests verifying put-related delivery stream APIs.""" """Unit tests verifying put-related delivery stream APIs."""
import boto3 import boto3
import sure # noqa pylint: disable=unused-import
from moto import mock_firehose from moto import mock_firehose
from moto import mock_s3 from moto import mock_s3

View File

@ -1,5 +1,4 @@
import boto3 import boto3
import sure # noqa # pylint: disable=unused-import
from moto import mock_firehose from moto import mock_firehose
from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID from moto.core import DEFAULT_ACCOUNT_ID as ACCOUNT_ID
@ -22,11 +21,10 @@ def test_create_http_stream():
stream_description = response["DeliveryStreamDescription"] stream_description = response["DeliveryStreamDescription"]
# Sure and Freezegun don't play nicely together # Sure and Freezegun don't play nicely together
_ = stream_description.pop("CreateTimestamp") stream_description.pop("CreateTimestamp")
_ = stream_description.pop("LastUpdateTimestamp") stream_description.pop("LastUpdateTimestamp")
stream_description.should.equal( assert stream_description == {
{
"DeliveryStreamName": stream_name, "DeliveryStreamName": stream_name,
"DeliveryStreamARN": stream_arn, "DeliveryStreamARN": stream_arn,
"DeliveryStreamStatus": "ACTIVE", "DeliveryStreamStatus": "ACTIVE",
@ -55,7 +53,6 @@ def test_create_http_stream():
], ],
"HasMoreDestinations": False, "HasMoreDestinations": False,
} }
)
@mock_firehose @mock_firehose
@ -82,4 +79,4 @@ def test_update_s3_for_http_stream():
s3_desc = desc["Destinations"][0]["HttpEndpointDestinationDescription"][ s3_desc = desc["Destinations"][0]["HttpEndpointDestinationDescription"][
"S3DestinationDescription" "S3DestinationDescription"
] ]
s3_desc.should.have.key("ErrorOutputPrefix").equals("prefix2") assert s3_desc["ErrorOutputPrefix"] == "prefix2"