Upgrade flake8 to 4.x (#5066)

This commit is contained in:
Bert Blommers 2022-04-27 11:58:59 +00:00 committed by GitHub
parent e703ee9a76
commit d60df32a25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 70 additions and 83 deletions

View File

@ -738,7 +738,7 @@ class ApiGatewayV2Response(BaseResponse):
def get_vpc_links(self): def get_vpc_links(self):
vpc_links = self.apigatewayv2_backend.get_vpc_links() vpc_links = self.apigatewayv2_backend.get_vpc_links()
return 200, {}, json.dumps({"items": [l.to_json() for l in vpc_links]}) return 200, {}, json.dumps({"items": [link.to_json() for link in vpc_links]})
def update_vpc_link(self): def update_vpc_link(self):
vpc_link_id = self.path.split("/")[-1] vpc_link_id = self.path.split("/")[-1]

View File

@ -9,5 +9,5 @@ class InvalidParameterValueException(JsonRESTError):
class ClusterNotFoundFault(JsonRESTError): class ClusterNotFoundFault(JsonRESTError):
def __init__(self, name=None): def __init__(self, name=None):
# DescribeClusters and DeleteCluster use a different message for the same error # DescribeClusters and DeleteCluster use a different message for the same error
msg = f"Cluster {name} not found." if name else f"Cluster not found." msg = f"Cluster {name} not found." if name else "Cluster not found."
super().__init__("ClusterNotFoundFault", msg) super().__init__("ClusterNotFoundFault", msg)

View File

@ -482,7 +482,7 @@ class VPCBackend(object):
association_set = vpc.associate_vpc_cidr_block( association_set = vpc.associate_vpc_cidr_block(
cidr_block, amazon_provided_ipv6_cidr_block cidr_block, amazon_provided_ipv6_cidr_block
) )
for route_table in self.route_tables.values(): for route_table in self.route_tables.copy().values():
if route_table.vpc_id == vpc_id: if route_table.vpc_id == vpc_id:
if amazon_provided_ipv6_cidr_block: if amazon_provided_ipv6_cidr_block:
self.create_route( self.create_route(

View File

@ -2,7 +2,7 @@
-r requirements-tests.txt -r requirements-tests.txt
black==22.1.0 black==22.1.0
flake8==3.7.8 flake8==4.0.1
# https://github.com/pallets/click/issues/2232 # https://github.com/pallets/click/issues/2232
click<8.1.0 click<8.1.0
inflection inflection

View File

@ -105,7 +105,9 @@ def test_create_custom_lambda_resource__verify_cfnresponse_failed():
) )
execution_failed.should.equal(True) execution_failed.should.equal(True)
printed_events = [l for l in logs if l.startswith("{'RequestType': 'Create'")] printed_events = [
line for line in logs if line.startswith("{'RequestType': 'Create'")
]
printed_events.should.have.length_of(1) printed_events.should.have.length_of(1)
original_event = json.loads(printed_events[0].replace("'", '"')) original_event = json.loads(printed_events[0].replace("'", '"'))
original_event.should.have.key("RequestType").equals("Create") original_event.should.have.key("RequestType").equals("Create")

View File

@ -414,7 +414,7 @@ def test_create_user_pool_string_schema_min_bigger_than_max():
) )
ex.value.response["Error"]["Code"].should.equal("InvalidParameterException") ex.value.response["Error"]["Code"].should.equal("InvalidParameterException")
ex.value.response["Error"]["Message"].should.equal( ex.value.response["Error"]["Message"].should.equal(
f"user.email: Max length cannot be less than min length." "user.email: Max length cannot be less than min length."
) )
ex.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400) ex.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
@ -435,7 +435,7 @@ def test_create_user_pool_number_schema_min_bigger_than_max():
) )
ex.value.response["Error"]["Code"].should.equal("InvalidParameterException") ex.value.response["Error"]["Code"].should.equal("InvalidParameterException")
ex.value.response["Error"]["Message"].should.equal( ex.value.response["Error"]["Message"].should.equal(
f"user.updated_at: Max value cannot be less than min value." "user.updated_at: Max value cannot be less than min value."
) )
ex.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400) ex.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
@ -482,7 +482,7 @@ def test_add_custom_attributes_existing_attribute():
ex.value.response["Error"]["Code"].should.equal("InvalidParameterException") ex.value.response["Error"]["Code"].should.equal("InvalidParameterException")
ex.value.response["Error"]["Message"].should.equal( ex.value.response["Error"]["Message"].should.equal(
f"custom:banana: Existing attribute already has name dev:custom:banana." "custom:banana: Existing attribute already has name dev:custom:banana."
) )
ex.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400) ex.value.response["ResponseMetadata"]["HTTPStatusCode"].should.equal(400)
@ -1824,7 +1824,7 @@ def test_admin_confirm_sign_up_non_existing_user():
err = exc.value.response["Error"] err = exc.value.response["Error"]
err["Code"].should.equal("UserNotFoundException") err["Code"].should.equal("UserNotFoundException")
err["Message"].should.equal(f"User does not exist.") err["Message"].should.equal("User does not exist.")
@mock_cognitoidp @mock_cognitoidp
@ -1879,7 +1879,7 @@ def test_admin_resend_invitation_missing_user():
) )
err = exc.value.response["Error"] err = exc.value.response["Error"]
err["Code"].should.equal("UserNotFoundException") err["Code"].should.equal("UserNotFoundException")
err["Message"].should.equal(f"User does not exist.") err["Message"].should.equal("User does not exist.")
@mock_cognitoidp @mock_cognitoidp
@ -1965,7 +1965,7 @@ def test_admin_get_missing_user():
err = exc.value.response["Error"] err = exc.value.response["Error"]
err["Code"].should.equal("UserNotFoundException") err["Code"].should.equal("UserNotFoundException")
err["Message"].should.equal(f"User does not exist.") err["Message"].should.equal("User does not exist.")
@mock_cognitoidp @mock_cognitoidp
@ -1982,7 +1982,7 @@ def test_admin_get_missing_user_with_username_attributes():
err = exc.value.response["Error"] err = exc.value.response["Error"]
err["Code"].should.equal("UserNotFoundException") err["Code"].should.equal("UserNotFoundException")
err["Message"].should.equal(f"User does not exist.") err["Message"].should.equal("User does not exist.")
@mock_cognitoidp @mock_cognitoidp

