Remove redundant test code (#3640)
These tests, when run, do not execute any `moto` code. They fail the parameter validation check in `botocore`, which raises an exception before ever sending a request. These tests do not cover or verify any `moto` behavior and have been removed.
This commit is contained in:
parent
779d18e00c
commit
cd044ef00b
@ -3,7 +3,6 @@ import boto3
|
|||||||
from moto import mock_applicationautoscaling, mock_ecs
|
from moto import mock_applicationautoscaling, mock_ecs
|
||||||
from moto.applicationautoscaling import models
|
from moto.applicationautoscaling import models
|
||||||
from moto.applicationautoscaling.exceptions import AWSValidationException
|
from moto.applicationautoscaling.exceptions import AWSValidationException
|
||||||
from botocore.exceptions import ParamValidationError
|
|
||||||
import pytest
|
import pytest
|
||||||
import sure # noqa
|
import sure # noqa
|
||||||
from botocore.exceptions import ClientError
|
from botocore.exceptions import ClientError
|
||||||
@ -21,27 +20,6 @@ DEFAULT_MAX_CAPACITY = 1
|
|||||||
DEFAULT_ROLE_ARN = "test:arn"
|
DEFAULT_ROLE_ARN = "test:arn"
|
||||||
|
|
||||||
|
|
||||||
@mock_applicationautoscaling
|
|
||||||
def test_describe_scalable_targets_no_params_should_raise_param_validation_errors():
|
|
||||||
client = boto3.client("application-autoscaling", region_name=DEFAULT_REGION)
|
|
||||||
with pytest.raises(ParamValidationError):
|
|
||||||
client.describe_scalable_targets()
|
|
||||||
|
|
||||||
|
|
||||||
@mock_applicationautoscaling
|
|
||||||
def test_register_scalable_target_no_params_should_raise_param_validation_errors():
|
|
||||||
client = boto3.client("application-autoscaling", region_name=DEFAULT_REGION)
|
|
||||||
with pytest.raises(ParamValidationError):
|
|
||||||
client.register_scalable_target()
|
|
||||||
|
|
||||||
|
|
||||||
@mock_applicationautoscaling
|
|
||||||
def test_register_scalable_target_with_none_service_namespace_should_raise_param_validation_errors():
|
|
||||||
client = boto3.client("application-autoscaling", region_name=DEFAULT_REGION)
|
|
||||||
with pytest.raises(ParamValidationError):
|
|
||||||
register_scalable_target(client, ServiceNamespace=None)
|
|
||||||
|
|
||||||
|
|
||||||
@mock_applicationautoscaling
|
@mock_applicationautoscaling
|
||||||
def test_describe_scalable_targets_with_invalid_scalable_dimension_should_return_validation_exception():
|
def test_describe_scalable_targets_with_invalid_scalable_dimension_should_return_validation_exception():
|
||||||
client = boto3.client("application-autoscaling", region_name=DEFAULT_REGION)
|
client = boto3.client("application-autoscaling", region_name=DEFAULT_REGION)
|
||||||
|
@ -11,7 +11,7 @@ import sure # noqa
|
|||||||
from moto import mock_dynamodb2, mock_dynamodb2_deprecated
|
from moto import mock_dynamodb2, mock_dynamodb2_deprecated
|
||||||
from moto.dynamodb2 import dynamodb_backend2, dynamodb_backends2
|
from moto.dynamodb2 import dynamodb_backend2, dynamodb_backends2
|
||||||
from boto.exception import JSONResponseError
|
from boto.exception import JSONResponseError
|
||||||
from botocore.exceptions import ClientError, ParamValidationError
|
from botocore.exceptions import ClientError
|
||||||
from tests.helpers import requires_boto_gte
|
from tests.helpers import requires_boto_gte
|
||||||
|
|
||||||
import moto.dynamodb2.comparisons
|
import moto.dynamodb2.comparisons
|
||||||
@ -4158,35 +4158,6 @@ def test_update_supports_list_append_with_nested_if_not_exists_operation_and_pro
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@mock_dynamodb2
|
|
||||||
def test_update_catches_invalid_list_append_operation():
|
|
||||||
client = boto3.client("dynamodb", region_name="us-east-1")
|
|
||||||
|
|
||||||
client.create_table(
|
|
||||||
AttributeDefinitions=[{"AttributeName": "SHA256", "AttributeType": "S"}],
|
|
||||||
TableName="TestTable",
|
|
||||||
KeySchema=[{"AttributeName": "SHA256", "KeyType": "HASH"}],
|
|
||||||
ProvisionedThroughput={"ReadCapacityUnits": 5, "WriteCapacityUnits": 5},
|
|
||||||
)
|
|
||||||
client.put_item(
|
|
||||||
TableName="TestTable",
|
|
||||||
Item={"SHA256": {"S": "sha-of-file"}, "crontab": {"L": [{"S": "bar1"}]}},
|
|
||||||
)
|
|
||||||
|
|
||||||
# Update item using invalid list_append expression
|
|
||||||
with pytest.raises(ParamValidationError) as ex:
|
|
||||||
client.update_item(
|
|
||||||
TableName="TestTable",
|
|
||||||
Key={"SHA256": {"S": "sha-of-file"}},
|
|
||||||
UpdateExpression="SET crontab = list_append(crontab, :i)",
|
|
||||||
ExpressionAttributeValues={":i": [{"S": "bar2"}]},
|
|
||||||
)
|
|
||||||
|
|
||||||
# Verify correct error is returned
|
|
||||||
str(ex.value).should.match("Parameter validation failed:")
|
|
||||||
str(ex.value).should.match("Invalid type for parameter ExpressionAttributeValues.")
|
|
||||||
|
|
||||||
|
|
||||||
def _create_user_table():
|
def _create_user_table():
|
||||||
client = boto3.client("dynamodb", region_name="us-east-1")
|
client = boto3.client("dynamodb", region_name="us-east-1")
|
||||||
client.create_table(
|
client.create_table(
|
||||||
|
@ -4,7 +4,7 @@ import pytest
|
|||||||
|
|
||||||
import boto3
|
import boto3
|
||||||
|
|
||||||
from botocore.exceptions import ParamValidationError, ClientError
|
from botocore.exceptions import ClientError
|
||||||
from botocore.parsers import ResponseParserError
|
from botocore.parsers import ResponseParserError
|
||||||
import json
|
import json
|
||||||
import sure # noqa
|
import sure # noqa
|
||||||
|
@ -10,7 +10,7 @@ import boto.vpc
|
|||||||
import pytest
|
import pytest
|
||||||
import sure # noqa
|
import sure # noqa
|
||||||
from boto.exception import EC2ResponseError
|
from boto.exception import EC2ResponseError
|
||||||
from botocore.exceptions import ClientError, ParamValidationError
|
from botocore.exceptions import ClientError
|
||||||
from moto import mock_ec2, mock_ec2_deprecated
|
from moto import mock_ec2, mock_ec2_deprecated
|
||||||
from tests import EXAMPLE_AMI_ID
|
from tests import EXAMPLE_AMI_ID
|
||||||
|
|
||||||
@ -202,11 +202,6 @@ def test_modify_subnet_attribute_validation():
|
|||||||
VpcId=vpc.id, CidrBlock="10.0.0.0/24", AvailabilityZone="us-west-1a"
|
VpcId=vpc.id, CidrBlock="10.0.0.0/24", AvailabilityZone="us-west-1a"
|
||||||
)
|
)
|
||||||
|
|
||||||
with pytest.raises(ParamValidationError):
|
|
||||||
client.modify_subnet_attribute(
|
|
||||||
SubnetId=subnet.id, MapPublicIpOnLaunch={"Value": "invalid"}
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@mock_ec2_deprecated
|
@mock_ec2_deprecated
|
||||||
def test_subnet_get_by_id():
|
def test_subnet_get_by_id():
|
||||||
|
@ -11,7 +11,7 @@ import re
|
|||||||
import sure # noqa
|
import sure # noqa
|
||||||
|
|
||||||
import boto3
|
import boto3
|
||||||
from botocore.exceptions import ClientError, ParamValidationError
|
from botocore.exceptions import ClientError
|
||||||
from dateutil.tz import tzlocal
|
from dateutil.tz import tzlocal
|
||||||
|
|
||||||
from moto import mock_ecr
|
from moto import mock_ecr
|
||||||
@ -721,26 +721,6 @@ def test_batch_get_image_that_doesnt_exist():
|
|||||||
response["failures"][0]["imageId"]["imageTag"].should.equal("v5")
|
response["failures"][0]["imageId"]["imageTag"].should.equal("v5")
|
||||||
|
|
||||||
|
|
||||||
@mock_ecr
|
|
||||||
def test_batch_get_image_no_tags():
|
|
||||||
client = boto3.client("ecr", region_name="us-east-1")
|
|
||||||
_ = client.create_repository(repositoryName="test_repository")
|
|
||||||
|
|
||||||
_ = client.put_image(
|
|
||||||
repositoryName="test_repository",
|
|
||||||
imageManifest=json.dumps(_create_image_manifest()),
|
|
||||||
imageTag="latest",
|
|
||||||
)
|
|
||||||
|
|
||||||
error_msg = re.compile(
|
|
||||||
r".*Missing required parameter in input: \"imageIds\".*", re.MULTILINE
|
|
||||||
)
|
|
||||||
|
|
||||||
client.batch_get_image.when.called_with(
|
|
||||||
repositoryName="test_repository"
|
|
||||||
).should.throw(ParamValidationError, error_msg)
|
|
||||||
|
|
||||||
|
|
||||||
@mock_ecr
|
@mock_ecr
|
||||||
def test_batch_delete_image_by_tag():
|
def test_batch_delete_image_by_tag():
|
||||||
client = boto3.client("ecr", region_name="us-east-1")
|
client = boto3.client("ecr", region_name="us-east-1")
|
||||||
|
@ -3,7 +3,7 @@ from __future__ import unicode_literals
|
|||||||
import os
|
import os
|
||||||
import boto3
|
import boto3
|
||||||
import botocore
|
import botocore
|
||||||
from botocore.exceptions import ClientError, ParamValidationError
|
from botocore.exceptions import ClientError
|
||||||
import pytest
|
import pytest
|
||||||
import sure # noqa
|
import sure # noqa
|
||||||
|
|
||||||
@ -1879,71 +1879,6 @@ def test_fixed_response_action_listener_rule_validates_status_code():
|
|||||||
)
|
)
|
||||||
load_balancer_arn = response.get("LoadBalancers")[0].get("LoadBalancerArn")
|
load_balancer_arn = response.get("LoadBalancers")[0].get("LoadBalancerArn")
|
||||||
|
|
||||||
missing_status_code_action = {
|
|
||||||
"Type": "fixed-response",
|
|
||||||
"FixedResponseConfig": {
|
|
||||||
"ContentType": "text/plain",
|
|
||||||
"MessageBody": "This page does not exist",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
with pytest.raises(ParamValidationError):
|
|
||||||
conn.create_listener(
|
|
||||||
LoadBalancerArn=load_balancer_arn,
|
|
||||||
Protocol="HTTP",
|
|
||||||
Port=80,
|
|
||||||
DefaultActions=[missing_status_code_action],
|
|
||||||
)
|
|
||||||
|
|
||||||
invalid_status_code_action = {
|
|
||||||
"Type": "fixed-response",
|
|
||||||
"FixedResponseConfig": {
|
|
||||||
"ContentType": "text/plain",
|
|
||||||
"MessageBody": "This page does not exist",
|
|
||||||
"StatusCode": "100",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
@mock_elbv2
|
|
||||||
@mock_ec2
|
|
||||||
def test_fixed_response_action_listener_rule_validates_status_code():
|
|
||||||
conn = boto3.client("elbv2", region_name="us-east-1")
|
|
||||||
ec2 = boto3.resource("ec2", region_name="us-east-1")
|
|
||||||
|
|
||||||
security_group = ec2.create_security_group(
|
|
||||||
GroupName="a-security-group", Description="First One"
|
|
||||||
)
|
|
||||||
vpc = ec2.create_vpc(CidrBlock="172.28.7.0/24", InstanceTenancy="default")
|
|
||||||
subnet1 = ec2.create_subnet(
|
|
||||||
VpcId=vpc.id, CidrBlock="172.28.7.192/26", AvailabilityZone="us-east-1a"
|
|
||||||
)
|
|
||||||
subnet2 = ec2.create_subnet(
|
|
||||||
VpcId=vpc.id, CidrBlock="172.28.7.128/26", AvailabilityZone="us-east-1b"
|
|
||||||
)
|
|
||||||
|
|
||||||
response = conn.create_load_balancer(
|
|
||||||
Name="my-lb",
|
|
||||||
Subnets=[subnet1.id, subnet2.id],
|
|
||||||
SecurityGroups=[security_group.id],
|
|
||||||
Scheme="internal",
|
|
||||||
Tags=[{"Key": "key_name", "Value": "a_value"}],
|
|
||||||
)
|
|
||||||
load_balancer_arn = response.get("LoadBalancers")[0].get("LoadBalancerArn")
|
|
||||||
|
|
||||||
missing_status_code_action = {
|
|
||||||
"Type": "fixed-response",
|
|
||||||
"FixedResponseConfig": {
|
|
||||||
"ContentType": "text/plain",
|
|
||||||
"MessageBody": "This page does not exist",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
with pytest.raises(ParamValidationError):
|
|
||||||
conn.create_listener(
|
|
||||||
LoadBalancerArn=load_balancer_arn,
|
|
||||||
Protocol="HTTP",
|
|
||||||
Port=80,
|
|
||||||
DefaultActions=[missing_status_code_action],
|
|
||||||
)
|
|
||||||
|
|
||||||
invalid_status_code_action = {
|
invalid_status_code_action = {
|
||||||
"Type": "fixed-response",
|
"Type": "fixed-response",
|
||||||
"FixedResponseConfig": {
|
"FixedResponseConfig": {
|
||||||
|
@ -395,7 +395,6 @@ def test_generate_data_key_decrypt():
|
|||||||
dict(KeySpec="AES_257"),
|
dict(KeySpec="AES_257"),
|
||||||
dict(KeySpec="AES_128", NumberOfBytes=16),
|
dict(KeySpec="AES_128", NumberOfBytes=16),
|
||||||
dict(NumberOfBytes=2048),
|
dict(NumberOfBytes=2048),
|
||||||
dict(NumberOfBytes=0),
|
|
||||||
dict(),
|
dict(),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
@ -404,9 +403,7 @@ def test_generate_data_key_invalid_size_params(kwargs):
|
|||||||
client = boto3.client("kms", region_name="us-east-1")
|
client = boto3.client("kms", region_name="us-east-1")
|
||||||
key = client.create_key(Description="generate-data-key-size")
|
key = client.create_key(Description="generate-data-key-size")
|
||||||
|
|
||||||
with pytest.raises(
|
with pytest.raises(botocore.exceptions.ClientError):
|
||||||
(botocore.exceptions.ClientError, botocore.exceptions.ParamValidationError)
|
|
||||||
) as err:
|
|
||||||
client.generate_data_key(KeyId=key["KeyMetadata"]["KeyId"], **kwargs)
|
client.generate_data_key(KeyId=key["KeyMetadata"]["KeyId"], **kwargs)
|
||||||
|
|
||||||
|
|
||||||
@ -538,13 +535,7 @@ def test_generate_random(number_of_bytes):
|
|||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"number_of_bytes,error_type",
|
"number_of_bytes,error_type",
|
||||||
[
|
[(2048, botocore.exceptions.ClientError), (1025, botocore.exceptions.ClientError),],
|
||||||
(2048, botocore.exceptions.ClientError),
|
|
||||||
(1025, botocore.exceptions.ClientError),
|
|
||||||
(0, botocore.exceptions.ParamValidationError),
|
|
||||||
(-1, botocore.exceptions.ParamValidationError),
|
|
||||||
(-1024, botocore.exceptions.ParamValidationError),
|
|
||||||
],
|
|
||||||
)
|
)
|
||||||
@mock_kms
|
@mock_kms
|
||||||
def test_generate_random_invalid_number_of_bytes(number_of_bytes, error_type):
|
def test_generate_random_invalid_number_of_bytes(number_of_bytes, error_type):
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from botocore.exceptions import ClientError, ParamValidationError
|
from botocore.exceptions import ClientError
|
||||||
import boto3
|
import boto3
|
||||||
import sure # noqa
|
import sure # noqa
|
||||||
from moto import mock_ec2, mock_kms, mock_rds2
|
from moto import mock_ec2, mock_kms, mock_rds2
|
||||||
@ -786,16 +786,8 @@ def test_modify_non_existent_option_group():
|
|||||||
conn = boto3.client("rds", region_name="us-west-2")
|
conn = boto3.client("rds", region_name="us-west-2")
|
||||||
conn.modify_option_group.when.called_with(
|
conn.modify_option_group.when.called_with(
|
||||||
OptionGroupName="non-existent",
|
OptionGroupName="non-existent",
|
||||||
OptionsToInclude=[
|
OptionsToInclude=[{"OptionName": "test-option"}],
|
||||||
(
|
).should.throw(ClientError, "Specified OptionGroupName: non-existent not found.")
|
||||||
"OptionName",
|
|
||||||
"Port",
|
|
||||||
"DBSecurityGroupMemberships",
|
|
||||||
"VpcSecurityGroupMemberships",
|
|
||||||
"OptionSettings",
|
|
||||||
)
|
|
||||||
],
|
|
||||||
).should.throw(ParamValidationError)
|
|
||||||
|
|
||||||
|
|
||||||
@mock_rds2
|
@mock_rds2
|
||||||
|
@ -4806,29 +4806,6 @@ def test_encryption():
|
|||||||
conn.get_bucket_encryption(Bucket="mybucket")
|
conn.get_bucket_encryption(Bucket="mybucket")
|
||||||
|
|
||||||
|
|
||||||
@mock_s3
|
|
||||||
def test_presigned_url_restrict_parameters():
|
|
||||||
# Only specific params can be set
|
|
||||||
# Ensure error is thrown when adding custom metadata this way
|
|
||||||
bucket = str(uuid.uuid4())
|
|
||||||
key = "file.txt"
|
|
||||||
conn = boto3.resource("s3", region_name="us-east-1")
|
|
||||||
conn.create_bucket(Bucket=bucket)
|
|
||||||
s3 = boto3.client("s3", region_name="us-east-1")
|
|
||||||
|
|
||||||
# Create a pre-signed url with some metadata.
|
|
||||||
with pytest.raises(botocore.exceptions.ParamValidationError) as err:
|
|
||||||
s3.generate_presigned_url(
|
|
||||||
ClientMethod="put_object",
|
|
||||||
Params={"Bucket": bucket, "Key": key, "Unknown": "metadata"},
|
|
||||||
)
|
|
||||||
assert str(err.value).should.match(
|
|
||||||
r'Parameter validation failed:\nUnknown parameter in input: "Unknown", must be one of:.*'
|
|
||||||
)
|
|
||||||
|
|
||||||
s3.delete_bucket(Bucket=bucket)
|
|
||||||
|
|
||||||
|
|
||||||
@mock_s3
|
@mock_s3
|
||||||
def test_presigned_put_url_with_approved_headers():
|
def test_presigned_put_url_with_approved_headers():
|
||||||
bucket = str(uuid.uuid4())
|
bucket = str(uuid.uuid4())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user