View File

@ -522,7 +522,7 @@ def test_transact_write_items__too_many_transactions():
} }
} }
update_email_transact(f"test1@moto.com") update_email_transact("test1@moto.com")
with pytest.raises(ClientError) as exc: with pytest.raises(ClientError) as exc:
dynamodb.transact_write_items( dynamodb.transact_write_items(
TransactItems=[ TransactItems=[

View File

@ -118,7 +118,7 @@ def test_query_filter_boto3():
) )
for i in range(0, 3): for i in range(0, 3):
table.put_item(Item={"pk": "pk".format(i), "sk": "sk-{}".format(i)}) table.put_item(Item={"pk": "pk", "sk": "sk-{}".format(i)})
res = table.query(KeyConditionExpression=Key("pk").eq("pk")) res = table.query(KeyConditionExpression=Key("pk").eq("pk"))
res["Items"].should.have.length_of(3) res["Items"].should.have.length_of(3)

View File

@ -703,7 +703,7 @@ def test_vpc_endpoint_creation():
ec2_client = boto3.client("ec2", region_name="us-west-1") ec2_client = boto3.client("ec2", region_name="us-west-1")
vpc = ec2.create_vpc(CidrBlock="10.0.0.0/16") vpc = ec2.create_vpc(CidrBlock="10.0.0.0/16")
subnet1 = ec2.create_subnet( subnet1 = ec2.create_subnet(
VpcId=vpc.id, CidrBlock="10.0.0.0/24", AvailabilityZone=f"us-west-1a" VpcId=vpc.id, CidrBlock="10.0.0.0/24", AvailabilityZone="us-west-1a"
) )
subnet_template = { subnet_template = {

View File

@ -9,8 +9,6 @@ import sure # noqa # pylint: disable=unused-import
from moto import mock_ec2 from moto import mock_ec2
from tests import EXAMPLE_AMI_ID from tests import EXAMPLE_AMI_ID
import logging
@mock_ec2 @mock_ec2
def test_eip_allocate_classic(): def test_eip_allocate_classic():
@ -104,7 +102,6 @@ def test_specific_eip_allocate_vpc():
vpc = client.allocate_address(Domain="vpc", Address="127.38.43.222") vpc = client.allocate_address(Domain="vpc", Address="127.38.43.222")
vpc["Domain"].should.be.equal("vpc") vpc["Domain"].should.be.equal("vpc")
vpc["PublicIp"].should.be.equal("127.38.43.222") vpc["PublicIp"].should.be.equal("127.38.43.222")
logging.debug("vpc alloc_id:".format(vpc["AllocationId"]))
@mock_ec2 @mock_ec2

View File

@ -54,7 +54,7 @@ def test_describe_managed_prefix_lists():
all_lists = ec2.describe_managed_prefix_lists()["PrefixLists"] all_lists = ec2.describe_managed_prefix_lists()["PrefixLists"]
[pl["PrefixListId"] for pl in all_lists].should.contain(pl_id) [pl["PrefixListId"] for pl in all_lists].should.contain(pl_id)
set([l["OwnerId"] for l in all_lists]).should.equal({"aws", ACCOUNT_ID}) set([pl["OwnerId"] for pl in all_lists]).should.equal({"aws", ACCOUNT_ID})
@mock_ec2 @mock_ec2
@ -64,7 +64,7 @@ def test_describe_managed_prefix_lists_with_prefix():
default_lists = ec2.describe_managed_prefix_lists()["PrefixLists"] default_lists = ec2.describe_managed_prefix_lists()["PrefixLists"]
if not settings.TEST_SERVER_MODE: if not settings.TEST_SERVER_MODE:
# ServerMode is not guaranteed to only have AWS prefix lists # ServerMode is not guaranteed to only have AWS prefix lists
set([l["OwnerId"] for l in default_lists]).should.equal({"aws"}) set([pl["OwnerId"] for pl in default_lists]).should.equal({"aws"})
random_list_id = default_lists[0]["PrefixListId"] random_list_id = default_lists[0]["PrefixListId"]
@ -168,7 +168,7 @@ def test_delete_managed_prefix_list():
] ]
lists_by_id.should.have.length_of(2) lists_by_id.should.have.length_of(2)
set([l["State"] for l in lists_by_id]).should.equal( set([pl["State"] for pl in lists_by_id]).should.equal(
{"create-complete", "delete-complete"} {"create-complete", "delete-complete"}
) )
@ -186,8 +186,8 @@ def test_describe_prefix_lists():
all_lists = ec2.describe_prefix_lists()["PrefixLists"] all_lists = ec2.describe_prefix_lists()["PrefixLists"]
all_lists.should.have.length_of(2) all_lists.should.have.length_of(2)
for l in all_lists: for pl in all_lists:
l["PrefixListName"].should.contain("com.amazonaws") pl["PrefixListName"].should.contain("com.amazonaws")
@mock_ec2 @mock_ec2

View File

@ -333,7 +333,7 @@ def test_validate_error_action_properties(action, error_msg):
}, },
( (
"numeric instance is lower than the required minimum " "numeric instance is lower than the required minimum "
f"(minimum: 1, found: 0)" "(minimum: 1, found: 0)"
), ),
], ],
[ [
@ -344,7 +344,7 @@ def test_validate_error_action_properties(action, error_msg):
}, },
( (
"numeric instance is lower than the required minimum " "numeric instance is lower than the required minimum "
f"(minimum: 1, found: -1)" "(minimum: 1, found: -1)"
), ),
], ],
], ],

View File

@ -55,14 +55,14 @@ def test_create_load_balancer(zones, region_name):
describe["ListenerDescriptions"].should.have.length_of(2) describe["ListenerDescriptions"].should.have.length_of(2)
tcp = [ tcp = [
l["Listener"] desc["Listener"]
for l in describe["ListenerDescriptions"] for desc in describe["ListenerDescriptions"]
if l["Listener"]["Protocol"] == "TCP" if desc["Listener"]["Protocol"] == "TCP"
][0] ][0]
http = [ http = [
l["Listener"] desc["Listener"]
for l in describe["ListenerDescriptions"] for desc in describe["ListenerDescriptions"]
if l["Listener"]["Protocol"] == "HTTP" if desc["Listener"]["Protocol"] == "HTTP"
][0] ][0]
tcp.should.equal( tcp.should.equal(
{ {
@ -566,16 +566,14 @@ def test_get_load_balancers_by_name():
client.describe_load_balancers(LoadBalancerNames=["unknownlb"]) client.describe_load_balancers(LoadBalancerNames=["unknownlb"])
err = ex.value.response["Error"] err = ex.value.response["Error"]
err["Code"].should.equal("LoadBalancerNotFound") err["Code"].should.equal("LoadBalancerNotFound")
err["Message"].should.equal( err["Message"].should.equal("The specified load balancer does not exist: unknownlb")
f"The specified load balancer does not exist: unknownlb"
)
with pytest.raises(ClientError) as ex: with pytest.raises(ClientError) as ex:
client.describe_load_balancers(LoadBalancerNames=[lb_name1, "unknownlb"]) client.describe_load_balancers(LoadBalancerNames=[lb_name1, "unknownlb"])
err = ex.value.response["Error"] err = ex.value.response["Error"]
err["Code"].should.equal("LoadBalancerNotFound") err["Code"].should.equal("LoadBalancerNotFound")
# Bug - message sometimes shows the lb that does exist # Bug - message sometimes shows the lb that does exist
err["Message"].should.match(f"The specified load balancer does not exist:") err["Message"].should.match("The specified load balancer does not exist:")
@mock_elb @mock_elb
@ -1003,8 +1001,8 @@ def test_add_remove_tags():
lb_tags = dict( lb_tags = dict(
[ [
(l["LoadBalancerName"], dict([(d["Key"], d["Value"]) for d in l["Tags"]])) (lb["LoadBalancerName"], dict([(d["Key"], d["Value"]) for d in lb["Tags"]]))
for l in client.describe_tags(LoadBalancerNames=["my-lb", "other-lb"])[ for lb in client.describe_tags(LoadBalancerNames=["my-lb", "other-lb"])[
"TagDescriptions" "TagDescriptions"
] ]
] ]

View File

@ -149,16 +149,16 @@ def test_set_policies_of_listener():
][0] ][0]
http_l = [ http_l = [
l listener
for l in balancer["ListenerDescriptions"] for listener in balancer["ListenerDescriptions"]
if l["Listener"]["Protocol"] == "HTTP" if listener["Listener"]["Protocol"] == "HTTP"
][0] ][0]
http_l.should.have.key("PolicyNames").should.equal([]) http_l.should.have.key("PolicyNames").should.equal([])
https_l = [ https_l = [
l listener
for l in balancer["ListenerDescriptions"] for listener in balancer["ListenerDescriptions"]
if l["Listener"]["Protocol"] == "HTTPS" if listener["Listener"]["Protocol"] == "HTTPS"
][0] ][0]
https_l.should.have.key("PolicyNames").should.equal(["pname"]) https_l.should.have.key("PolicyNames").should.equal(["pname"])

View File

@ -407,7 +407,7 @@ class TestCancelJobRun:
err = exc.value.response["Error"] err = exc.value.response["Error"]
assert err["Code"] == "ResourceNotFoundException" assert err["Code"] == "ResourceNotFoundException"
assert err["Message"] == f"Job run 123456789abcdefghij doesn't exist." assert err["Message"] == "Job run 123456789abcdefghij doesn't exist."
def test_wrong_job_state(self): def test_wrong_job_state(self):
with pytest.raises(ClientError) as exc: with pytest.raises(ClientError) as exc:
@ -581,4 +581,4 @@ class TestDescribeJobRun:
err = exc.value.response["Error"] err = exc.value.response["Error"]
assert err["Code"] == "ResourceNotFoundException" assert err["Code"] == "ResourceNotFoundException"
assert err["Message"] == f"Job run 123456789abcdefghij doesn't exist." assert err["Message"] == "Job run 123456789abcdefghij doesn't exist."

View File

@ -176,7 +176,7 @@ def test_describe_invalid_domain():
meta["HTTPStatusCode"].should.equal(400) meta["HTTPStatusCode"].should.equal(400)
err = exc.value.response["Error"] err = exc.value.response["Error"]
err["Message"].should.equal( err["Message"].should.equal(
f"1 validation error detected: Value 'moto.org' at 'domainName' failed to satisfy constraint: Member must satisfy regular expression pattern: [a-z][a-z0-9\\-]+" "1 validation error detected: Value 'moto.org' at 'domainName' failed to satisfy constraint: Member must satisfy regular expression pattern: [a-z][a-z0-9\\-]+"
) )
err["Code"].should.equal("ValidationException") err["Code"].should.equal("ValidationException")

View File

@ -1041,8 +1041,8 @@ def test__delete_alias__raises_if_alias_is_not_found():
) )
def sort(l): def sort(lst):
return sorted(l, key=lambda d: d.keys()) return sorted(lst, key=lambda d: d.keys())
def _check_tags(key_id, created_tags, client): def _check_tags(key_id, created_tags, client):

View File

@ -1185,7 +1185,7 @@ def test_describe_log_streams_simple_paging():
# Get stream 1-4 # Get stream 1-4
resp = client.describe_log_streams(logGroupName=group_name, limit=4) resp = client.describe_log_streams(logGroupName=group_name, limit=4)
resp["logStreams"].should.have.length_of(4) resp["logStreams"].should.have.length_of(4)
[l["logStreamName"] for l in resp["logStreams"]].should.equal( [stream["logStreamName"] for stream in resp["logStreams"]].should.equal(
["stream0", "stream1", "stream2", "stream3"] ["stream0", "stream1", "stream2", "stream3"]
) )
resp.should.have.key("nextToken") resp.should.have.key("nextToken")
@ -1195,7 +1195,7 @@ def test_describe_log_streams_simple_paging():
logGroupName=group_name, limit=4, nextToken=str(resp["nextToken"]) logGroupName=group_name, limit=4, nextToken=str(resp["nextToken"])
) )
resp["logStreams"].should.have.length_of(4) resp["logStreams"].should.have.length_of(4)
[l["logStreamName"] for l in resp["logStreams"]].should.equal( [stream["logStreamName"] for stream in resp["logStreams"]].should.equal(
["stream4", "stream5", "stream6", "stream7"] ["stream4", "stream5", "stream6", "stream7"]
) )
resp.should.have.key("nextToken") resp.should.have.key("nextToken")
@ -1205,7 +1205,7 @@ def test_describe_log_streams_simple_paging():
logGroupName=group_name, limit=4, nextToken=str(resp["nextToken"]) logGroupName=group_name, limit=4, nextToken=str(resp["nextToken"])
) )
resp["logStreams"].should.have.length_of(2) resp["logStreams"].should.have.length_of(2)
[l["logStreamName"] for l in resp["logStreams"]].should.equal( [stream["logStreamName"] for stream in resp["logStreams"]].should.equal(
["stream8", "stream9"] ["stream8", "stream9"]
) )
resp.should_not.have.key("nextToken") resp.should_not.have.key("nextToken")

View File

@ -209,9 +209,7 @@ def test_add_flow_vpc_interfaces_fails():
client.add_flow_vpc_interfaces(FlowArn=flow_arn, VpcInterfaces=[]) client.add_flow_vpc_interfaces(FlowArn=flow_arn, VpcInterfaces=[])
err = err.value.response["Error"] err = err.value.response["Error"]
err["Code"].should.equal("NotFoundException") err["Code"].should.equal("NotFoundException")
err["Message"].should.equal( err["Message"].should.equal("flow with arn=unknown-flow not found")
"flow with arn=unknown-flow not found".format(str(flow_arn))
)
@mock_mediaconnect @mock_mediaconnect
@ -256,9 +254,7 @@ def test_remove_flow_vpc_interface_fails():
) )
err = err.value.response["Error"] err = err.value.response["Error"]
err["Code"].should.equal("NotFoundException") err["Code"].should.equal("NotFoundException")
err["Message"].should.equal( err["Message"].should.equal("flow with arn=unknown-flow not found")
"flow with arn=unknown-flow not found".format(str(flow_arn))
)
@mock_mediaconnect @mock_mediaconnect
@ -293,9 +289,7 @@ def test_add_flow_outputs_fails():
client.add_flow_outputs(FlowArn=flow_arn, Outputs=[]) client.add_flow_outputs(FlowArn=flow_arn, Outputs=[])
err = err.value.response["Error"] err = err.value.response["Error"]
err["Code"].should.equal("NotFoundException") err["Code"].should.equal("NotFoundException")
err["Message"].should.equal( err["Message"].should.equal("flow with arn=unknown-flow not found")
"flow with arn=unknown-flow not found".format(str(flow_arn))
)
@mock_mediaconnect @mock_mediaconnect
@ -307,9 +301,7 @@ def test_remove_flow_output_fails():
client.remove_flow_output(FlowArn=flow_arn, OutputArn=output_arn) client.remove_flow_output(FlowArn=flow_arn, OutputArn=output_arn)
err = err.value.response["Error"] err = err.value.response["Error"]
err["Code"].should.equal("NotFoundException") err["Code"].should.equal("NotFoundException")
err["Message"].should.equal( err["Message"].should.equal("flow with arn=unknown-flow not found")
"flow with arn=unknown-flow not found".format(str(flow_arn))
)
@mock_mediaconnect @mock_mediaconnect

View File

@ -144,7 +144,7 @@ def test_create_group_membership():
client.register_user( client.register_user(
AwsAccountId=ACCOUNT_ID, AwsAccountId=ACCOUNT_ID,
Namespace="default", Namespace="default",
Email=f"fakeemail@example.com", Email="fakeemail@example.com",
IdentityType="QUICKSIGHT", IdentityType="QUICKSIGHT",
UserName="user1", UserName="user1",
UserRole="READER", UserRole="READER",
@ -175,7 +175,7 @@ def test_describe_group_membership():
client.register_user( client.register_user(
AwsAccountId=ACCOUNT_ID, AwsAccountId=ACCOUNT_ID,
Namespace="default", Namespace="default",
Email=f"fakeemail@example.com", Email="fakeemail@example.com",
IdentityType="QUICKSIGHT", IdentityType="QUICKSIGHT",
UserName="user1", UserName="user1",
UserRole="READER", UserRole="READER",
@ -214,7 +214,7 @@ def test_list_group_memberships():
client.register_user( client.register_user(
AwsAccountId=ACCOUNT_ID, AwsAccountId=ACCOUNT_ID,
Namespace="default", Namespace="default",
Email=f"fakeemail@example.com", Email="fakeemail@example.com",
IdentityType="QUICKSIGHT", IdentityType="QUICKSIGHT",
UserName=f"user{i}", UserName=f"user{i}",
UserRole="READER", UserRole="READER",
@ -276,7 +276,7 @@ def test_list_group_memberships__after_deleting_user():
client.register_user( client.register_user(
AwsAccountId=ACCOUNT_ID, AwsAccountId=ACCOUNT_ID,
Namespace="default", Namespace="default",
Email=f"fakeemail@example.com", Email="fakeemail@example.com",
IdentityType="QUICKSIGHT", IdentityType="QUICKSIGHT",
UserName=f"user{i}", UserName=f"user{i}",
UserRole="READER", UserRole="READER",

View File

@ -1441,7 +1441,7 @@ def test_list_resource_recordset_pagination():
# Create A Record. # Create A Record.
a_record_endpoint_payload = { a_record_endpoint_payload = {
"Comment": f"Create 500 A records", "Comment": "Create 500 A records",
"Changes": [ "Changes": [
{ {
"Action": "CREATE", "Action": "CREATE",

View File

@ -84,7 +84,7 @@ def test_objectcreated_put__invokes_lambda(match_events, actual_event):
+ str(all_logs) + str(all_logs)
) )
records = [l for l in all_logs if l.startswith("{'Records'")][0] records = [line for line in all_logs if line.startswith("{'Records'")][0]
records = json.loads(records.replace("'", '"'))["Records"] records = json.loads(records.replace("'", '"'))["Records"]
records.should.have.length_of(1) records.should.have.length_of(1)

View File

@ -64,5 +64,5 @@ def test_delete_domain_invalid():
sdb.delete_domain(DomainName="a") sdb.delete_domain(DomainName="a")
err = exc.value.response["Error"] err = exc.value.response["Error"]
err["Code"].should.equal("InvalidParameterValue") err["Code"].should.equal("InvalidParameterValue")
err["Message"].should.equal(f"Value (a) for parameter DomainName is invalid. ") err["Message"].should.equal("Value (a) for parameter DomainName is invalid. ")
err.should.have.key("BoxUsage") err.should.have.key("BoxUsage")

View File

@ -132,7 +132,7 @@ def test_send_unverified_email_with_chevrons():
# Sending an email to an unverified source should fail # Sending an email to an unverified source should fail
with pytest.raises(ClientError) as ex: with pytest.raises(ClientError) as ex:
conn.send_email( conn.send_email(
Source=f"John Smith <foobar@example.com>", # << Unverified source address Source="John Smith <foobar@example.com>", # << Unverified source address
Destination={ Destination={
"ToAddresses": ["blah@example.com"], "ToAddresses": ["blah@example.com"],
"CcAddresses": [], "CcAddresses": [],

View File

@ -49,7 +49,7 @@ def test_publish_batch_non_unique_ids():
client.publish_batch( client.publish_batch(
TopicArn=topic["TopicArn"], TopicArn=topic["TopicArn"],
PublishBatchRequestEntries=[ PublishBatchRequestEntries=[
{"Id": f"id", "Message": f"{idx}"} for idx in range(5) {"Id": "id", "Message": f"{idx}"} for idx in range(5)
], ],
) )
err = exc.value.response["Error"] err = exc.value.response["Error"]
@ -70,7 +70,7 @@ def test_publish_batch_fifo_without_message_group_id():
with pytest.raises(ClientError) as exc: with pytest.raises(ClientError) as exc:
client.publish_batch( client.publish_batch(
TopicArn=topic["TopicArn"], TopicArn=topic["TopicArn"],
PublishBatchRequestEntries=[{"Id": f"id_2", "Message": f"2"}], PublishBatchRequestEntries=[{"Id": "id_2", "Message": "2"}],
) )
err = exc.value.response["Error"] err = exc.value.response["Error"]
err["Code"].should.equal("InvalidParameter") err["Code"].should.equal("InvalidParameter")
@ -84,9 +84,9 @@ def test_publish_batch_standard_with_message_group_id():
client = boto3.client("sns", region_name="us-east-1") client = boto3.client("sns", region_name="us-east-1")
topic_arn = client.create_topic(Name="standard_topic")["TopicArn"] topic_arn = client.create_topic(Name="standard_topic")["TopicArn"]
entries = [ entries = [
{"Id": f"id_1", "Message": f"1"}, {"Id": "id_1", "Message": "1"},
{"Id": f"id_2", "Message": f"2", "MessageGroupId": "mgid"}, {"Id": "id_2", "Message": "2", "MessageGroupId": "mgid"},
{"Id": f"id_3", "Message": f"3"}, {"Id": "id_3", "Message": "3"},
] ]
resp = client.publish_batch(TopicArn=topic_arn, PublishBatchRequestEntries=entries) resp = client.publish_batch(TopicArn=topic_arn, PublishBatchRequestEntries=entries)
@ -112,11 +112,11 @@ def test_publish_batch_to_sqs():
client = boto3.client("sns", region_name="us-east-1") client = boto3.client("sns", region_name="us-east-1")
topic_arn = client.create_topic(Name="standard_topic")["TopicArn"] topic_arn = client.create_topic(Name="standard_topic")["TopicArn"]
entries = [ entries = [
{"Id": f"id_1", "Message": f"1"}, {"Id": "id_1", "Message": "1"},
{"Id": f"id_2", "Message": f"2", "Subject": "subj2"}, {"Id": "id_2", "Message": "2", "Subject": "subj2"},
{ {
"Id": f"id_3", "Id": "id_3",
"Message": f"3", "Message": "3",
"MessageAttributes": {"a": {"DataType": "String", "StringValue": "v"}}, "MessageAttributes": {"a": {"DataType": "String", "StringValue": "v"}},
}, },
] ]

View File

@ -378,9 +378,7 @@ def test_run_transcription_job_s3output_params():
transcription_job.should.contain("Transcript") transcription_job.should.contain("Transcript")
# Check aws hosted bucket # Check aws hosted bucket
transcription_job["Transcript"]["TranscriptFileUri"].should.contain( transcription_job["Transcript"]["TranscriptFileUri"].should.contain(
"https://s3.us-east-1.amazonaws.com/my-output-bucket/bucket-key/MyJob.json".format( "https://s3.us-east-1.amazonaws.com/my-output-bucket/bucket-key/MyJob.json"
region_name
)
) )
# A new job without an "OutputKey" # A new job without an "OutputKey"
job_name = "MyJob2" job_name = "MyJob2"