Testing new version of decorator.

This commit is contained in:
Steve Pulec 2017-02-15 22:35:45 -05:00
commit fde721bed7
123 changed files with 2740 additions and 1114 deletions

View file

@ -1 +1,8 @@
from __future__ import unicode_literals
import logging
# Disable extra logging for tests
logging.getLogger('boto').setLevel(logging.CRITICAL)
logging.getLogger('boto3').setLevel(logging.CRITICAL)
logging.getLogger('botocore').setLevel(logging.CRITICAL)
logging.getLogger('nose').setLevel(logging.CRITICAL)

View file

@ -5,11 +5,11 @@ from datetime import datetime
from dateutil.tz import tzutc
import boto3
from freezegun import freeze_time
import httpretty
import requests
import sure # noqa
from botocore.exceptions import ClientError
from moto.packages.responses import responses
from moto import mock_apigateway
@ -883,11 +883,10 @@ def test_deployment():
stage['description'].should.equal('_new_description_')
@httpretty.activate
@mock_apigateway
def test_http_proxying_integration():
httpretty.register_uri(
httpretty.GET, "http://httpbin.org/robots.txt", body='a fake response'
responses.add(
responses.GET, "http://httpbin.org/robots.txt", body='a fake response'
)
region_name = 'us-west-2'

View file

@ -8,12 +8,12 @@ from boto.ec2.autoscale import Tag
import boto.ec2.elb
import sure # noqa
from moto import mock_autoscaling, mock_ec2, mock_elb
from moto import mock_autoscaling, mock_ec2_deprecated, mock_elb_deprecated, mock_autoscaling_deprecated
from tests.helpers import requires_boto_gte
@mock_autoscaling
@mock_elb
@mock_autoscaling_deprecated
@mock_elb_deprecated
def test_create_autoscaling_group():
elb_conn = boto.ec2.elb.connect_to_region('us-east-1')
elb_conn.create_load_balancer('test_lb', zones=[], listeners=[(80, 8080, 'http')])
@ -73,7 +73,7 @@ def test_create_autoscaling_group():
tag.propagate_at_launch.should.equal(True)
@mock_autoscaling
@mock_autoscaling_deprecated
def test_create_autoscaling_groups_defaults():
""" Test with the minimum inputs and check that all of the proper defaults
are assigned for the other attributes """
@ -112,7 +112,7 @@ def test_create_autoscaling_groups_defaults():
list(group.tags).should.equal([])
@mock_autoscaling
@mock_autoscaling_deprecated
def test_autoscaling_group_describe_filter():
conn = boto.connect_autoscale()
config = LaunchConfiguration(
@ -138,7 +138,7 @@ def test_autoscaling_group_describe_filter():
conn.get_all_groups().should.have.length_of(3)
@mock_autoscaling
@mock_autoscaling_deprecated
def test_autoscaling_update():
conn = boto.connect_autoscale()
config = LaunchConfiguration(
@ -169,7 +169,7 @@ def test_autoscaling_update():
group.vpc_zone_identifier.should.equal('subnet-5678efgh')
@mock_autoscaling
@mock_autoscaling_deprecated
def test_autoscaling_tags_update():
conn = boto.connect_autoscale()
config = LaunchConfiguration(
@ -211,7 +211,7 @@ def test_autoscaling_tags_update():
group.tags.should.have.length_of(2)
@mock_autoscaling
@mock_autoscaling_deprecated
def test_autoscaling_group_delete():
conn = boto.connect_autoscale()
config = LaunchConfiguration(
@ -235,8 +235,8 @@ def test_autoscaling_group_delete():
conn.get_all_groups().should.have.length_of(0)
@mock_ec2
@mock_autoscaling
@mock_ec2_deprecated
@mock_autoscaling_deprecated
def test_autoscaling_group_describe_instances():
conn = boto.connect_autoscale()
config = LaunchConfiguration(
@ -269,7 +269,7 @@ def test_autoscaling_group_describe_instances():
@requires_boto_gte("2.8")
@mock_autoscaling
@mock_autoscaling_deprecated
def test_set_desired_capacity_up():
conn = boto.connect_autoscale()
config = LaunchConfiguration(
@ -304,7 +304,7 @@ def test_set_desired_capacity_up():
@requires_boto_gte("2.8")
@mock_autoscaling
@mock_autoscaling_deprecated
def test_set_desired_capacity_down():
conn = boto.connect_autoscale()
config = LaunchConfiguration(
@ -339,7 +339,7 @@ def test_set_desired_capacity_down():
@requires_boto_gte("2.8")
@mock_autoscaling
@mock_autoscaling_deprecated
def test_set_desired_capacity_the_same():
conn = boto.connect_autoscale()
config = LaunchConfiguration(
@ -372,8 +372,8 @@ def test_set_desired_capacity_the_same():
instances = list(conn.get_all_autoscaling_instances())
instances.should.have.length_of(2)
@mock_autoscaling
@mock_elb
@mock_autoscaling_deprecated
@mock_elb_deprecated
def test_autoscaling_group_with_elb():
elb_conn = boto.connect_elb()
zones = ['us-east-1a', 'us-east-1b']

View file

@ -5,11 +5,11 @@ from boto.ec2.blockdevicemapping import BlockDeviceType, BlockDeviceMapping
import sure # noqa
from moto import mock_autoscaling
from moto import mock_autoscaling_deprecated
from tests.helpers import requires_boto_gte
@mock_autoscaling
@mock_autoscaling_deprecated
def test_create_launch_configuration():
conn = boto.connect_autoscale()
config = LaunchConfiguration(
@ -38,7 +38,7 @@ def test_create_launch_configuration():
@requires_boto_gte("2.27.0")
@mock_autoscaling
@mock_autoscaling_deprecated
def test_create_launch_configuration_with_block_device_mappings():
block_device_mapping = BlockDeviceMapping()
@ -101,7 +101,7 @@ def test_create_launch_configuration_with_block_device_mappings():
@requires_boto_gte("2.12")
@mock_autoscaling
@mock_autoscaling_deprecated
def test_create_launch_configuration_for_2_12():
conn = boto.connect_autoscale()
config = LaunchConfiguration(
@ -116,7 +116,7 @@ def test_create_launch_configuration_for_2_12():
@requires_boto_gte("2.25.0")
@mock_autoscaling
@mock_autoscaling_deprecated
def test_create_launch_configuration_using_ip_association():
conn = boto.connect_autoscale()
config = LaunchConfiguration(
@ -131,7 +131,7 @@ def test_create_launch_configuration_using_ip_association():
@requires_boto_gte("2.25.0")
@mock_autoscaling
@mock_autoscaling_deprecated
def test_create_launch_configuration_using_ip_association_should_default_to_false():
conn = boto.connect_autoscale()
config = LaunchConfiguration(
@ -144,7 +144,7 @@ def test_create_launch_configuration_using_ip_association_should_default_to_fals
launch_config.associate_public_ip_address.should.equal(False)
@mock_autoscaling
@mock_autoscaling_deprecated
def test_create_launch_configuration_defaults():
""" Test with the minimum inputs and check that all of the proper defaults
are assigned for the other attributes """
@ -171,7 +171,7 @@ def test_create_launch_configuration_defaults():
@requires_boto_gte("2.12")
@mock_autoscaling
@mock_autoscaling_deprecated
def test_create_launch_configuration_defaults_for_2_12():
conn = boto.connect_autoscale()
config = LaunchConfiguration(
@ -184,7 +184,7 @@ def test_create_launch_configuration_defaults_for_2_12():
launch_config.ebs_optimized.should.equal(False)
@mock_autoscaling
@mock_autoscaling_deprecated
def test_launch_configuration_describe_filter():
conn = boto.connect_autoscale()
config = LaunchConfiguration(
@ -202,7 +202,7 @@ def test_launch_configuration_describe_filter():
conn.get_all_launch_configurations().should.have.length_of(3)
@mock_autoscaling
@mock_autoscaling_deprecated
def test_launch_configuration_delete():
conn = boto.connect_autoscale()
config = LaunchConfiguration(

View file

@ -5,7 +5,7 @@ from boto.ec2.autoscale.group import AutoScalingGroup
from boto.ec2.autoscale.policy import ScalingPolicy
import sure # noqa
from moto import mock_autoscaling
from moto import mock_autoscaling_deprecated
def setup_autoscale_group():
@ -27,7 +27,7 @@ def setup_autoscale_group():
return group
@mock_autoscaling
@mock_autoscaling_deprecated
def test_create_policy():
setup_autoscale_group()
conn = boto.connect_autoscale()
@ -48,7 +48,7 @@ def test_create_policy():
policy.cooldown.should.equal(60)
@mock_autoscaling
@mock_autoscaling_deprecated
def test_create_policy_default_values():
setup_autoscale_group()
conn = boto.connect_autoscale()
@ -67,7 +67,7 @@ def test_create_policy_default_values():
policy.cooldown.should.equal(300)
@mock_autoscaling
@mock_autoscaling_deprecated
def test_update_policy():
setup_autoscale_group()
conn = boto.connect_autoscale()
@ -94,7 +94,7 @@ def test_update_policy():
policy.scaling_adjustment.should.equal(2)
@mock_autoscaling
@mock_autoscaling_deprecated
def test_delete_policy():
setup_autoscale_group()
conn = boto.connect_autoscale()
@ -112,7 +112,7 @@ def test_delete_policy():
conn.get_all_policies().should.have.length_of(0)
@mock_autoscaling
@mock_autoscaling_deprecated
def test_execute_policy_exact_capacity():
setup_autoscale_group()
conn = boto.connect_autoscale()
@ -130,7 +130,7 @@ def test_execute_policy_exact_capacity():
instances.should.have.length_of(3)
@mock_autoscaling
@mock_autoscaling_deprecated
def test_execute_policy_positive_change_in_capacity():
setup_autoscale_group()
conn = boto.connect_autoscale()
@ -148,7 +148,7 @@ def test_execute_policy_positive_change_in_capacity():
instances.should.have.length_of(5)
@mock_autoscaling
@mock_autoscaling_deprecated
def test_execute_policy_percent_change_in_capacity():
setup_autoscale_group()
conn = boto.connect_autoscale()
@ -166,7 +166,7 @@ def test_execute_policy_percent_change_in_capacity():
instances.should.have.length_of(3)
@mock_autoscaling
@mock_autoscaling_deprecated
def test_execute_policy_small_percent_change_in_capacity():
""" http://docs.aws.amazon.com/AutoScaling/latest/DeveloperGuide/as-scale-based-on-demand.html
If PercentChangeInCapacity returns a value between 0 and 1,

View file

@ -12,7 +12,7 @@ import sure # noqa
import tests.backport_assert_raises # noqa
from nose.tools import assert_raises
from moto import mock_cloudformation, mock_s3
from moto import mock_cloudformation_deprecated, mock_s3_deprecated
from moto.cloudformation import cloudformation_backends
dummy_template = {
@ -46,7 +46,7 @@ dummy_template_json2 = json.dumps(dummy_template2)
dummy_template_json3 = json.dumps(dummy_template3)
@mock_cloudformation
@mock_cloudformation_deprecated
def test_create_stack():
conn = boto.connect_cloudformation()
conn.create_stack(
@ -69,7 +69,7 @@ def test_create_stack():
})
@mock_cloudformation
@mock_cloudformation_deprecated
def test_creating_stacks_across_regions():
west1_conn = boto.cloudformation.connect_to_region("us-west-1")
west1_conn.create_stack("test_stack", template_body=dummy_template_json)
@ -81,7 +81,7 @@ def test_creating_stacks_across_regions():
list(west2_conn.describe_stacks()).should.have.length_of(1)
@mock_cloudformation
@mock_cloudformation_deprecated
def test_create_stack_with_notification_arn():
conn = boto.connect_cloudformation()
conn.create_stack(
@ -94,8 +94,8 @@ def test_create_stack_with_notification_arn():
[n.value for n in stack.notification_arns].should.contain('arn:aws:sns:us-east-1:123456789012:fake-queue')
@mock_cloudformation
@mock_s3
@mock_cloudformation_deprecated
@mock_s3_deprecated
def test_create_stack_from_s3_url():
s3_conn = boto.s3.connect_to_region('us-west-1')
bucket = s3_conn.create_bucket("foobar")
@ -123,7 +123,7 @@ def test_create_stack_from_s3_url():
})
@mock_cloudformation
@mock_cloudformation_deprecated
def test_describe_stack_by_name():
conn = boto.connect_cloudformation()
conn.create_stack(
@ -135,7 +135,7 @@ def test_describe_stack_by_name():
stack.stack_name.should.equal('test_stack')
@mock_cloudformation
@mock_cloudformation_deprecated
def test_describe_stack_by_stack_id():
conn = boto.connect_cloudformation()
conn.create_stack(
@ -149,7 +149,7 @@ def test_describe_stack_by_stack_id():
stack_by_id.stack_name.should.equal("test_stack")
@mock_cloudformation
@mock_cloudformation_deprecated
def test_describe_deleted_stack():
conn = boto.connect_cloudformation()
conn.create_stack(
@ -166,7 +166,7 @@ def test_describe_deleted_stack():
stack_by_id.stack_status.should.equal("DELETE_COMPLETE")
@mock_cloudformation
@mock_cloudformation_deprecated
def test_get_template_by_name():
conn = boto.connect_cloudformation()
conn.create_stack(
@ -188,7 +188,7 @@ def test_get_template_by_name():
})
@mock_cloudformation
@mock_cloudformation_deprecated
def test_list_stacks():
conn = boto.connect_cloudformation()
conn.create_stack(
@ -205,7 +205,7 @@ def test_list_stacks():
stacks[0].template_description.should.equal("Stack 1")
@mock_cloudformation
@mock_cloudformation_deprecated
def test_delete_stack_by_name():
conn = boto.connect_cloudformation()
conn.create_stack(
@ -218,7 +218,7 @@ def test_delete_stack_by_name():
conn.list_stacks().should.have.length_of(0)
@mock_cloudformation
@mock_cloudformation_deprecated
def test_delete_stack_by_id():
conn = boto.connect_cloudformation()
stack_id = conn.create_stack(
@ -235,7 +235,7 @@ def test_delete_stack_by_id():
conn.describe_stacks(stack_id).should.have.length_of(1)
@mock_cloudformation
@mock_cloudformation_deprecated
def test_delete_stack_with_resource_missing_delete_attr():
conn = boto.connect_cloudformation()
conn.create_stack(
@ -248,14 +248,14 @@ def test_delete_stack_with_resource_missing_delete_attr():
conn.list_stacks().should.have.length_of(0)
@mock_cloudformation
@mock_cloudformation_deprecated
def test_bad_describe_stack():
conn = boto.connect_cloudformation()
with assert_raises(BotoServerError):
conn.describe_stacks("bad_stack")
@mock_cloudformation()
@mock_cloudformation_deprecated()
def test_cloudformation_params():
dummy_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@ -279,7 +279,7 @@ def test_cloudformation_params():
param.value.should.equal('testing123')
@mock_cloudformation
@mock_cloudformation_deprecated
def test_stack_tags():
conn = boto.connect_cloudformation()
conn.create_stack(
@ -292,7 +292,7 @@ def test_stack_tags():
dict(stack.tags).should.equal({"foo": "bar", "baz": "bleh"})
@mock_cloudformation
@mock_cloudformation_deprecated
def test_update_stack():
conn = boto.connect_cloudformation()
conn.create_stack(
@ -316,7 +316,7 @@ def test_update_stack():
})
@mock_cloudformation
@mock_cloudformation_deprecated
def test_update_stack():
conn = boto.connect_cloudformation()
conn.create_stack(
@ -339,7 +339,7 @@ def test_update_stack():
})
@mock_cloudformation
@mock_cloudformation_deprecated
def test_update_stack_when_rolled_back():
conn = boto.connect_cloudformation()
stack_id = conn.create_stack("test_stack", template_body=dummy_template_json)
@ -355,7 +355,7 @@ def test_update_stack_when_rolled_back():
ex.reason.should.equal('Bad Request')
ex.status.should.equal(400)
@mock_cloudformation
@mock_cloudformation_deprecated
def test_describe_stack_events_shows_create_update_and_delete():
conn = boto.connect_cloudformation()
stack_id = conn.create_stack("test_stack", template_body=dummy_template_json)

View file

@ -5,7 +5,7 @@ import boto
import boto.s3
import boto.s3.key
from botocore.exceptions import ClientError
from moto import mock_cloudformation, mock_s3
from moto import mock_cloudformation, mock_s3_deprecated
import json
import sure # noqa
@ -118,7 +118,7 @@ def test_create_stack_with_role_arn():
@mock_cloudformation
@mock_s3
@mock_s3_deprecated
def test_create_stack_from_s3_url():
s3_conn = boto.s3.connect_to_region('us-west-1')
bucket = s3_conn.create_bucket("foobar")

View file

@ -18,20 +18,26 @@ import boto3
import sure # noqa
from moto import (
mock_autoscaling,
mock_autoscaling_deprecated,
mock_cloudformation,
mock_datapipeline,
mock_cloudformation_deprecated,
mock_datapipeline_deprecated,
mock_ec2,
mock_ec2_deprecated,
mock_elb,
mock_iam,
mock_elb_deprecated,
mock_iam_deprecated,
mock_kms,
mock_lambda,
mock_rds,
mock_rds_deprecated,
mock_rds2,
mock_rds2_deprecated,
mock_redshift,
mock_route53,
mock_sns,
mock_redshift_deprecated,
mock_route53_deprecated,
mock_sns_deprecated,
mock_sqs,
mock_sqs_deprecated,
)
from .fixtures import (
@ -49,7 +55,7 @@ from .fixtures import (
)
@mock_cloudformation()
@mock_cloudformation_deprecated()
def test_stack_sqs_integration():
sqs_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@ -79,7 +85,7 @@ def test_stack_sqs_integration():
queue.physical_resource_id.should.equal("my-queue")
@mock_cloudformation()
@mock_cloudformation_deprecated()
def test_stack_list_resources():
sqs_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@ -110,8 +116,8 @@ def test_stack_list_resources():
queue.physical_resource_id.should.equal("my-queue")
@mock_cloudformation()
@mock_sqs()
@mock_cloudformation_deprecated()
@mock_sqs_deprecated()
def test_update_stack():
sqs_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@ -148,8 +154,8 @@ def test_update_stack():
queues[0].get_attributes('VisibilityTimeout')['VisibilityTimeout'].should.equal('100')
@mock_cloudformation()
@mock_sqs()
@mock_cloudformation_deprecated()
@mock_sqs_deprecated()
def test_update_stack_and_remove_resource():
sqs_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@ -184,8 +190,8 @@ def test_update_stack_and_remove_resource():
queues.should.have.length_of(0)
@mock_cloudformation()
@mock_sqs()
@mock_cloudformation_deprecated()
@mock_sqs_deprecated()
def test_update_stack_and_add_resource():
sqs_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@ -223,8 +229,8 @@ def test_update_stack_and_add_resource():
queues.should.have.length_of(1)
@mock_ec2()
@mock_cloudformation()
@mock_ec2_deprecated()
@mock_cloudformation_deprecated()
def test_stack_ec2_integration():
ec2_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@ -257,9 +263,9 @@ def test_stack_ec2_integration():
instance.physical_resource_id.should.equal(ec2_instance.id)
@mock_ec2()
@mock_elb()
@mock_cloudformation()
@mock_ec2_deprecated()
@mock_elb_deprecated()
@mock_cloudformation_deprecated()
def test_stack_elb_integration_with_attached_ec2_instances():
elb_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@ -307,8 +313,8 @@ def test_stack_elb_integration_with_attached_ec2_instances():
list(load_balancer.availability_zones).should.equal(['us-east-1'])
@mock_elb()
@mock_cloudformation()
@mock_elb_deprecated()
@mock_cloudformation_deprecated()
def test_stack_elb_integration_with_health_check():
elb_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@ -355,8 +361,8 @@ def test_stack_elb_integration_with_health_check():
health_check.unhealthy_threshold.should.equal(2)
@mock_elb()
@mock_cloudformation()
@mock_elb_deprecated()
@mock_cloudformation_deprecated()
def test_stack_elb_integration_with_update():
elb_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@ -399,9 +405,9 @@ def test_stack_elb_integration_with_update():
load_balancer.availability_zones[0].should.equal('us-west-1b')
@mock_ec2()
@mock_redshift()
@mock_cloudformation()
@mock_ec2_deprecated()
@mock_redshift_deprecated()
@mock_cloudformation_deprecated()
def test_redshift_stack():
redshift_template_json = json.dumps(redshift.template)
@ -443,8 +449,8 @@ def test_redshift_stack():
group.rules[0].grants[0].cidr_ip.should.equal("10.0.0.1/16")
@mock_ec2()
@mock_cloudformation()
@mock_ec2_deprecated()
@mock_cloudformation_deprecated()
def test_stack_security_groups():
security_group_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@ -519,9 +525,9 @@ def test_stack_security_groups():
rule2.grants[0].group_id.should.equal(other_group.id)
@mock_autoscaling()
@mock_elb()
@mock_cloudformation()
@mock_autoscaling_deprecated()
@mock_elb_deprecated()
@mock_cloudformation_deprecated()
def test_autoscaling_group_with_elb():
web_setup_template = {
@ -601,8 +607,8 @@ def test_autoscaling_group_with_elb():
elb_resource.physical_resource_id.should.contain("my-elb")
@mock_autoscaling()
@mock_cloudformation()
@mock_autoscaling_deprecated()
@mock_cloudformation_deprecated()
def test_autoscaling_group_update():
asg_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@ -650,8 +656,8 @@ def test_autoscaling_group_update():
asg.max_size.should.equal(3)
@mock_ec2()
@mock_cloudformation()
@mock_ec2_deprecated()
@mock_cloudformation_deprecated()
def test_vpc_single_instance_in_subnet():
template_json = json.dumps(vpc_single_instance_in_subnet.template)
@ -695,8 +701,8 @@ def test_vpc_single_instance_in_subnet():
eip_resource = [resource for resource in resources if resource.resource_type == 'AWS::EC2::EIP'][0]
eip_resource.physical_resource_id.should.equal(eip.allocation_id)
@mock_cloudformation()
@mock_ec2()
@mock_cloudformation_deprecated()
@mock_ec2_deprecated()
@mock_rds2()
def test_rds_db_parameter_groups():
ec2_conn = boto.ec2.connect_to_region("us-west-1")
@ -734,9 +740,9 @@ def test_rds_db_parameter_groups():
@mock_cloudformation()
@mock_ec2()
@mock_rds()
@mock_cloudformation_deprecated()
@mock_ec2_deprecated()
@mock_rds_deprecated()
def test_rds_mysql_with_read_replica():
ec2_conn = boto.ec2.connect_to_region("us-west-1")
ec2_conn.create_security_group('application', 'Our Application Group')
@ -776,9 +782,9 @@ def test_rds_mysql_with_read_replica():
security_group.ec2_groups[0].name.should.equal("application")
@mock_cloudformation()
@mock_ec2()
@mock_rds()
@mock_cloudformation_deprecated()
@mock_ec2_deprecated()
@mock_rds_deprecated()
def test_rds_mysql_with_read_replica_in_vpc():
template_json = json.dumps(rds_mysql_with_read_replica.template)
conn = boto.cloudformation.connect_to_region("eu-central-1")
@ -804,9 +810,9 @@ def test_rds_mysql_with_read_replica_in_vpc():
subnet_group.description.should.equal("my db subnet group")
@mock_autoscaling()
@mock_iam()
@mock_cloudformation()
@mock_autoscaling_deprecated()
@mock_iam_deprecated()
@mock_cloudformation_deprecated()
def test_iam_roles():
iam_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@ -923,8 +929,8 @@ def test_iam_roles():
role_resource.physical_resource_id.should.equal(role.role_id)
@mock_ec2()
@mock_cloudformation()
@mock_ec2_deprecated()
@mock_cloudformation_deprecated()
def test_single_instance_with_ebs_volume():
template_json = json.dumps(single_instance_with_ebs_volume.template)
@ -951,7 +957,7 @@ def test_single_instance_with_ebs_volume():
ebs_volumes[0].physical_resource_id.should.equal(volume.id)
@mock_cloudformation()
@mock_cloudformation_deprecated()
def test_create_template_without_required_param():
template_json = json.dumps(single_instance_with_ebs_volume.template)
conn = boto.cloudformation.connect_to_region("us-west-1")
@ -961,8 +967,8 @@ def test_create_template_without_required_param():
).should.throw(BotoServerError)
@mock_ec2()
@mock_cloudformation()
@mock_ec2_deprecated()
@mock_cloudformation_deprecated()
def test_classic_eip():
template_json = json.dumps(ec2_classic_eip.template)
@ -977,8 +983,8 @@ def test_classic_eip():
cfn_eip.physical_resource_id.should.equal(eip.public_ip)
@mock_ec2()
@mock_cloudformation()
@mock_ec2_deprecated()
@mock_cloudformation_deprecated()
def test_vpc_eip():
template_json = json.dumps(vpc_eip.template)
@ -993,8 +999,8 @@ def test_vpc_eip():
cfn_eip.physical_resource_id.should.equal(eip.allocation_id)
@mock_ec2()
@mock_cloudformation()
@mock_ec2_deprecated()
@mock_cloudformation_deprecated()
def test_fn_join():
template_json = json.dumps(fn_join.template)
@ -1008,8 +1014,8 @@ def test_fn_join():
fn_join_output.value.should.equal('test eip:{0}'.format(eip.public_ip))
@mock_cloudformation()
@mock_sqs()
@mock_cloudformation_deprecated()
@mock_sqs_deprecated()
def test_conditional_resources():
sqs_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@ -1054,8 +1060,8 @@ def test_conditional_resources():
list(sqs_conn.get_all_queues()).should.have.length_of(1)
@mock_cloudformation()
@mock_ec2()
@mock_cloudformation_deprecated()
@mock_ec2_deprecated()
def test_conditional_if_handling():
dummy_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@ -1110,8 +1116,8 @@ def test_conditional_if_handling():
ec2_instance.image_id.should.equal("ami-00000000")
@mock_cloudformation()
@mock_ec2()
@mock_cloudformation_deprecated()
@mock_ec2_deprecated()
def test_cloudformation_mapping():
dummy_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@ -1155,8 +1161,8 @@ def test_cloudformation_mapping():
ec2_instance.image_id.should.equal("ami-c9c7978c")
@mock_cloudformation()
@mock_route53()
@mock_cloudformation_deprecated()
@mock_route53_deprecated()
def test_route53_roundrobin():
route53_conn = boto.connect_route53()
@ -1198,9 +1204,9 @@ def test_route53_roundrobin():
output.value.should.equal('arn:aws:route53:::hostedzone/{0}'.format(zone_id))
@mock_cloudformation()
@mock_ec2()
@mock_route53()
@mock_cloudformation_deprecated()
@mock_ec2_deprecated()
@mock_route53_deprecated()
def test_route53_ec2_instance_with_public_ip():
route53_conn = boto.connect_route53()
ec2_conn = boto.ec2.connect_to_region("us-west-1")
@ -1233,8 +1239,8 @@ def test_route53_ec2_instance_with_public_ip():
record_set1.resource_records[0].should.equal("10.0.0.25")
@mock_cloudformation()
@mock_route53()
@mock_cloudformation_deprecated()
@mock_route53_deprecated()
def test_route53_associate_health_check():
route53_conn = boto.connect_route53()
@ -1270,8 +1276,8 @@ def test_route53_associate_health_check():
record_set.health_check.should.equal(health_check_id)
@mock_cloudformation()
@mock_route53()
@mock_cloudformation_deprecated()
@mock_route53_deprecated()
def test_route53_with_update():
route53_conn = boto.connect_route53()
@ -1314,8 +1320,8 @@ def test_route53_with_update():
record_set.resource_records.should.equal(["my_other.example.com"])
@mock_cloudformation()
@mock_sns()
@mock_cloudformation_deprecated()
@mock_sns_deprecated()
def test_sns_topic():
dummy_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@ -1367,8 +1373,8 @@ def test_sns_topic():
topic_arn_output.value.should.equal(topic_arn)
@mock_cloudformation
@mock_ec2
@mock_cloudformation_deprecated
@mock_ec2_deprecated
def test_vpc_gateway_attachment_creation_should_attach_itself_to_vpc():
template = {
"AWSTemplateFormatVersion": "2010-09-09",
@ -1415,8 +1421,8 @@ def test_vpc_gateway_attachment_creation_should_attach_itself_to_vpc():
igws.should.have.length_of(1)
@mock_cloudformation
@mock_ec2
@mock_cloudformation_deprecated
@mock_ec2_deprecated
def test_vpc_peering_creation():
vpc_conn = boto.vpc.connect_to_region("us-west-1")
vpc_source = vpc_conn.create_vpc("10.0.0.0/16")
@ -1445,8 +1451,8 @@ def test_vpc_peering_creation():
peering_connections.should.have.length_of(1)
@mock_cloudformation
@mock_ec2
@mock_cloudformation_deprecated
@mock_ec2_deprecated
def test_multiple_security_group_ingress_separate_from_security_group_by_id():
template = {
"AWSTemplateFormatVersion": "2010-09-09",
@ -1507,8 +1513,8 @@ def test_multiple_security_group_ingress_separate_from_security_group_by_id():
security_group1.rules[0].to_port.should.equal('8080')
@mock_cloudformation
@mock_ec2
@mock_cloudformation_deprecated
@mock_ec2_deprecated
def test_security_group_ingress_separate_from_security_group_by_id():
ec2_conn = boto.ec2.connect_to_region("us-west-1")
ec2_conn.create_security_group("test-security-group1", "test security group")
@ -1558,8 +1564,8 @@ def test_security_group_ingress_separate_from_security_group_by_id():
security_group1.rules[0].to_port.should.equal('8080')
@mock_cloudformation
@mock_ec2
@mock_cloudformation_deprecated
@mock_ec2_deprecated
def test_security_group_ingress_separate_from_security_group_by_id_using_vpc():
vpc_conn = boto.vpc.connect_to_region("us-west-1")
vpc = vpc_conn.create_vpc("10.0.0.0/16")
@ -1624,8 +1630,8 @@ def test_security_group_ingress_separate_from_security_group_by_id_using_vpc():
security_group1.rules[0].to_port.should.equal('8080')
@mock_cloudformation
@mock_ec2
@mock_cloudformation_deprecated
@mock_ec2_deprecated
def test_security_group_with_update():
vpc_conn = boto.vpc.connect_to_region("us-west-1")
vpc1 = vpc_conn.create_vpc("10.0.0.0/16")
@ -1669,8 +1675,8 @@ def test_security_group_with_update():
security_group.vpc_id.should.equal(vpc2.id)
@mock_cloudformation
@mock_ec2
@mock_cloudformation_deprecated
@mock_ec2_deprecated
def test_subnets_should_be_created_with_availability_zone():
vpc_conn = boto.vpc.connect_to_region('us-west-1')
vpc = vpc_conn.create_vpc("10.0.0.0/16")
@ -1698,8 +1704,8 @@ def test_subnets_should_be_created_with_availability_zone():
subnet.availability_zone.should.equal('us-west-1b')
@mock_cloudformation
@mock_datapipeline
@mock_cloudformation_deprecated
@mock_datapipeline_deprecated
def test_datapipeline():
dp_template = {
"AWSTemplateFormatVersion": "2010-09-09",
@ -1796,11 +1802,10 @@ def lambda_handler(event, context):
return _process_lamda(pfunc)
@mock_cloudformation
@mock_cloudformation_deprecated
@mock_lambda
def test_lambda_function():
# switch this to python as backend lambda only supports python execution.
conn = boto3.client('lambda', 'us-east-1')
template = {
"AWSTemplateFormatVersion": "2010-09-09",
"Resources": {
@ -1827,6 +1832,7 @@ def test_lambda_function():
template_body=template_json,
)
conn = boto3.client('lambda', 'us-east-1')
result = conn.list_functions()
result['Functions'].should.have.length_of(1)
result['Functions'][0]['Description'].should.equal('Test function')

View file

@ -2,7 +2,7 @@ import boto
from boto.ec2.cloudwatch.alarm import MetricAlarm
import sure # noqa
from moto import mock_cloudwatch
from moto import mock_cloudwatch_deprecated
def alarm_fixture(name="tester", action=None):
action = action or ['arn:alarm']
@ -23,7 +23,7 @@ def alarm_fixture(name="tester", action=None):
unit='Seconds',
)
@mock_cloudwatch
@mock_cloudwatch_deprecated
def test_create_alarm():
conn = boto.connect_cloudwatch()
@ -49,7 +49,7 @@ def test_create_alarm():
alarm.unit.should.equal('Seconds')
@mock_cloudwatch
@mock_cloudwatch_deprecated
def test_delete_alarm():
conn = boto.connect_cloudwatch()
@ -68,7 +68,7 @@ def test_delete_alarm():
alarms.should.have.length_of(0)
@mock_cloudwatch
@mock_cloudwatch_deprecated
def test_put_metric_data():
conn = boto.connect_cloudwatch()
@ -87,7 +87,7 @@ def test_put_metric_data():
dict(metric.dimensions).should.equal({'InstanceId': ['i-0123456,i-0123457']})
@mock_cloudwatch
@mock_cloudwatch_deprecated
def test_describe_alarms():
conn = boto.connect_cloudwatch()
@ -114,7 +114,7 @@ def test_describe_alarms():
alarms = conn.describe_alarms()
alarms.should.have.length_of(0)
@mock_cloudwatch
@mock_cloudwatch_deprecated
def test_describe_state_value_unimplemented():
conn = boto.connect_cloudwatch()

View file

@ -7,19 +7,19 @@ import unittest
import tests.backport_assert_raises # noqa
from nose.tools import assert_raises
from moto import mock_ec2, mock_s3
from moto import mock_ec2_deprecated, mock_s3_deprecated
'''
Test the different ways that the decorator can be used
'''
@mock_ec2
@mock_ec2_deprecated
def test_basic_connect():
boto.connect_ec2()
@mock_ec2
@mock_ec2_deprecated
def test_basic_decorator():
conn = boto.connect_ec2('the_key', 'the_secret')
list(conn.get_all_instances()).should.equal([])
@ -30,7 +30,7 @@ def test_context_manager():
with assert_raises(EC2ResponseError):
conn.get_all_instances()
with mock_ec2():
with mock_ec2_deprecated():
conn = boto.connect_ec2('the_key', 'the_secret')
list(conn.get_all_instances()).should.equal([])
@ -44,7 +44,7 @@ def test_decorator_start_and_stop():
with assert_raises(EC2ResponseError):
conn.get_all_instances()
mock = mock_ec2()
mock = mock_ec2_deprecated()
mock.start()
conn = boto.connect_ec2('the_key', 'the_secret')
list(conn.get_all_instances()).should.equal([])
@ -54,7 +54,7 @@ def test_decorator_start_and_stop():
conn.get_all_instances()
@mock_ec2
@mock_ec2_deprecated
def test_decorater_wrapped_gets_set():
"""
Moto decorator's __wrapped__ should get set to the tests function
@ -62,7 +62,7 @@ def test_decorater_wrapped_gets_set():
test_decorater_wrapped_gets_set.__wrapped__.__name__.should.equal('test_decorater_wrapped_gets_set')
@mock_ec2
@mock_ec2_deprecated
class Tester(object):
def test_the_class(self):
conn = boto.connect_ec2()
@ -73,7 +73,7 @@ class Tester(object):
list(conn.get_all_instances()).should.have.length_of(0)
@mock_s3
@mock_s3_deprecated
class TesterWithSetup(unittest.TestCase):
def setUp(self):
self.conn = boto.connect_s3()

View file

@ -5,12 +5,12 @@ from boto.sqs.connection import SQSConnection
from boto.sqs.message import Message
from boto.ec2 import EC2Connection
from moto import mock_sqs, mock_ec2
from moto import mock_sqs_deprecated, mock_ec2_deprecated
class TestNestedDecorators(unittest.TestCase):
@mock_sqs
@mock_sqs_deprecated
def setup_sqs_queue(self):
conn = SQSConnection()
q = conn.create_queue('some-queue')
@ -21,7 +21,7 @@ class TestNestedDecorators(unittest.TestCase):
self.assertEqual(q.count(), 1)
@mock_ec2
@mock_ec2_deprecated
def test_nested(self):
self.setup_sqs_queue()

View file

@ -3,7 +3,7 @@ from __future__ import unicode_literals
import boto.datapipeline
import sure # noqa
from moto import mock_datapipeline
from moto import mock_datapipeline_deprecated
from moto.datapipeline.utils import remove_capitalization_of_dict_keys
@ -13,7 +13,7 @@ def get_value_from_fields(key, fields):
return field['stringValue']
@mock_datapipeline
@mock_datapipeline_deprecated
def test_create_pipeline():
conn = boto.datapipeline.connect_to_region("us-west-2")
@ -78,7 +78,7 @@ PIPELINE_OBJECTS = [
]
@mock_datapipeline
@mock_datapipeline_deprecated
def test_creating_pipeline_definition():
conn = boto.datapipeline.connect_to_region("us-west-2")
res = conn.create_pipeline("mypipeline", "some-unique-id")
@ -97,7 +97,7 @@ def test_creating_pipeline_definition():
}])
@mock_datapipeline
@mock_datapipeline_deprecated
def test_describing_pipeline_objects():
conn = boto.datapipeline.connect_to_region("us-west-2")
res = conn.create_pipeline("mypipeline", "some-unique-id")
@ -116,7 +116,7 @@ def test_describing_pipeline_objects():
}])
@mock_datapipeline
@mock_datapipeline_deprecated
def test_activate_pipeline():
conn = boto.datapipeline.connect_to_region("us-west-2")
@ -133,7 +133,7 @@ def test_activate_pipeline():
get_value_from_fields('@pipelineState', fields).should.equal("SCHEDULED")
@mock_datapipeline
@mock_datapipeline_deprecated
def test_listing_pipelines():
conn = boto.datapipeline.connect_to_region("us-west-2")
res1 = conn.create_pipeline("mypipeline1", "some-unique-id1")

View file

@ -7,13 +7,13 @@ import requests
import tests.backport_assert_raises
from nose.tools import assert_raises
from moto import mock_dynamodb
from moto import mock_dynamodb, mock_dynamodb_deprecated
from moto.dynamodb import dynamodb_backend
from boto.exception import DynamoDBResponseError
@mock_dynamodb
@mock_dynamodb_deprecated
def test_list_tables():
name = 'TestTable'
dynamodb_backend.create_table(name, hash_key_attr="name", hash_key_type="S")
@ -21,7 +21,7 @@ def test_list_tables():
assert conn.list_tables() == ['TestTable']
@mock_dynamodb
@mock_dynamodb_deprecated
def test_list_tables_layer_1():
dynamodb_backend.create_table("test_1", hash_key_attr="name", hash_key_type="S")
dynamodb_backend.create_table("test_2", hash_key_attr="name", hash_key_type="S")
@ -35,7 +35,7 @@ def test_list_tables_layer_1():
res.should.equal(expected)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_describe_missing_table():
conn = boto.connect_dynamodb('the_key', 'the_secret')
with assert_raises(DynamoDBResponseError):
@ -49,7 +49,7 @@ def test_sts_handler():
res.text.should.contain("SecretAccessKey")
@mock_dynamodb
@mock_dynamodb_deprecated
def test_dynamodb_with_connect_to_region():
# this will work if connected with boto.connect_dynamodb()
dynamodb = boto.dynamodb.connect_to_region('us-west-2')

View file

@ -4,7 +4,7 @@ import boto
import sure # noqa
from freezegun import freeze_time
from moto import mock_dynamodb
from moto import mock_dynamodb_deprecated
from boto.dynamodb import condition
from boto.dynamodb.exceptions import DynamoDBKeyNotFoundError, DynamoDBValidationError
@ -29,7 +29,7 @@ def create_table(conn):
@freeze_time("2012-01-14")
@mock_dynamodb
@mock_dynamodb_deprecated
def test_create_table():
conn = boto.connect_dynamodb()
create_table(conn)
@ -60,7 +60,7 @@ def test_create_table():
conn.describe_table('messages').should.equal(expected)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_delete_table():
conn = boto.connect_dynamodb()
create_table(conn)
@ -72,7 +72,7 @@ def test_delete_table():
conn.layer1.delete_table.when.called_with('messages').should.throw(DynamoDBResponseError)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_update_table_throughput():
conn = boto.connect_dynamodb()
table = create_table(conn)
@ -86,7 +86,7 @@ def test_update_table_throughput():
table.write_units.should.equal(6)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_item_add_and_describe_and_update():
conn = boto.connect_dynamodb()
table = create_table(conn)
@ -133,7 +133,7 @@ def test_item_add_and_describe_and_update():
})
@mock_dynamodb
@mock_dynamodb_deprecated
def test_item_put_without_table():
conn = boto.connect_dynamodb()
@ -146,7 +146,7 @@ def test_item_put_without_table():
).should.throw(DynamoDBResponseError)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_get_missing_item():
conn = boto.connect_dynamodb()
table = create_table(conn)
@ -158,7 +158,7 @@ def test_get_missing_item():
table.has_item("foobar", "more").should.equal(False)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_get_item_with_undeclared_table():
conn = boto.connect_dynamodb()
@ -171,7 +171,7 @@ def test_get_item_with_undeclared_table():
).should.throw(DynamoDBKeyNotFoundError)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_get_item_without_range_key():
conn = boto.connect_dynamodb()
message_table_schema = conn.create_schema(
@ -195,7 +195,7 @@ def test_get_item_without_range_key():
table.get_item.when.called_with(hash_key=hash_key).should.throw(DynamoDBValidationError)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_delete_item():
conn = boto.connect_dynamodb()
table = create_table(conn)
@ -223,7 +223,7 @@ def test_delete_item():
item.delete.when.called_with().should.throw(DynamoDBResponseError)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_delete_item_with_attribute_response():
conn = boto.connect_dynamodb()
table = create_table(conn)
@ -260,7 +260,7 @@ def test_delete_item_with_attribute_response():
item.delete.when.called_with().should.throw(DynamoDBResponseError)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_delete_item_with_undeclared_table():
conn = boto.connect_dynamodb()
@ -273,7 +273,7 @@ def test_delete_item_with_undeclared_table():
).should.throw(DynamoDBResponseError)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_query():
conn = boto.connect_dynamodb()
table = create_table(conn)
@ -323,7 +323,7 @@ def test_query():
results.response['Items'].should.have.length_of(1)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_query_with_undeclared_table():
conn = boto.connect_dynamodb()
@ -339,7 +339,7 @@ def test_query_with_undeclared_table():
).should.throw(DynamoDBResponseError)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_scan():
conn = boto.connect_dynamodb()
table = create_table(conn)
@ -402,7 +402,7 @@ def test_scan():
results.response['Items'].should.have.length_of(1)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_scan_with_undeclared_table():
conn = boto.connect_dynamodb()
@ -419,7 +419,7 @@ def test_scan_with_undeclared_table():
).should.throw(DynamoDBResponseError)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_scan_after_has_item():
conn = boto.connect_dynamodb()
table = create_table(conn)
@ -430,7 +430,7 @@ def test_scan_after_has_item():
list(table.scan()).should.equal([])
@mock_dynamodb
@mock_dynamodb_deprecated
def test_write_batch():
conn = boto.connect_dynamodb()
table = create_table(conn)
@ -474,7 +474,7 @@ def test_write_batch():
table.item_count.should.equal(1)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_batch_read():
conn = boto.connect_dynamodb()
table = create_table(conn)

View file

@ -4,7 +4,7 @@ import boto
import sure # noqa
from freezegun import freeze_time
from moto import mock_dynamodb
from moto import mock_dynamodb_deprecated
from boto.dynamodb import condition
from boto.dynamodb.exceptions import DynamoDBKeyNotFoundError
@ -27,7 +27,7 @@ def create_table(conn):
@freeze_time("2012-01-14")
@mock_dynamodb
@mock_dynamodb_deprecated
def test_create_table():
conn = boto.connect_dynamodb()
create_table(conn)
@ -54,7 +54,7 @@ def test_create_table():
conn.describe_table('messages').should.equal(expected)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_delete_table():
conn = boto.connect_dynamodb()
create_table(conn)
@ -66,7 +66,7 @@ def test_delete_table():
conn.layer1.delete_table.when.called_with('messages').should.throw(DynamoDBResponseError)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_update_table_throughput():
conn = boto.connect_dynamodb()
table = create_table(conn)
@ -80,7 +80,7 @@ def test_update_table_throughput():
table.write_units.should.equal(6)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_item_add_and_describe_and_update():
conn = boto.connect_dynamodb()
table = create_table(conn)
@ -120,7 +120,7 @@ def test_item_add_and_describe_and_update():
})
@mock_dynamodb
@mock_dynamodb_deprecated
def test_item_put_without_table():
conn = boto.connect_dynamodb()
@ -132,7 +132,7 @@ def test_item_put_without_table():
).should.throw(DynamoDBResponseError)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_get_missing_item():
conn = boto.connect_dynamodb()
table = create_table(conn)
@ -142,7 +142,7 @@ def test_get_missing_item():
).should.throw(DynamoDBKeyNotFoundError)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_get_item_with_undeclared_table():
conn = boto.connect_dynamodb()
@ -154,7 +154,7 @@ def test_get_item_with_undeclared_table():
).should.throw(DynamoDBKeyNotFoundError)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_delete_item():
conn = boto.connect_dynamodb()
table = create_table(conn)
@ -181,7 +181,7 @@ def test_delete_item():
item.delete.when.called_with().should.throw(DynamoDBResponseError)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_delete_item_with_attribute_response():
conn = boto.connect_dynamodb()
table = create_table(conn)
@ -216,7 +216,7 @@ def test_delete_item_with_attribute_response():
item.delete.when.called_with().should.throw(DynamoDBResponseError)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_delete_item_with_undeclared_table():
conn = boto.connect_dynamodb()
@ -228,7 +228,7 @@ def test_delete_item_with_undeclared_table():
).should.throw(DynamoDBResponseError)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_query():
conn = boto.connect_dynamodb()
table = create_table(conn)
@ -248,7 +248,7 @@ def test_query():
results.response['Items'].should.have.length_of(1)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_query_with_undeclared_table():
conn = boto.connect_dynamodb()
@ -258,7 +258,7 @@ def test_query_with_undeclared_table():
).should.throw(DynamoDBResponseError)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_scan():
conn = boto.connect_dynamodb()
table = create_table(conn)
@ -318,7 +318,7 @@ def test_scan():
results.response['Items'].should.have.length_of(1)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_scan_with_undeclared_table():
conn = boto.connect_dynamodb()
@ -335,7 +335,7 @@ def test_scan_with_undeclared_table():
).should.throw(DynamoDBResponseError)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_scan_after_has_item():
conn = boto.connect_dynamodb()
table = create_table(conn)
@ -346,7 +346,7 @@ def test_scan_after_has_item():
list(table.scan()).should.equal([])
@mock_dynamodb
@mock_dynamodb_deprecated
def test_write_batch():
conn = boto.connect_dynamodb()
table = create_table(conn)
@ -388,7 +388,7 @@ def test_write_batch():
table.item_count.should.equal(1)
@mock_dynamodb
@mock_dynamodb_deprecated
def test_batch_read():
conn = boto.connect_dynamodb()
table = create_table(conn)

View file

@ -4,7 +4,7 @@ import six
import boto
import sure # noqa
import requests
from moto import mock_dynamodb2
from moto import mock_dynamodb2, mock_dynamodb2_deprecated
from moto.dynamodb2 import dynamodb_backend2
from boto.exception import JSONResponseError
from tests.helpers import requires_boto_gte
@ -16,7 +16,7 @@ except ImportError:
print("This boto version is not supported")
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_list_tables():
name = 'TestTable'
#{'schema': }
@ -32,7 +32,7 @@ def test_list_tables():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_list_tables_layer_1():
dynamodb_backend2.create_table("test_1",schema=[
{u'KeyType': u'HASH', u'AttributeName': u'name'}
@ -55,7 +55,7 @@ def test_list_tables_layer_1():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_describe_missing_table():
conn = boto.dynamodb2.connect_to_region(
'us-west-2',

View file

@ -7,7 +7,7 @@ import boto3
from boto3.dynamodb.conditions import Key
import sure # noqa
from freezegun import freeze_time
from moto import mock_dynamodb2
from moto import mock_dynamodb2, mock_dynamodb2_deprecated
from boto.exception import JSONResponseError
from tests.helpers import requires_boto_gte
try:
@ -61,7 +61,7 @@ def iterate_results(res):
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
@freeze_time("2012-01-14")
def test_create_table():
table = create_table()
@ -90,7 +90,7 @@ def test_create_table():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
@freeze_time("2012-01-14")
def test_create_table_with_local_index():
table = create_table_with_local_indexes()
@ -132,7 +132,7 @@ def test_create_table_with_local_index():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_delete_table():
conn = boto.dynamodb2.layer1.DynamoDBConnection()
table = create_table()
@ -144,7 +144,7 @@ def test_delete_table():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_update_table_throughput():
table = create_table()
table.throughput["read"].should.equal(10)
@ -169,7 +169,7 @@ def test_update_table_throughput():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_item_add_and_describe_and_update():
table = create_table()
ok = table.put_item(data={
@ -212,7 +212,7 @@ def test_item_add_and_describe_and_update():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_item_partial_save():
table = create_table()
@ -242,7 +242,7 @@ def test_item_partial_save():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_item_put_without_table():
table = Table('undeclared-table')
item_data = {
@ -256,7 +256,7 @@ def test_item_put_without_table():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_get_missing_item():
table = create_table()
@ -267,14 +267,14 @@ def test_get_missing_item():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_get_item_with_undeclared_table():
table = Table('undeclared-table')
table.get_item.when.called_with(test_hash=3241526475).should.throw(JSONResponseError)
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_get_item_without_range_key():
table = Table.create('messages', schema=[
HashKey('test_hash'),
@ -291,7 +291,7 @@ def test_get_item_without_range_key():
@requires_boto_gte("2.30.0")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_delete_item():
table = create_table()
item_data = {
@ -313,7 +313,7 @@ def test_delete_item():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_delete_item_with_undeclared_table():
table = Table("undeclared-table")
item_data = {
@ -327,7 +327,7 @@ def test_delete_item_with_undeclared_table():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_query():
table = create_table()
@ -384,7 +384,7 @@ def test_query():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_query_with_undeclared_table():
table = Table('undeclared')
results = table.query(
@ -396,7 +396,7 @@ def test_query_with_undeclared_table():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_scan():
table = create_table()
item_data = {
@ -451,7 +451,7 @@ def test_scan():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_scan_with_undeclared_table():
conn = boto.dynamodb2.layer1.DynamoDBConnection()
conn.scan.when.called_with(
@ -468,7 +468,7 @@ def test_scan_with_undeclared_table():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_write_batch():
table = create_table()
with table.batch_write() as batch:
@ -498,7 +498,7 @@ def test_write_batch():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_batch_read():
table = create_table()
item_data = {
@ -542,14 +542,14 @@ def test_batch_read():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_get_key_fields():
table = create_table()
kf = table.get_key_fields()
kf.should.equal(['forum_name', 'subject'])
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_create_with_global_indexes():
conn = boto.dynamodb2.layer1.DynamoDBConnection()
@ -594,7 +594,7 @@ def test_create_with_global_indexes():
])
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_query_with_global_indexes():
table = Table.create('messages', schema=[
HashKey('subject'),
@ -638,7 +638,7 @@ def test_query_with_global_indexes():
list(results).should.have.length_of(0)
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_query_with_local_indexes():
table = create_table_with_local_indexes()
item_data = {
@ -658,7 +658,7 @@ def test_query_with_local_indexes():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_query_filter_eq():
table = create_table_with_local_indexes()
item_data = [
@ -691,7 +691,7 @@ def test_query_filter_eq():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_query_filter_lt():
table = create_table_with_local_indexes()
item_data = [
@ -726,7 +726,7 @@ def test_query_filter_lt():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_query_filter_gt():
table = create_table_with_local_indexes()
item_data = [
@ -760,7 +760,7 @@ def test_query_filter_gt():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_query_filter_lte():
table = create_table_with_local_indexes()
item_data = [
@ -794,7 +794,7 @@ def test_query_filter_lte():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_query_filter_gte():
table = create_table_with_local_indexes()
item_data = [
@ -827,7 +827,7 @@ def test_query_filter_gte():
list(results).should.have.length_of(2)
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_reverse_query():
conn = boto.dynamodb2.layer1.DynamoDBConnection()
@ -851,7 +851,7 @@ def test_reverse_query():
[r['created_at'] for r in results].should.equal(expected)
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_lookup():
from decimal import Decimal
table = Table.create('messages', schema=[
@ -871,7 +871,7 @@ def test_lookup():
message.get('test_range').should.equal(Decimal(range_key))
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_failed_overwrite():
table = Table.create('messages', schema=[
HashKey('id'),
@ -900,7 +900,7 @@ def test_failed_overwrite():
dict(returned_item).should.equal(data4)
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_conflicting_writes():
table = Table.create('messages', schema=[
HashKey('id'),

View file

@ -6,7 +6,7 @@ from boto3.dynamodb.conditions import Key
import sure # noqa
from freezegun import freeze_time
from boto.exception import JSONResponseError
from moto import mock_dynamodb2
from moto import mock_dynamodb2, mock_dynamodb2_deprecated
from tests.helpers import requires_boto_gte
import botocore
try:
@ -29,7 +29,7 @@ def create_table():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
@freeze_time("2012-01-14")
def test_create_table():
create_table()
@ -62,7 +62,7 @@ def test_create_table():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_delete_table():
create_table()
conn = boto.dynamodb2.layer1.DynamoDBConnection()
@ -75,7 +75,7 @@ def test_delete_table():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_update_table_throughput():
table = create_table()
table.throughput["read"].should.equal(10)
@ -91,7 +91,7 @@ def test_update_table_throughput():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_item_add_and_describe_and_update():
table = create_table()
@ -125,7 +125,7 @@ def test_item_add_and_describe_and_update():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_item_partial_save():
table = create_table()
@ -152,7 +152,7 @@ def test_item_partial_save():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_item_put_without_table():
conn = boto.dynamodb2.layer1.DynamoDBConnection()
@ -167,7 +167,7 @@ def test_item_put_without_table():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_get_item_with_undeclared_table():
conn = boto.dynamodb2.layer1.DynamoDBConnection()
@ -178,7 +178,7 @@ def test_get_item_with_undeclared_table():
@requires_boto_gte("2.30.0")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_delete_item():
table = create_table()
@ -202,7 +202,7 @@ def test_delete_item():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_delete_item_with_undeclared_table():
conn = boto.dynamodb2.layer1.DynamoDBConnection()
@ -213,7 +213,7 @@ def test_delete_item_with_undeclared_table():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_query():
table = create_table()
@ -233,7 +233,7 @@ def test_query():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_query_with_undeclared_table():
conn = boto.dynamodb2.layer1.DynamoDBConnection()
@ -244,7 +244,7 @@ def test_query_with_undeclared_table():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_scan():
table = create_table()
@ -295,7 +295,7 @@ def test_scan():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_scan_with_undeclared_table():
conn = boto.dynamodb2.layer1.DynamoDBConnection()
@ -313,7 +313,7 @@ def test_scan_with_undeclared_table():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_write_batch():
table = create_table()
@ -344,7 +344,7 @@ def test_write_batch():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_batch_read():
table = create_table()
@ -385,7 +385,7 @@ def test_batch_read():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_get_key_fields():
table = create_table()
kf = table.get_key_fields()
@ -393,14 +393,14 @@ def test_get_key_fields():
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_get_missing_item():
table = create_table()
table.get_item.when.called_with(forum_name='missing').should.throw(ItemNotFound)
@requires_boto_gte("2.9")
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_get_special_item():
table = Table.create('messages', schema=[
HashKey('date-joined')
@ -418,7 +418,7 @@ def test_get_special_item():
dict(returned_item).should.equal(data)
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_update_item_remove():
conn = boto.dynamodb2.connect_to_region("us-west-2")
table = Table.create('messages', schema=[
@ -444,7 +444,7 @@ def test_update_item_remove():
})
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_update_item_set():
conn = boto.dynamodb2.connect_to_region("us-west-2")
table = Table.create('messages', schema=[
@ -471,7 +471,7 @@ def test_update_item_set():
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_failed_overwrite():
table = Table.create('messages', schema=[
HashKey('id'),
@ -499,7 +499,7 @@ def test_failed_overwrite():
dict(returned_item).should.equal(data4)
@mock_dynamodb2
@mock_dynamodb2_deprecated
def test_conflicting_writes():
table = Table.create('messages', schema=[
HashKey('id'),

View file

@ -9,11 +9,11 @@ from boto.exception import EC2ResponseError, JSONResponseError
import sure # noqa
from moto import mock_ec2
from moto import mock_emr_deprecated
from tests.helpers import requires_boto_gte
@mock_ec2
@mock_emr_deprecated
def test_ami_create_and_delete():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -69,7 +69,7 @@ def test_ami_create_and_delete():
@requires_boto_gte("2.14.0")
@mock_ec2
@mock_emr_deprecated
def test_ami_copy():
conn = boto.ec2.connect_to_region("us-west-1")
reservation = conn.run_instances('ami-1234abcd')
@ -119,7 +119,7 @@ def test_ami_copy():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_emr_deprecated
def test_ami_tagging():
conn = boto.connect_vpc('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -145,7 +145,7 @@ def test_ami_tagging():
image.tags["a key"].should.equal("some value")
@mock_ec2
@mock_emr_deprecated
def test_ami_create_from_missing_instance():
conn = boto.connect_ec2('the_key', 'the_secret')
args = ["i-abcdefg", "test-ami", "this is a test ami"]
@ -157,7 +157,7 @@ def test_ami_create_from_missing_instance():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_emr_deprecated
def test_ami_pulls_attributes_from_instance():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -169,7 +169,7 @@ def test_ami_pulls_attributes_from_instance():
image.kernel_id.should.equal('test-kernel')
@mock_ec2
@mock_emr_deprecated
def test_ami_filters():
conn = boto.connect_ec2('the_key', 'the_secret')
@ -220,7 +220,7 @@ def test_ami_filters():
set([ami.id for ami in amis_by_nonpublic]).should.equal(set([imageA.id]))
@mock_ec2
@mock_emr_deprecated
def test_ami_filtering_via_tag():
conn = boto.connect_vpc('the_key', 'the_secret')
@ -243,7 +243,7 @@ def test_ami_filtering_via_tag():
set([ami.id for ami in amis_by_tagB]).should.equal(set([imageB.id]))
@mock_ec2
@mock_emr_deprecated
def test_getting_missing_ami():
conn = boto.connect_ec2('the_key', 'the_secret')
@ -254,7 +254,7 @@ def test_getting_missing_ami():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_emr_deprecated
def test_getting_malformed_ami():
conn = boto.connect_ec2('the_key', 'the_secret')
@ -265,7 +265,7 @@ def test_getting_malformed_ami():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_emr_deprecated
def test_ami_attribute_group_permissions():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -318,7 +318,7 @@ def test_ami_attribute_group_permissions():
conn.modify_image_attribute.when.called_with(**REMOVE_GROUP_ARGS).should_not.throw(EC2ResponseError)
@mock_ec2
@mock_emr_deprecated
def test_ami_attribute_user_permissions():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -383,7 +383,7 @@ def test_ami_attribute_user_permissions():
conn.modify_image_attribute.when.called_with(**REMOVE_USERS_ARGS).should_not.throw(EC2ResponseError)
@mock_ec2
@mock_emr_deprecated
def test_ami_attribute_user_and_group_permissions():
"""
Boto supports adding/removing both users and groups at the same time.
@ -435,7 +435,7 @@ def test_ami_attribute_user_and_group_permissions():
image.is_public.should.equal(False)
@mock_ec2
@mock_emr_deprecated
def test_ami_attribute_error_cases():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')

View file

@ -4,10 +4,10 @@ import boto.ec2
import boto3
import sure # noqa
from moto import mock_ec2
from moto import mock_ec2, mock_ec2_deprecated
@mock_ec2
@mock_ec2_deprecated
def test_describe_regions():
conn = boto.connect_ec2('the_key', 'the_secret')
regions = conn.get_all_regions()
@ -16,7 +16,7 @@ def test_describe_regions():
region.endpoint.should.contain(region.name)
@mock_ec2
@mock_ec2_deprecated
def test_availability_zones():
conn = boto.connect_ec2('the_key', 'the_secret')
regions = conn.get_all_regions()

View file

@ -5,10 +5,10 @@ from nose.tools import assert_raises
from nose.tools import assert_false
from boto.exception import EC2ResponseError
from moto import mock_ec2
from moto import mock_ec2_deprecated
@mock_ec2
@mock_ec2_deprecated
def test_create_customer_gateways():
conn = boto.connect_vpc('the_key', 'the_secret')
@ -19,7 +19,7 @@ def test_create_customer_gateways():
customer_gateway.bgp_asn.should.equal(65534)
customer_gateway.ip_address.should.equal('205.251.242.54')
@mock_ec2
@mock_ec2_deprecated
def test_describe_customer_gateways():
conn = boto.connect_vpc('the_key', 'the_secret')
customer_gateway = conn.create_customer_gateway('ipsec.1', '205.251.242.54', 65534)
@ -27,7 +27,7 @@ def test_describe_customer_gateways():
cgws.should.have.length_of(1)
cgws[0].id.should.match(customer_gateway.id)
@mock_ec2
@mock_ec2_deprecated
def test_delete_customer_gateways():
conn = boto.connect_vpc('the_key', 'the_secret')
@ -39,7 +39,7 @@ def test_delete_customer_gateways():
cgws = conn.get_all_customer_gateways()
cgws.should.have.length_of(0)
@mock_ec2
@mock_ec2_deprecated
def test_delete_customer_gateways_bad_id():
conn = boto.connect_vpc('the_key', 'the_secret')
with assert_raises(EC2ResponseError) as cm:

View file

@ -9,13 +9,13 @@ from boto.exception import EC2ResponseError
import sure # noqa
from moto import mock_ec2
from moto import mock_ec2, mock_ec2_deprecated
SAMPLE_DOMAIN_NAME = u'example.com'
SAMPLE_NAME_SERVERS = [u'10.0.0.6', u'10.0.0.7']
@mock_ec2
@mock_ec2_deprecated
def test_dhcp_options_associate():
""" associate dhcp option """
conn = boto.connect_vpc('the_key', 'the_secret')
@ -26,7 +26,7 @@ def test_dhcp_options_associate():
rval.should.be.equal(True)
@mock_ec2
@mock_ec2_deprecated
def test_dhcp_options_associate_invalid_dhcp_id():
""" associate dhcp option bad dhcp options id """
conn = boto.connect_vpc('the_key', 'the_secret')
@ -39,7 +39,7 @@ def test_dhcp_options_associate_invalid_dhcp_id():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_dhcp_options_associate_invalid_vpc_id():
""" associate dhcp option invalid vpc id """
conn = boto.connect_vpc('the_key', 'the_secret')
@ -52,7 +52,7 @@ def test_dhcp_options_associate_invalid_vpc_id():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_dhcp_options_delete_with_vpc():
"""Test deletion of dhcp options with vpc"""
conn = boto.connect_vpc('the_key', 'the_secret')
@ -78,7 +78,7 @@ def test_dhcp_options_delete_with_vpc():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_create_dhcp_options():
"""Create most basic dhcp option"""
conn = boto.connect_vpc('the_key', 'the_secret')
@ -89,7 +89,7 @@ def test_create_dhcp_options():
dhcp_option.options[u'domain-name-servers'][1].should.be.equal(SAMPLE_NAME_SERVERS[1])
@mock_ec2
@mock_ec2_deprecated
def test_create_dhcp_options_invalid_options():
"""Create invalid dhcp options"""
conn = boto.connect_vpc('the_key', 'the_secret')
@ -108,7 +108,7 @@ def test_create_dhcp_options_invalid_options():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_describe_dhcp_options():
"""Test dhcp options lookup by id"""
conn = boto.connect_vpc('the_key', 'the_secret')
@ -121,7 +121,7 @@ def test_describe_dhcp_options():
dhcp_options.should.be.length_of(1)
@mock_ec2
@mock_ec2_deprecated
def test_describe_dhcp_options_invalid_id():
"""get error on invalid dhcp_option_id lookup"""
conn = boto.connect_vpc('the_key', 'the_secret')
@ -133,7 +133,7 @@ def test_describe_dhcp_options_invalid_id():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_delete_dhcp_options():
"""delete dhcp option"""
conn = boto.connect_vpc('the_key', 'the_secret')
@ -151,7 +151,7 @@ def test_delete_dhcp_options():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_delete_dhcp_options_invalid_id():
conn = boto.connect_vpc('the_key', 'the_secret')
@ -164,7 +164,7 @@ def test_delete_dhcp_options_invalid_id():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_delete_dhcp_options_malformed_id():
conn = boto.connect_vpc('the_key', 'the_secret')
@ -177,7 +177,7 @@ def test_delete_dhcp_options_malformed_id():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_dhcp_tagging():
conn = boto.connect_vpc('the_key', 'the_secret')
dhcp_option = conn.create_dhcp_options()
@ -194,7 +194,7 @@ def test_dhcp_tagging():
dhcp_option.tags["a key"].should.equal("some value")
@mock_ec2
@mock_ec2_deprecated
def test_dhcp_options_get_by_tag():
conn = boto.connect_vpc('the_key', 'the_secret')
@ -230,7 +230,7 @@ def test_dhcp_options_get_by_tag():
dhcp_options_sets.should.have.length_of(2)
@mock_ec2
@mock_ec2_deprecated
def test_dhcp_options_get_by_id():
conn = boto.connect_vpc('the_key', 'the_secret')
@ -308,7 +308,7 @@ def test_dhcp_options_get_by_key_filter():
dhcp_options_sets.should.have.length_of(3)
@mock_ec2
@mock_ec2_deprecated
def test_dhcp_options_get_by_invalid_filter():
conn = boto.connect_vpc('the_key', 'the_secret')

View file

@ -8,10 +8,10 @@ import boto
from boto.exception import EC2ResponseError, JSONResponseError
import sure # noqa
from moto import mock_ec2
from moto import mock_ec2_deprecated
@mock_ec2
@mock_ec2_deprecated
def test_create_and_delete_volume():
conn = boto.connect_ec2('the_key', 'the_secret')
volume = conn.create_volume(80, "us-east-1a")
@ -43,7 +43,7 @@ def test_create_and_delete_volume():
@mock_ec2
@mock_ec2_deprecated
def test_create_encrypted_volume_dryrun():
conn = boto.connect_ec2('the_key', 'the_secret')
with assert_raises(JSONResponseError) as ex:
@ -53,7 +53,7 @@ def test_create_encrypted_volume_dryrun():
ex.exception.message.should.equal('An error occurred (DryRunOperation) when calling the CreateVolume operation: Request would have succeeded, but DryRun flag is set')
@mock_ec2
@mock_ec2_deprecated
def test_create_encrypted_volume():
conn = boto.connect_ec2('the_key', 'the_secret')
conn.create_volume(80, "us-east-1a", encrypted=True)
@ -68,7 +68,7 @@ def test_create_encrypted_volume():
all_volumes[0].encrypted.should.be(True)
@mock_ec2
@mock_ec2_deprecated
def test_filter_volume_by_id():
conn = boto.connect_ec2('the_key', 'the_secret')
volume1 = conn.create_volume(80, "us-east-1a")
@ -82,7 +82,7 @@ def test_filter_volume_by_id():
vol2.should.have.length_of(2)
@mock_ec2
@mock_ec2_deprecated
def test_volume_filters():
conn = boto.connect_ec2('the_key', 'the_secret')
@ -155,7 +155,7 @@ def test_volume_filters():
)
@mock_ec2
@mock_ec2_deprecated
def test_volume_attach_and_detach():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -209,7 +209,7 @@ def test_volume_attach_and_detach():
cm3.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_create_snapshot():
conn = boto.connect_ec2('the_key', 'the_secret')
volume = conn.create_volume(80, "us-east-1a")
@ -245,7 +245,7 @@ def test_create_snapshot():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_create_encrypted_snapshot():
conn = boto.connect_ec2('the_key', 'the_secret')
volume = conn.create_volume(80, "us-east-1a", encrypted=True)
@ -260,7 +260,7 @@ def test_create_encrypted_snapshot():
snapshots[0].encrypted.should.be(True)
@mock_ec2
@mock_ec2_deprecated
def test_filter_snapshot_by_id():
conn = boto.connect_ec2('the_key', 'the_secret')
volume1 = conn.create_volume(36, "us-east-1a")
@ -281,7 +281,7 @@ def test_filter_snapshot_by_id():
s.region.name.should.equal(conn.region.name)
@mock_ec2
@mock_ec2_deprecated
def test_snapshot_filters():
conn = boto.connect_ec2('the_key', 'the_secret')
volume1 = conn.create_volume(20, "us-east-1a", encrypted=False)
@ -322,7 +322,7 @@ def test_snapshot_filters():
set([snap.id for snap in snapshots_by_encrypted]).should.equal(set([snapshot3.id]))
@mock_ec2
@mock_ec2_deprecated
def test_snapshot_attribute():
import copy
@ -418,7 +418,7 @@ def test_snapshot_attribute():
user_ids=['user']).should.throw(NotImplementedError)
@mock_ec2
@mock_ec2_deprecated
def test_create_volume_from_snapshot():
conn = boto.connect_ec2('the_key', 'the_secret')
volume = conn.create_volume(80, "us-east-1a")
@ -439,7 +439,7 @@ def test_create_volume_from_snapshot():
new_volume.snapshot_id.should.equal(snapshot.id)
@mock_ec2
@mock_ec2_deprecated
def test_create_volume_from_encrypted_snapshot():
conn = boto.connect_ec2('the_key', 'the_secret')
volume = conn.create_volume(80, "us-east-1a", encrypted=True)
@ -454,7 +454,7 @@ def test_create_volume_from_encrypted_snapshot():
new_volume.encrypted.should.be(True)
@mock_ec2
@mock_ec2_deprecated
def test_modify_attribute_blockDeviceMapping():
"""
Reproduces the missing feature explained at [0], where we want to mock a
@ -481,7 +481,7 @@ def test_modify_attribute_blockDeviceMapping():
instance.block_device_mapping['/dev/sda1'].delete_on_termination.should.be(True)
@mock_ec2
@mock_ec2_deprecated
def test_volume_tag_escaping():
conn = boto.connect_ec2('the_key', 'the_secret')
vol = conn.create_volume(10, 'us-east-1a')

View file

@ -10,12 +10,12 @@ import six
import sure # noqa
from moto import mock_ec2
from moto import mock_ec2, mock_ec2_deprecated
import logging
@mock_ec2
@mock_ec2_deprecated
def test_eip_allocate_classic():
"""Allocate/release Classic EIP"""
conn = boto.connect_ec2('the_key', 'the_secret')
@ -42,7 +42,7 @@ def test_eip_allocate_classic():
standard.should_not.be.within(conn.get_all_addresses())
@mock_ec2
@mock_ec2_deprecated
def test_eip_allocate_vpc():
"""Allocate/release VPC EIP"""
conn = boto.connect_ec2('the_key', 'the_secret')
@ -60,7 +60,7 @@ def test_eip_allocate_vpc():
vpc.release()
@mock_ec2
@mock_ec2_deprecated
def test_eip_allocate_invalid_domain():
"""Allocate EIP invalid domain"""
conn = boto.connect_ec2('the_key', 'the_secret')
@ -72,7 +72,7 @@ def test_eip_allocate_invalid_domain():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_eip_associate_classic():
"""Associate/Disassociate EIP to classic instance"""
conn = boto.connect_ec2('the_key', 'the_secret')
@ -114,7 +114,7 @@ def test_eip_associate_classic():
instance.terminate()
@mock_ec2
@mock_ec2_deprecated
def test_eip_associate_vpc():
"""Associate/Disassociate EIP to VPC instance"""
conn = boto.connect_ec2('the_key', 'the_secret')
@ -176,7 +176,7 @@ def test_eip_boto3_vpc_association():
instance.public_dns_name.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_eip_associate_network_interface():
"""Associate/Disassociate EIP to NIC"""
conn = boto.connect_vpc('the_key', 'the_secret')
@ -204,7 +204,7 @@ def test_eip_associate_network_interface():
eip.release()
eip = None
@mock_ec2
@mock_ec2_deprecated
def test_eip_reassociate():
"""reassociate EIP"""
conn = boto.connect_ec2('the_key', 'the_secret')
@ -233,7 +233,7 @@ def test_eip_reassociate():
instance1.terminate()
instance2.terminate()
@mock_ec2
@mock_ec2_deprecated
def test_eip_reassociate_nic():
"""reassociate EIP"""
conn = boto.connect_vpc('the_key', 'the_secret')
@ -261,7 +261,7 @@ def test_eip_reassociate_nic():
eip.release()
eip = None
@mock_ec2
@mock_ec2_deprecated
def test_eip_associate_invalid_args():
"""Associate EIP, invalid args """
conn = boto.connect_ec2('the_key', 'the_secret')
@ -280,7 +280,7 @@ def test_eip_associate_invalid_args():
instance.terminate()
@mock_ec2
@mock_ec2_deprecated
def test_eip_disassociate_bogus_association():
"""Disassociate bogus EIP"""
conn = boto.connect_ec2('the_key', 'the_secret')
@ -291,7 +291,7 @@ def test_eip_disassociate_bogus_association():
cm.exception.status.should.equal(400)
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_eip_release_bogus_eip():
"""Release bogus EIP"""
conn = boto.connect_ec2('the_key', 'the_secret')
@ -303,7 +303,7 @@ def test_eip_release_bogus_eip():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_eip_disassociate_arg_error():
"""Invalid arguments disassociate address"""
conn = boto.connect_ec2('the_key', 'the_secret')
@ -315,7 +315,7 @@ def test_eip_disassociate_arg_error():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_eip_release_arg_error():
"""Invalid arguments release address"""
conn = boto.connect_ec2('the_key', 'the_secret')
@ -327,7 +327,7 @@ def test_eip_release_arg_error():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_eip_describe():
"""Listing of allocated Elastic IP Addresses."""
conn = boto.connect_ec2('the_key', 'the_secret')
@ -363,7 +363,7 @@ def test_eip_describe():
len(conn.get_all_addresses()).should.be.equal(0)
@mock_ec2
@mock_ec2_deprecated
def test_eip_describe_none():
"""Error when search for bogus IP"""
conn = boto.connect_ec2('the_key', 'the_secret')

View file

@ -10,13 +10,13 @@ import boto.ec2
from boto.exception import EC2ResponseError, JSONResponseError
import sure # noqa
from moto import mock_ec2, mock_cloudformation
from moto import mock_ec2, mock_cloudformation_deprecated, mock_ec2_deprecated
from tests.helpers import requires_boto_gte
from tests.test_cloudformation.fixtures import vpc_eni
import json
@mock_ec2
@mock_ec2_deprecated
def test_elastic_network_interfaces():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -54,7 +54,7 @@ def test_elastic_network_interfaces():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_elastic_network_interfaces_subnet_validation():
conn = boto.connect_vpc('the_key', 'the_secret')
@ -65,7 +65,7 @@ def test_elastic_network_interfaces_subnet_validation():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_elastic_network_interfaces_with_private_ip():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -83,7 +83,7 @@ def test_elastic_network_interfaces_with_private_ip():
eni.private_ip_addresses[0].private_ip_address.should.equal(private_ip)
@mock_ec2
@mock_ec2_deprecated
def test_elastic_network_interfaces_with_groups():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -101,7 +101,7 @@ def test_elastic_network_interfaces_with_groups():
@requires_boto_gte("2.12.0")
@mock_ec2
@mock_ec2_deprecated
def test_elastic_network_interfaces_modify_attribute():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -133,7 +133,7 @@ def test_elastic_network_interfaces_modify_attribute():
eni.groups[0].id.should.equal(security_group2.id)
@mock_ec2
@mock_ec2_deprecated
def test_elastic_network_interfaces_filtering():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -281,8 +281,8 @@ def test_elastic_network_interfaces_get_by_subnet_id():
enis.should.have.length_of(0)
@mock_ec2
@mock_cloudformation
@mock_ec2_deprecated
@mock_cloudformation_deprecated
def test_elastic_network_interfaces_cloudformation():
template = vpc_eni.template
template_json = json.dumps(template)

View file

@ -7,10 +7,10 @@ import boto
from boto.exception import EC2ResponseError
import sure # noqa
from moto import mock_ec2
from moto import mock_ec2_deprecated
@mock_ec2
@mock_ec2_deprecated
def test_console_output():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -20,7 +20,7 @@ def test_console_output():
output.output.should_not.equal(None)
@mock_ec2
@mock_ec2_deprecated
def test_console_output_without_instance():
conn = boto.connect_ec2('the_key', 'the_secret')

View file

@ -12,7 +12,7 @@ from boto.exception import EC2ResponseError, JSONResponseError
from freezegun import freeze_time
import sure # noqa
from moto import mock_ec2
from moto import mock_ec2_deprecated
from tests.helpers import requires_boto_gte
@ -23,7 +23,7 @@ def add_servers(ami_id, count):
conn.run_instances(ami_id)
@mock_ec2
@mock_ec2_deprecated
def test_add_servers():
add_servers('ami-1234abcd', 2)
@ -37,7 +37,7 @@ def test_add_servers():
@freeze_time("2014-01-01 05:00:00")
@mock_ec2
@mock_ec2_deprecated
def test_instance_launch_and_terminate():
conn = boto.connect_ec2('the_key', 'the_secret')
@ -87,14 +87,14 @@ def test_instance_launch_and_terminate():
instance.state.should.equal('terminated')
@mock_ec2
@mock_ec2_deprecated
def test_terminate_empty_instances():
conn = boto.connect_ec2('the_key', 'the_secret')
conn.terminate_instances.when.called_with([]).should.throw(EC2ResponseError)
@freeze_time("2014-01-01 05:00:00")
@mock_ec2
@mock_ec2_deprecated
def test_instance_attach_volume():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -123,7 +123,7 @@ def test_instance_attach_volume():
v.status.should.equal('in-use')
@mock_ec2
@mock_ec2_deprecated
def test_get_instances_by_id():
conn = boto.connect_ec2()
reservation = conn.run_instances('ami-1234abcd', min_count=2)
@ -150,7 +150,7 @@ def test_get_instances_by_id():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_get_instances_filtering_by_state():
conn = boto.connect_ec2()
reservation = conn.run_instances('ami-1234abcd', min_count=3)
@ -178,7 +178,7 @@ def test_get_instances_filtering_by_state():
conn.get_all_instances.when.called_with(filters={'not-implemented-filter': 'foobar'}).should.throw(NotImplementedError)
@mock_ec2
@mock_ec2_deprecated
def test_get_instances_filtering_by_instance_id():
conn = boto.connect_ec2()
reservation = conn.run_instances('ami-1234abcd', min_count=3)
@ -197,7 +197,7 @@ def test_get_instances_filtering_by_instance_id():
reservations.should.have.length_of(0)
@mock_ec2
@mock_ec2_deprecated
def test_get_instances_filtering_by_instance_type():
conn = boto.connect_ec2()
reservation1 = conn.run_instances('ami-1234abcd', instance_type='m1.small')
@ -238,7 +238,7 @@ def test_get_instances_filtering_by_instance_type():
#bogus instance-type should return none
reservations.should.have.length_of(0)
@mock_ec2
@mock_ec2_deprecated
def test_get_instances_filtering_by_reason_code():
conn = boto.connect_ec2()
reservation = conn.run_instances('ami-1234abcd', min_count=3)
@ -257,7 +257,7 @@ def test_get_instances_filtering_by_reason_code():
reservations[0].instances[0].id.should.equal(instance3.id)
@mock_ec2
@mock_ec2_deprecated
def test_get_instances_filtering_by_source_dest_check():
conn = boto.connect_ec2()
reservation = conn.run_instances('ami-1234abcd', min_count=2)
@ -274,7 +274,7 @@ def test_get_instances_filtering_by_source_dest_check():
source_dest_check_true[0].instances[0].id.should.equal(instance2.id)
@mock_ec2
@mock_ec2_deprecated
def test_get_instances_filtering_by_vpc_id():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc1 = conn.create_vpc("10.0.0.0/16")
@ -298,7 +298,7 @@ def test_get_instances_filtering_by_vpc_id():
reservations2[0].instances[0].id.should.equal(instance2.id)
@mock_ec2
@mock_ec2_deprecated
def test_get_instances_filtering_by_architecture():
conn = boto.connect_ec2()
reservation = conn.run_instances('ami-1234abcd', min_count=1)
@ -309,7 +309,7 @@ def test_get_instances_filtering_by_architecture():
reservations[0].instances.should.have.length_of(1)
@mock_ec2
@mock_ec2_deprecated
def test_get_instances_filtering_by_tag():
conn = boto.connect_ec2()
reservation = conn.run_instances('ami-1234abcd', min_count=3)
@ -351,7 +351,7 @@ def test_get_instances_filtering_by_tag():
reservations[0].instances[1].id.should.equal(instance3.id)
@mock_ec2
@mock_ec2_deprecated
def test_get_instances_filtering_by_tag_value():
conn = boto.connect_ec2()
reservation = conn.run_instances('ami-1234abcd', min_count=3)
@ -388,7 +388,7 @@ def test_get_instances_filtering_by_tag_value():
reservations[0].instances[0].id.should.equal(instance1.id)
reservations[0].instances[1].id.should.equal(instance3.id)
@mock_ec2
@mock_ec2_deprecated
def test_get_instances_filtering_by_tag_name():
conn = boto.connect_ec2()
reservation = conn.run_instances('ami-1234abcd', min_count=3)
@ -418,7 +418,7 @@ def test_get_instances_filtering_by_tag_name():
reservations[0].instances[1].id.should.equal(instance2.id)
reservations[0].instances[2].id.should.equal(instance3.id)
@mock_ec2
@mock_ec2_deprecated
def test_instance_start_and_stop():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd', min_count=2)
@ -448,7 +448,7 @@ def test_instance_start_and_stop():
started_instances[0].state.should.equal('pending')
@mock_ec2
@mock_ec2_deprecated
def test_instance_reboot():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -464,7 +464,7 @@ def test_instance_reboot():
instance.state.should.equal('pending')
@mock_ec2
@mock_ec2_deprecated
def test_instance_attribute_instance_type():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -482,7 +482,7 @@ def test_instance_attribute_instance_type():
instance_attribute.should.be.a(InstanceAttribute)
instance_attribute.get('instanceType').should.equal("m1.small")
@mock_ec2
@mock_ec2_deprecated
def test_modify_instance_attribute_security_groups():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -506,7 +506,7 @@ def test_modify_instance_attribute_security_groups():
any(g.id == sg_id2 for g in group_list).should.be.ok
@mock_ec2
@mock_ec2_deprecated
def test_instance_attribute_user_data():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -525,7 +525,7 @@ def test_instance_attribute_user_data():
instance_attribute.get("userData").should.equal("this is my user data")
@mock_ec2
@mock_ec2_deprecated
def test_instance_attribute_source_dest_check():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -566,7 +566,7 @@ def test_instance_attribute_source_dest_check():
instance_attribute.get("sourceDestCheck").should.equal(True)
@mock_ec2
@mock_ec2_deprecated
def test_user_data_with_run_instance():
user_data = b"some user data"
conn = boto.connect_ec2('the_key', 'the_secret')
@ -580,7 +580,7 @@ def test_user_data_with_run_instance():
decoded_user_data.should.equal(b"some user data")
@mock_ec2
@mock_ec2_deprecated
def test_run_instance_with_security_group_name():
conn = boto.connect_ec2('the_key', 'the_secret')
@ -600,7 +600,7 @@ def test_run_instance_with_security_group_name():
instance.groups[0].name.should.equal("group1")
@mock_ec2
@mock_ec2_deprecated
def test_run_instance_with_security_group_id():
conn = boto.connect_ec2('the_key', 'the_secret')
group = conn.create_security_group('group1', "some description")
@ -612,7 +612,7 @@ def test_run_instance_with_security_group_id():
instance.groups[0].name.should.equal("group1")
@mock_ec2
@mock_ec2_deprecated
def test_run_instance_with_instance_type():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd', instance_type="t1.micro")
@ -621,7 +621,7 @@ def test_run_instance_with_instance_type():
instance.instance_type.should.equal("t1.micro")
@mock_ec2
@mock_ec2_deprecated
def test_run_instance_with_default_placement():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -630,7 +630,7 @@ def test_run_instance_with_default_placement():
instance.placement.should.equal("us-east-1a")
@mock_ec2
@mock_ec2_deprecated
def test_run_instance_with_placement():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd', placement="us-east-1b")
@ -639,7 +639,7 @@ def test_run_instance_with_placement():
instance.placement.should.equal("us-east-1b")
@mock_ec2
@mock_ec2_deprecated
def test_run_instance_with_subnet():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -653,7 +653,7 @@ def test_run_instance_with_subnet():
all_enis.should.have.length_of(1)
@mock_ec2
@mock_ec2_deprecated
def test_run_instance_with_nic_autocreated():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -686,7 +686,7 @@ def test_run_instance_with_nic_autocreated():
eni.private_ip_addresses[0].private_ip_address.should.equal(private_ip)
@mock_ec2
@mock_ec2_deprecated
def test_run_instance_with_nic_preexisting():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -724,7 +724,7 @@ def test_run_instance_with_nic_preexisting():
@requires_boto_gte("2.32.0")
@mock_ec2
@mock_ec2_deprecated
def test_instance_with_nic_attach_detach():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -790,7 +790,7 @@ def test_instance_with_nic_attach_detach():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_ec2_classic_has_public_ip_address():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd', key_name="keypair_name")
@ -802,7 +802,7 @@ def test_ec2_classic_has_public_ip_address():
instance.private_dns_name.should.contain(instance.private_ip_address)
@mock_ec2
@mock_ec2_deprecated
def test_run_instance_with_keypair():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd', key_name="keypair_name")
@ -811,14 +811,14 @@ def test_run_instance_with_keypair():
instance.key_name.should.equal("keypair_name")
@mock_ec2
@mock_ec2_deprecated
def test_describe_instance_status_no_instances():
conn = boto.connect_ec2('the_key', 'the_secret')
all_status = conn.get_all_instance_status()
len(all_status).should.equal(0)
@mock_ec2
@mock_ec2_deprecated
def test_describe_instance_status_with_instances():
conn = boto.connect_ec2('the_key', 'the_secret')
conn.run_instances('ami-1234abcd', key_name="keypair_name")
@ -829,7 +829,7 @@ def test_describe_instance_status_with_instances():
all_status[0].system_status.status.should.equal('ok')
@mock_ec2
@mock_ec2_deprecated
def test_describe_instance_status_with_instance_filter():
conn = boto.connect_ec2('the_key', 'the_secret')
@ -852,7 +852,7 @@ def test_describe_instance_status_with_instance_filter():
cm.exception.request_id.should_not.be.none
@requires_boto_gte("2.32.0")
@mock_ec2
@mock_ec2_deprecated
def test_describe_instance_status_with_non_running_instances():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd', min_count=3)
@ -877,7 +877,7 @@ def test_describe_instance_status_with_non_running_instances():
status3 = next((s for s in all_status if s.id == instance3.id), None)
status3.state_name.should.equal('running')
@mock_ec2
@mock_ec2_deprecated
def test_get_instance_by_security_group():
conn = boto.connect_ec2('the_key', 'the_secret')

View file

@ -10,14 +10,14 @@ from boto.exception import EC2ResponseError, JSONResponseError
import sure # noqa
from moto import mock_ec2
from moto import mock_ec2_deprecated
VPC_CIDR="10.0.0.0/16"
BAD_VPC="vpc-deadbeef"
BAD_IGW="igw-deadbeef"
@mock_ec2
@mock_ec2_deprecated
def test_igw_create():
""" internet gateway create """
conn = boto.connect_vpc('the_key', 'the_secret')
@ -37,7 +37,7 @@ def test_igw_create():
igw = conn.get_all_internet_gateways()[0]
igw.attachments.should.have.length_of(0)
@mock_ec2
@mock_ec2_deprecated
def test_igw_attach():
""" internet gateway attach """
conn = boto.connect_vpc('the_key', 'the_secret')
@ -55,7 +55,7 @@ def test_igw_attach():
igw = conn.get_all_internet_gateways()[0]
igw.attachments[0].vpc_id.should.be.equal(vpc.id)
@mock_ec2
@mock_ec2_deprecated
def test_igw_attach_bad_vpc():
""" internet gateway fail to attach w/ bad vpc """
conn = boto.connect_vpc('the_key', 'the_secret')
@ -67,7 +67,7 @@ def test_igw_attach_bad_vpc():
cm.exception.status.should.equal(400)
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_igw_attach_twice():
""" internet gateway fail to attach twice """
conn = boto.connect_vpc('the_key', 'the_secret')
@ -82,7 +82,7 @@ def test_igw_attach_twice():
cm.exception.status.should.equal(400)
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_igw_detach():
""" internet gateway detach"""
conn = boto.connect_vpc('the_key', 'the_secret')
@ -100,7 +100,7 @@ def test_igw_detach():
igw = conn.get_all_internet_gateways()[0]
igw.attachments.should.have.length_of(0)
@mock_ec2
@mock_ec2_deprecated
def test_igw_detach_wrong_vpc():
""" internet gateway fail to detach w/ wrong vpc """
conn = boto.connect_vpc('the_key', 'the_secret')
@ -115,7 +115,7 @@ def test_igw_detach_wrong_vpc():
cm.exception.status.should.equal(400)
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_igw_detach_invalid_vpc():
""" internet gateway fail to detach w/ invalid vpc """
conn = boto.connect_vpc('the_key', 'the_secret')
@ -129,7 +129,7 @@ def test_igw_detach_invalid_vpc():
cm.exception.status.should.equal(400)
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_igw_detach_unattached():
""" internet gateway fail to detach unattached """
conn = boto.connect_vpc('the_key', 'the_secret')
@ -142,7 +142,7 @@ def test_igw_detach_unattached():
cm.exception.status.should.equal(400)
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_igw_delete():
""" internet gateway delete"""
conn = boto.connect_vpc('the_key', 'the_secret')
@ -160,7 +160,7 @@ def test_igw_delete():
conn.delete_internet_gateway(igw.id)
conn.get_all_internet_gateways().should.have.length_of(0)
@mock_ec2
@mock_ec2_deprecated
def test_igw_delete_attached():
""" internet gateway fail to delete attached """
conn = boto.connect_vpc('the_key', 'the_secret')
@ -174,7 +174,7 @@ def test_igw_delete_attached():
cm.exception.status.should.equal(400)
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_igw_desribe():
""" internet gateway fetch by id """
conn = boto.connect_vpc('the_key', 'the_secret')
@ -182,7 +182,7 @@ def test_igw_desribe():
igw_by_search = conn.get_all_internet_gateways([igw.id])[0]
igw.id.should.equal(igw_by_search.id)
@mock_ec2
@mock_ec2_deprecated
def test_igw_desribe_bad_id():
""" internet gateway fail to fetch by bad id """
conn = boto.connect_vpc('the_key', 'the_secret')
@ -193,7 +193,7 @@ def test_igw_desribe_bad_id():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_igw_filter_by_vpc_id():
""" internet gateway filter by vpc id """
conn = boto.connect_vpc('the_key', 'the_secret')
@ -208,7 +208,7 @@ def test_igw_filter_by_vpc_id():
result[0].id.should.equal(igw1.id)
@mock_ec2
@mock_ec2_deprecated
def test_igw_filter_by_tags():
""" internet gateway filter by vpc id """
conn = boto.connect_vpc('the_key', 'the_secret')
@ -222,7 +222,7 @@ def test_igw_filter_by_tags():
result[0].id.should.equal(igw1.id)
@mock_ec2
@mock_ec2_deprecated
def test_igw_filter_by_internet_gateway_id():
""" internet gateway filter by internet gateway id """
conn = boto.connect_vpc('the_key', 'the_secret')
@ -235,7 +235,7 @@ def test_igw_filter_by_internet_gateway_id():
result[0].id.should.equal(igw1.id)
@mock_ec2
@mock_ec2_deprecated
def test_igw_filter_by_attachment_state():
""" internet gateway filter by attachment state """
conn = boto.connect_vpc('the_key', 'the_secret')

View file

@ -8,16 +8,16 @@ import six
import sure # noqa
from boto.exception import EC2ResponseError, JSONResponseError
from moto import mock_ec2
from moto import mock_ec2_deprecated
@mock_ec2
@mock_ec2_deprecated
def test_key_pairs_empty():
conn = boto.connect_ec2('the_key', 'the_secret')
assert len(conn.get_all_key_pairs()) == 0
@mock_ec2
@mock_ec2_deprecated
def test_key_pairs_invalid_id():
conn = boto.connect_ec2('the_key', 'the_secret')
@ -28,7 +28,7 @@ def test_key_pairs_invalid_id():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_key_pairs_create():
conn = boto.connect_ec2('the_key', 'the_secret')
@ -45,7 +45,7 @@ def test_key_pairs_create():
assert kps[0].name == 'foo'
@mock_ec2
@mock_ec2_deprecated
def test_key_pairs_create_two():
conn = boto.connect_ec2('the_key', 'the_secret')
kp = conn.create_key_pair('foo')
@ -60,7 +60,7 @@ def test_key_pairs_create_two():
kps[0].name.should.equal('foo')
@mock_ec2
@mock_ec2_deprecated
def test_key_pairs_create_exist():
conn = boto.connect_ec2('the_key', 'the_secret')
kp = conn.create_key_pair('foo')
@ -74,7 +74,7 @@ def test_key_pairs_create_exist():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_key_pairs_delete_no_exist():
conn = boto.connect_ec2('the_key', 'the_secret')
assert len(conn.get_all_key_pairs()) == 0
@ -82,7 +82,7 @@ def test_key_pairs_delete_no_exist():
r.should.be.ok
@mock_ec2
@mock_ec2_deprecated
def test_key_pairs_delete_exist():
conn = boto.connect_ec2('the_key', 'the_secret')
conn.create_key_pair('foo')
@ -98,7 +98,7 @@ def test_key_pairs_delete_exist():
assert len(conn.get_all_key_pairs()) == 0
@mock_ec2
@mock_ec2_deprecated
def test_key_pairs_import():
conn = boto.connect_ec2('the_key', 'the_secret')
@ -115,7 +115,7 @@ def test_key_pairs_import():
assert kps[0].name == 'foo'
@mock_ec2
@mock_ec2_deprecated
def test_key_pairs_import_exist():
conn = boto.connect_ec2('the_key', 'the_secret')
kp = conn.import_key_pair('foo', b'content')

View file

@ -2,10 +2,10 @@ from __future__ import unicode_literals
import boto
import sure # noqa
from moto import mock_ec2
from moto import mock_ec2_deprecated
@mock_ec2
@mock_ec2_deprecated
def test_default_network_acl_created_with_vpc():
conn = boto.connect_vpc('the_key', 'the secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -13,7 +13,7 @@ def test_default_network_acl_created_with_vpc():
all_network_acls.should.have.length_of(2)
@mock_ec2
@mock_ec2_deprecated
def test_network_acls():
conn = boto.connect_vpc('the_key', 'the secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -22,7 +22,7 @@ def test_network_acls():
all_network_acls.should.have.length_of(3)
@mock_ec2
@mock_ec2_deprecated
def test_new_subnet_associates_with_default_network_acl():
conn = boto.connect_vpc('the_key', 'the secret')
vpc = conn.get_all_vpcs()[0]
@ -36,7 +36,7 @@ def test_new_subnet_associates_with_default_network_acl():
[a.subnet_id for a in acl.associations].should.contain(subnet.id)
@mock_ec2
@mock_ec2_deprecated
def test_network_acl_entries():
conn = boto.connect_vpc('the_key', 'the secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -62,7 +62,7 @@ def test_network_acl_entries():
entries[0].rule_action.should.equal('ALLOW')
@mock_ec2
@mock_ec2_deprecated
def test_associate_new_network_acl_with_subnet():
conn = boto.connect_vpc('the_key', 'the secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -81,7 +81,7 @@ def test_associate_new_network_acl_with_subnet():
test_network_acl.associations[0].subnet_id.should.equal(subnet.id)
@mock_ec2
@mock_ec2_deprecated
def test_delete_network_acl():
conn = boto.connect_vpc('the_key', 'the secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -101,7 +101,7 @@ def test_delete_network_acl():
any(acl.id == network_acl.id for acl in updated_network_acls).shouldnt.be.ok
@mock_ec2
@mock_ec2_deprecated
def test_network_acl_tagging():
conn = boto.connect_vpc('the_key', 'the secret')
vpc = conn.create_vpc("10.0.0.0/16")

View file

@ -3,7 +3,7 @@ import boto.ec2
import boto.ec2.autoscale
import boto.ec2.elb
import sure
from moto import mock_ec2, mock_autoscaling, mock_elb
from moto import mock_ec2_deprecated, mock_autoscaling_deprecated, mock_elb_deprecated
def add_servers_to_region(ami_id, count, region):
@ -12,7 +12,7 @@ def add_servers_to_region(ami_id, count, region):
conn.run_instances(ami_id)
@mock_ec2
@mock_ec2_deprecated
def test_add_servers_to_a_single_region():
region = 'ap-northeast-1'
add_servers_to_region('ami-1234abcd', 1, region)
@ -27,7 +27,7 @@ def test_add_servers_to_a_single_region():
reservations[1].instances[0].image_id.should.equal('ami-5678efgh')
@mock_ec2
@mock_ec2_deprecated
def test_add_servers_to_multiple_regions():
region1 = 'us-east-1'
region2 = 'ap-northeast-1'
@ -46,8 +46,8 @@ def test_add_servers_to_multiple_regions():
ap_reservations[0].instances[0].image_id.should.equal('ami-5678efgh')
@mock_autoscaling
@mock_elb
@mock_autoscaling_deprecated
@mock_elb_deprecated
def test_create_autoscaling_group():
elb_conn = boto.ec2.elb.connect_to_region('us-east-1')
elb_conn.create_load_balancer('us_test_lb', zones=[], listeners=[(80, 8080, 'http')])

View file

@ -8,11 +8,11 @@ import boto3
from boto.exception import EC2ResponseError
import sure # noqa
from moto import mock_ec2
from moto import mock_ec2, mock_ec2_deprecated
from tests.helpers import requires_boto_gte
@mock_ec2
@mock_ec2_deprecated
def test_route_tables_defaults():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -37,7 +37,7 @@ def test_route_tables_defaults():
all_route_tables.should.have.length_of(0)
@mock_ec2
@mock_ec2_deprecated
def test_route_tables_additional():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -77,7 +77,7 @@ def test_route_tables_additional():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_route_tables_filters_standard():
conn = boto.connect_vpc('the_key', 'the_secret')
@ -115,7 +115,7 @@ def test_route_tables_filters_standard():
conn.get_all_route_tables.when.called_with(filters={'not-implemented-filter': 'foobar'}).should.throw(NotImplementedError)
@mock_ec2
@mock_ec2_deprecated
def test_route_tables_filters_associations():
conn = boto.connect_vpc('the_key', 'the_secret')
@ -152,7 +152,7 @@ def test_route_tables_filters_associations():
association1_route_tables[0].associations.should.have.length_of(2)
@mock_ec2
@mock_ec2_deprecated
def test_route_table_associations():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -219,7 +219,7 @@ def test_route_table_associations():
@requires_boto_gte("2.16.0")
@mock_ec2
@mock_ec2_deprecated
def test_route_table_replace_route_table_association():
"""
Note: Boto has deprecated replace_route_table_assocation (which returns status)
@ -289,7 +289,7 @@ def test_route_table_replace_route_table_association():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_route_table_get_by_tag():
conn = boto.connect_vpc('the_key', 'the_secret')
@ -326,7 +326,7 @@ def test_route_table_get_by_tag_boto3():
route_tables[0].tags[0].should.equal({'Key': 'Name', 'Value': 'TestRouteTable'})
@mock_ec2
@mock_ec2_deprecated
def test_routes_additional():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -364,7 +364,7 @@ def test_routes_additional():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_routes_replace():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -412,7 +412,7 @@ def test_routes_replace():
@requires_boto_gte("2.19.0")
@mock_ec2
@mock_ec2_deprecated
def test_routes_not_supported():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -431,7 +431,7 @@ def test_routes_not_supported():
@requires_boto_gte("2.34.0")
@mock_ec2
@mock_ec2_deprecated
def test_routes_vpc_peering_connection():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -458,7 +458,7 @@ def test_routes_vpc_peering_connection():
@requires_boto_gte("2.34.0")
@mock_ec2
@mock_ec2_deprecated
def test_routes_vpn_gateway():
conn = boto.connect_vpc('the_key', 'the_secret')
@ -480,7 +480,7 @@ def test_routes_vpn_gateway():
new_route.vpc_peering_connection_id.should.be.none
@mock_ec2
@mock_ec2_deprecated
def test_network_acl_tagging():
conn = boto.connect_vpc('the_key', 'the secret')

View file

@ -12,10 +12,10 @@ from botocore.exceptions import ClientError
from boto.exception import EC2ResponseError, JSONResponseError
import sure # noqa
from moto import mock_ec2
from moto import mock_ec2, mock_ec2_deprecated
@mock_ec2
@mock_ec2_deprecated
def test_create_and_describe_security_group():
conn = boto.connect_ec2('the_key', 'the_secret')
@ -43,7 +43,7 @@ def test_create_and_describe_security_group():
set(group_names).should.equal(set(["default", "test security group"]))
@mock_ec2
@mock_ec2_deprecated
def test_create_security_group_without_description_raises_error():
conn = boto.connect_ec2('the_key', 'the_secret')
@ -54,7 +54,7 @@ def test_create_security_group_without_description_raises_error():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_default_security_group():
conn = boto.ec2.connect_to_region('us-east-1')
groups = conn.get_all_security_groups()
@ -62,7 +62,7 @@ def test_default_security_group():
groups[0].name.should.equal("default")
@mock_ec2
@mock_ec2_deprecated
def test_create_and_describe_vpc_security_group():
conn = boto.connect_ec2('the_key', 'the_secret')
vpc_id = 'vpc-5300000c'
@ -88,7 +88,7 @@ def test_create_and_describe_vpc_security_group():
all_groups[0].name.should.equal('test security group')
@mock_ec2
@mock_ec2_deprecated
def test_create_two_security_groups_with_same_name_in_different_vpc():
conn = boto.connect_ec2('the_key', 'the_secret')
vpc_id = 'vpc-5300000c'
@ -105,7 +105,7 @@ def test_create_two_security_groups_with_same_name_in_different_vpc():
set(group_names).should.equal(set(["default", "test security group"]))
@mock_ec2
@mock_ec2_deprecated
def test_deleting_security_groups():
conn = boto.connect_ec2('the_key', 'the_secret')
security_group1 = conn.create_security_group('test1', 'test1')
@ -135,7 +135,7 @@ def test_deleting_security_groups():
conn.get_all_security_groups().should.have.length_of(2)
@mock_ec2
@mock_ec2_deprecated
def test_delete_security_group_in_vpc():
conn = boto.connect_ec2('the_key', 'the_secret')
vpc_id = "vpc-12345"
@ -145,7 +145,7 @@ def test_delete_security_group_in_vpc():
conn.delete_security_group(group_id=security_group1.id)
@mock_ec2
@mock_ec2_deprecated
def test_authorize_ip_range_and_revoke():
conn = boto.connect_ec2('the_key', 'the_secret')
security_group = conn.create_security_group('test', 'test')
@ -216,7 +216,7 @@ def test_authorize_ip_range_and_revoke():
egress_security_group.rules_egress.should.have.length_of(1)
@mock_ec2
@mock_ec2_deprecated
def test_authorize_other_group_and_revoke():
conn = boto.connect_ec2('the_key', 'the_secret')
security_group = conn.create_security_group('test', 'test')
@ -269,7 +269,7 @@ def test_authorize_other_group_egress_and_revoke():
sg01.ip_permissions_egress.should.have.length_of(1)
@mock_ec2
@mock_ec2_deprecated
def test_authorize_group_in_vpc():
conn = boto.connect_ec2('the_key', 'the_secret')
vpc_id = "vpc-12345"
@ -295,7 +295,7 @@ def test_authorize_group_in_vpc():
security_group.rules.should.have.length_of(0)
@mock_ec2
@mock_ec2_deprecated
def test_get_all_security_groups():
conn = boto.connect_ec2()
sg1 = conn.create_security_group(name='test1', description='test1', vpc_id='vpc-mjm05d27')
@ -321,7 +321,7 @@ def test_get_all_security_groups():
resp.should.have.length_of(4)
@mock_ec2
@mock_ec2_deprecated
def test_authorize_bad_cidr_throws_invalid_parameter_value():
conn = boto.connect_ec2('the_key', 'the_secret')
security_group = conn.create_security_group('test', 'test')
@ -332,7 +332,7 @@ def test_authorize_bad_cidr_throws_invalid_parameter_value():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_security_group_tagging():
conn = boto.connect_vpc()
vpc = conn.create_vpc("10.0.0.0/16")
@ -356,7 +356,7 @@ def test_security_group_tagging():
group.tags["Test"].should.equal("Tag")
@mock_ec2
@mock_ec2_deprecated
def test_security_group_tag_filtering():
conn = boto.connect_ec2()
sg = conn.create_security_group("test-sg", "Test SG")
@ -366,7 +366,7 @@ def test_security_group_tag_filtering():
groups.should.have.length_of(1)
@mock_ec2
@mock_ec2_deprecated
def test_authorize_all_protocols_with_no_port_specification():
conn = boto.connect_ec2()
sg = conn.create_security_group('test', 'test')
@ -379,7 +379,7 @@ def test_authorize_all_protocols_with_no_port_specification():
sg.rules[0].to_port.should.equal(None)
@mock_ec2
@mock_ec2_deprecated
def test_sec_group_rule_limit():
ec2_conn = boto.connect_ec2()
sg = ec2_conn.create_security_group('test', 'test')
@ -441,7 +441,7 @@ def test_sec_group_rule_limit():
cm.exception.error_code.should.equal('RulesPerSecurityGroupLimitExceeded')
@mock_ec2
@mock_ec2_deprecated
def test_sec_group_rule_limit_vpc():
ec2_conn = boto.connect_ec2()
vpc_conn = boto.connect_vpc()
@ -611,7 +611,7 @@ def test_authorize_and_revoke_in_bulk():
for ip_permission in expected_ip_permissions:
sg01.ip_permissions_egress.shouldnt.contain(ip_permission)
@mock_ec2
@mock_ec2_deprecated
def test_get_all_security_groups_filter_with_same_vpc_id():
conn = boto.connect_ec2('the_key', 'the_secret')
vpc_id = 'vpc-5300000c'

View file

@ -7,12 +7,13 @@ import boto3
import sure # noqa
from boto.exception import JSONResponseError
from moto import mock_ec2
from moto import mock_ec2, mock_ec2_deprecated
from moto.backends import get_model
from moto.core.utils import iso_8601_datetime_with_milliseconds
@mock_ec2
@mock_ec2_deprecated
def test_request_spot_instances():
conn = boto3.client('ec2', 'us-east-1')
vpc = conn.create_vpc(CidrBlock="10.0.0.0/8")['Vpc']
@ -73,7 +74,7 @@ def test_request_spot_instances():
request.launch_specification.subnet_id.should.equal(subnet_id)
@mock_ec2
@mock_ec2_deprecated
def test_request_spot_instances_default_arguments():
"""
Test that moto set the correct default arguments
@ -106,7 +107,7 @@ def test_request_spot_instances_default_arguments():
request.launch_specification.subnet_id.should.equal(None)
@mock_ec2
@mock_ec2_deprecated
def test_cancel_spot_instance_request():
conn = boto.connect_ec2()
@ -130,7 +131,7 @@ def test_cancel_spot_instance_request():
requests.should.have.length_of(0)
@mock_ec2
@mock_ec2_deprecated
def test_request_spot_instances_fulfilled():
"""
Test that moto correctly fullfills a spot instance request
@ -156,7 +157,7 @@ def test_request_spot_instances_fulfilled():
request.state.should.equal("active")
@mock_ec2
@mock_ec2_deprecated
def test_tag_spot_instance_request():
"""
Test that moto correctly tags a spot instance request
@ -177,7 +178,7 @@ def test_tag_spot_instance_request():
tag_dict.should.equal({'tag1': 'value1', 'tag2': 'value2'})
@mock_ec2
@mock_ec2_deprecated
def test_get_all_spot_instance_requests_filtering():
"""
Test that moto correctly filters spot instance requests
@ -211,7 +212,7 @@ def test_get_all_spot_instance_requests_filtering():
requests.should.have.length_of(1)
@mock_ec2
@mock_ec2_deprecated
def test_request_spot_instances_setting_instance_id():
conn = boto.ec2.connect_to_region("us-east-1")
request = conn.request_spot_instances(

View file

@ -11,10 +11,10 @@ from botocore.exceptions import ParamValidationError
import json
import sure # noqa
from moto import mock_cloudformation, mock_ec2
from moto import mock_cloudformation_deprecated, mock_ec2, mock_ec2_deprecated
@mock_ec2
@mock_ec2_deprecated
def test_subnets():
ec2 = boto.connect_ec2('the_key', 'the_secret')
conn = boto.connect_vpc('the_key', 'the_secret')
@ -36,7 +36,7 @@ def test_subnets():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_subnet_create_vpc_validation():
conn = boto.connect_vpc('the_key', 'the_secret')
@ -47,7 +47,7 @@ def test_subnet_create_vpc_validation():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_subnet_tagging():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -65,7 +65,7 @@ def test_subnet_tagging():
subnet.tags["a key"].should.equal("some value")
@mock_ec2
@mock_ec2_deprecated
def test_subnet_should_have_proper_availability_zone_set():
conn = boto.vpc.connect_to_region('us-west-1')
vpcA = conn.create_vpc("10.0.0.0/16")
@ -87,7 +87,7 @@ def test_default_subnet():
subnet.map_public_ip_on_launch.shouldnt.be.ok
@mock_ec2
@mock_ec2_deprecated
def test_non_default_subnet():
vpc_cli = boto.vpc.connect_to_region('us-west-1')
@ -150,7 +150,7 @@ def test_modify_subnet_attribute_validation():
client.modify_subnet_attribute(SubnetId=subnet.id, MapPublicIpOnLaunch={'Value': 'invalid'})
@mock_ec2
@mock_ec2_deprecated
def test_get_subnets_filtering():
ec2 = boto.ec2.connect_to_region('us-west-1')
conn = boto.vpc.connect_to_region('us-west-1')
@ -205,8 +205,8 @@ def test_get_subnets_filtering():
conn.get_all_subnets.when.called_with(filters={'not-implemented-filter': 'foobar'}).should.throw(NotImplementedError)
@mock_ec2
@mock_cloudformation
@mock_ec2_deprecated
@mock_cloudformation_deprecated
def test_subnet_tags_through_cloudformation():
vpc_conn = boto.vpc.connect_to_region('us-west-1')
vpc = vpc_conn.create_vpc("10.0.0.0/16")

View file

@ -8,11 +8,11 @@ from boto.exception import EC2ResponseError, JSONResponseError
from boto.ec2.instance import Reservation
import sure # noqa
from moto import mock_ec2
from moto import mock_ec2_deprecated
from nose.tools import assert_raises
@mock_ec2
@mock_ec2_deprecated
def test_add_tag():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -32,7 +32,7 @@ def test_add_tag():
existing_instance.tags["a key"].should.equal("some value")
@mock_ec2
@mock_ec2_deprecated
def test_remove_tag():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -59,7 +59,7 @@ def test_remove_tag():
instance.remove_tag("a key", "some value")
@mock_ec2
@mock_ec2_deprecated
def test_get_all_tags():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -73,7 +73,7 @@ def test_get_all_tags():
tag.value.should.equal("some value")
@mock_ec2
@mock_ec2_deprecated
def test_get_all_tags_with_special_characters():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -87,7 +87,7 @@ def test_get_all_tags_with_special_characters():
tag.value.should.equal("some<> value")
@mock_ec2
@mock_ec2_deprecated
def test_create_tags():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -108,7 +108,7 @@ def test_create_tags():
set([tag_dict[key] for key in tag_dict]).should.equal(set([tag.value for tag in tags]))
@mock_ec2
@mock_ec2_deprecated
def test_tag_limit_exceeded():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -137,7 +137,7 @@ def test_tag_limit_exceeded():
tag.value.should.equal("a value")
@mock_ec2
@mock_ec2_deprecated
def test_invalid_parameter_tag_null():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -150,7 +150,7 @@ def test_invalid_parameter_tag_null():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_invalid_id():
conn = boto.connect_ec2('the_key', 'the_secret')
with assert_raises(EC2ResponseError) as cm:
@ -166,7 +166,7 @@ def test_invalid_id():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_get_all_tags_resource_id_filter():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -193,7 +193,7 @@ def test_get_all_tags_resource_id_filter():
tag.value.should.equal("some value")
@mock_ec2
@mock_ec2_deprecated
def test_get_all_tags_resource_type_filter():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -220,7 +220,7 @@ def test_get_all_tags_resource_type_filter():
tag.value.should.equal("some value")
@mock_ec2
@mock_ec2_deprecated
def test_get_all_tags_key_filter():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -239,7 +239,7 @@ def test_get_all_tags_key_filter():
tag.value.should.equal("some value")
@mock_ec2
@mock_ec2_deprecated
def test_get_all_tags_value_filter():
conn = boto.connect_ec2('the_key', 'the_secret')
reservation = conn.run_instances('ami-1234abcd')
@ -283,7 +283,7 @@ def test_get_all_tags_value_filter():
tags.should.have.length_of(1)
@mock_ec2
@mock_ec2_deprecated
def test_retrieved_instances_must_contain_their_tags():
tag_key = 'Tag name'
tag_value = 'Tag value'
@ -314,7 +314,7 @@ def test_retrieved_instances_must_contain_their_tags():
retrieved_tags[tag_key].should.equal(tag_value)
@mock_ec2
@mock_ec2_deprecated
def test_retrieved_volumes_must_contain_their_tags():
tag_key = 'Tag name'
tag_value = 'Tag value'
@ -337,7 +337,7 @@ def test_retrieved_volumes_must_contain_their_tags():
retrieved_tags[tag_key].should.equal(tag_value)
@mock_ec2
@mock_ec2_deprecated
def test_retrieved_snapshots_must_contain_their_tags():
tag_key = 'Tag name'
tag_value = 'Tag value'
@ -359,7 +359,7 @@ def test_retrieved_snapshots_must_contain_their_tags():
retrieved_tags[tag_key].should.equal(tag_value)
@mock_ec2
@mock_ec2_deprecated
def test_filter_instances_by_wildcard_tags():
conn = boto.connect_ec2(aws_access_key_id='the_key', aws_secret_access_key='the_secret')
reservation = conn.run_instances('ami-1234abcd')

View file

@ -2,10 +2,10 @@ from __future__ import unicode_literals
import boto
import sure # noqa
from moto import mock_ec2
from moto import mock_ec2_deprecated
@mock_ec2
@mock_ec2_deprecated
def test_virtual_private_gateways():
conn = boto.connect_vpc('the_key', 'the_secret')
@ -16,7 +16,7 @@ def test_virtual_private_gateways():
vpn_gateway.state.should.equal('available')
vpn_gateway.availability_zone.should.equal('us-east-1a')
@mock_ec2
@mock_ec2_deprecated
def test_describe_vpn_gateway():
conn = boto.connect_vpc('the_key', 'the_secret')
vpn_gateway = conn.create_vpn_gateway('ipsec.1', 'us-east-1a')
@ -32,7 +32,7 @@ def test_describe_vpn_gateway():
vpn_gateway.availability_zone.should.equal('us-east-1a')
@mock_ec2
@mock_ec2_deprecated
def test_vpn_gateway_vpc_attachment():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -50,7 +50,7 @@ def test_vpn_gateway_vpc_attachment():
attachments[0].state.should.equal('attached')
@mock_ec2
@mock_ec2_deprecated
def test_delete_vpn_gateway():
conn = boto.connect_vpc('the_key', 'the_secret')
vpn_gateway = conn.create_vpn_gateway('ipsec.1', 'us-east-1a')
@ -60,7 +60,7 @@ def test_delete_vpn_gateway():
vgws.should.have.length_of(0)
@mock_ec2
@mock_ec2_deprecated
def test_vpn_gateway_tagging():
conn = boto.connect_vpc('the_key', 'the_secret')
vpn_gateway = conn.create_vpn_gateway('ipsec.1', 'us-east-1a')
@ -76,7 +76,7 @@ def test_vpn_gateway_tagging():
vpn_gateway.tags["a key"].should.equal("some value")
@mock_ec2
@mock_ec2_deprecated
def test_detach_vpn_gateway():
conn = boto.connect_vpc('the_key', 'the_secret')

View file

@ -7,12 +7,12 @@ import boto
from boto.exception import EC2ResponseError
import sure # noqa
from moto import mock_ec2
from moto import mock_ec2_deprecated
from tests.helpers import requires_boto_gte
@requires_boto_gte("2.32.0")
@mock_ec2
@mock_ec2_deprecated
def test_vpc_peering_connections():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -25,7 +25,7 @@ def test_vpc_peering_connections():
@requires_boto_gte("2.32.0")
@mock_ec2
@mock_ec2_deprecated
def test_vpc_peering_connections_get_all():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc_pcx = test_vpc_peering_connections()
@ -37,7 +37,7 @@ def test_vpc_peering_connections_get_all():
@requires_boto_gte("2.32.0")
@mock_ec2
@mock_ec2_deprecated
def test_vpc_peering_connections_accept():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc_pcx = test_vpc_peering_connections()
@ -57,7 +57,7 @@ def test_vpc_peering_connections_accept():
@requires_boto_gte("2.32.0")
@mock_ec2
@mock_ec2_deprecated
def test_vpc_peering_connections_reject():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc_pcx = test_vpc_peering_connections()
@ -77,7 +77,7 @@ def test_vpc_peering_connections_reject():
@requires_boto_gte("2.32.1")
@mock_ec2
@mock_ec2_deprecated
def test_vpc_peering_connections_delete():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc_pcx = test_vpc_peering_connections()

View file

@ -8,13 +8,13 @@ import boto
from boto.exception import EC2ResponseError
import sure # noqa
from moto import mock_ec2
from moto import mock_ec2, mock_ec2_deprecated
SAMPLE_DOMAIN_NAME = u'example.com'
SAMPLE_NAME_SERVERS = [u'10.0.0.6', u'10.0.0.7']
@mock_ec2
@mock_ec2_deprecated
def test_vpcs():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -35,7 +35,7 @@ def test_vpcs():
cm.exception.request_id.should_not.be.none
@mock_ec2
@mock_ec2_deprecated
def test_vpc_defaults():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -50,7 +50,7 @@ def test_vpc_defaults():
conn.get_all_route_tables().should.have.length_of(1)
conn.get_all_security_groups(filters={'vpc-id': [vpc.id]}).should.have.length_of(0)
@mock_ec2
@mock_ec2_deprecated
def test_vpc_isdefault_filter():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -59,7 +59,7 @@ def test_vpc_isdefault_filter():
conn.get_all_vpcs(filters={'isDefault': 'true'}).should.have.length_of(1)
@mock_ec2
@mock_ec2_deprecated
def test_multiple_vpcs_default_filter():
conn = boto.connect_vpc('the_key', 'the_secret')
conn.create_vpc("10.8.0.0/16")
@ -71,7 +71,7 @@ def test_multiple_vpcs_default_filter():
vpc[0].cidr_block.should.equal('172.31.0.0/16')
@mock_ec2
@mock_ec2_deprecated
def test_vpc_state_available_filter():
conn = boto.connect_vpc('the_key', 'the_secret')
vpc = conn.create_vpc("10.0.0.0/16")
@ -80,7 +80,7 @@ def test_vpc_state_available_filter():
vpc.delete()
conn.get_all_vpcs(filters={'state': 'available'}).should.have.length_of(2)
@mock_ec2
@mock_ec2_deprecated
def test_vpc_tagging():
conn = boto.connect_vpc()
vpc = conn.create_vpc("10.0.0.0/16")
@ -96,7 +96,7 @@ def test_vpc_tagging():
vpc.tags["a key"].should.equal("some value")
@mock_ec2
@mock_ec2_deprecated
def test_vpc_get_by_id():
conn = boto.connect_vpc()
vpc1 = conn.create_vpc("10.0.0.0/16")
@ -110,7 +110,7 @@ def test_vpc_get_by_id():
vpc2.id.should.be.within(vpc_ids)
@mock_ec2
@mock_ec2_deprecated
def test_vpc_get_by_cidr_block():
conn = boto.connect_vpc()
vpc1 = conn.create_vpc("10.0.0.0/16")
@ -124,7 +124,7 @@ def test_vpc_get_by_cidr_block():
vpc2.id.should.be.within(vpc_ids)
@mock_ec2
@mock_ec2_deprecated
def test_vpc_get_by_dhcp_options_id():
conn = boto.connect_vpc()
dhcp_options = conn.create_dhcp_options(SAMPLE_DOMAIN_NAME, SAMPLE_NAME_SERVERS)
@ -142,7 +142,7 @@ def test_vpc_get_by_dhcp_options_id():
vpc2.id.should.be.within(vpc_ids)
@mock_ec2
@mock_ec2_deprecated
def test_vpc_get_by_tag():
conn = boto.connect_vpc()
vpc1 = conn.create_vpc("10.0.0.0/16")
@ -160,7 +160,7 @@ def test_vpc_get_by_tag():
vpc2.id.should.be.within(vpc_ids)
@mock_ec2
@mock_ec2_deprecated
def test_vpc_get_by_tag_key_superset():
conn = boto.connect_vpc()
vpc1 = conn.create_vpc("10.0.0.0/16")
@ -180,7 +180,7 @@ def test_vpc_get_by_tag_key_superset():
vpc2.id.should.be.within(vpc_ids)
@mock_ec2
@mock_ec2_deprecated
def test_vpc_get_by_tag_key_subset():
conn = boto.connect_vpc()
vpc1 = conn.create_vpc("10.0.0.0/16")
@ -200,7 +200,7 @@ def test_vpc_get_by_tag_key_subset():
vpc2.id.should.be.within(vpc_ids)
@mock_ec2
@mock_ec2_deprecated
def test_vpc_get_by_tag_value_superset():
conn = boto.connect_vpc()
vpc1 = conn.create_vpc("10.0.0.0/16")
@ -220,7 +220,7 @@ def test_vpc_get_by_tag_value_superset():
vpc2.id.should.be.within(vpc_ids)
@mock_ec2
@mock_ec2_deprecated
def test_vpc_get_by_tag_value_subset():
conn = boto.connect_vpc()
vpc1 = conn.create_vpc("10.0.0.0/16")
@ -339,7 +339,7 @@ def test_vpc_modify_enable_dns_hostnames():
attr = response.get('EnableDnsHostnames')
attr.get('Value').should.be.ok
@mock_ec2
@mock_ec2_deprecated
def test_vpc_associate_dhcp_options():
conn = boto.connect_vpc()
dhcp_options = conn.create_dhcp_options(SAMPLE_DOMAIN_NAME, SAMPLE_NAME_SERVERS)

View file

@ -4,10 +4,10 @@ from nose.tools import assert_raises
import sure # noqa
from boto.exception import EC2ResponseError
from moto import mock_ec2
from moto import mock_ec2_deprecated
@mock_ec2
@mock_ec2_deprecated
def test_create_vpn_connections():
conn = boto.connect_vpc('the_key', 'the_secret')
vpn_connection = conn.create_vpn_connection('ipsec.1', 'vgw-0123abcd', 'cgw-0123abcd')
@ -15,7 +15,7 @@ def test_create_vpn_connections():
vpn_connection.id.should.match(r'vpn-\w+')
vpn_connection.type.should.equal('ipsec.1')
@mock_ec2
@mock_ec2_deprecated
def test_delete_vpn_connections():
conn = boto.connect_vpc('the_key', 'the_secret')
vpn_connection = conn.create_vpn_connection('ipsec.1', 'vgw-0123abcd', 'cgw-0123abcd')
@ -25,13 +25,13 @@ def test_delete_vpn_connections():
list_of_vpn_connections = conn.get_all_vpn_connections()
list_of_vpn_connections.should.have.length_of(0)
@mock_ec2
@mock_ec2_deprecated
def test_delete_vpn_connections_bad_id():
conn = boto.connect_vpc('the_key', 'the_secret')
with assert_raises(EC2ResponseError):
conn.delete_vpn_connection('vpn-0123abcd')
@mock_ec2
@mock_ec2_deprecated
def test_describe_vpn_connections():
conn = boto.connect_vpc('the_key', 'the_secret')
list_of_vpn_connections = conn.get_all_vpn_connections()

View file

@ -18,9 +18,9 @@ from boto.ec2.elb.policies import (
from boto.exception import BotoServerError
import sure # noqa
from moto import mock_elb, mock_ec2
from moto import mock_elb, mock_ec2, mock_elb_deprecated, mock_ec2_deprecated
@mock_elb
@mock_elb_deprecated
def test_create_load_balancer():
conn = boto.connect_elb()
@ -43,13 +43,13 @@ def test_create_load_balancer():
listener2.protocol.should.equal("TCP")
@mock_elb
@mock_elb_deprecated
def test_getting_missing_elb():
conn = boto.connect_elb()
conn.get_all_load_balancers.when.called_with(load_balancer_names='aaa').should.throw(BotoServerError)
@mock_elb
@mock_elb_deprecated
def test_create_elb_in_multiple_region():
zones = ['us-east-1a', 'us-east-1b']
ports = [(80, 8080, 'http'), (443, 8443, 'tcp')]
@ -63,7 +63,7 @@ def test_create_elb_in_multiple_region():
list(west1_conn.get_all_load_balancers()).should.have.length_of(1)
list(west2_conn.get_all_load_balancers()).should.have.length_of(1)
@mock_elb
@mock_elb_deprecated
def test_create_load_balancer_with_certificate():
conn = boto.connect_elb()
@ -99,7 +99,7 @@ def test_create_and_delete_boto3_support():
)
list(client.describe_load_balancers()['LoadBalancerDescriptions']).should.have.length_of(0)
@mock_elb
@mock_elb_deprecated
def test_add_listener():
conn = boto.connect_elb()
zones = ['us-east-1a', 'us-east-1b']
@ -119,7 +119,7 @@ def test_add_listener():
listener2.protocol.should.equal("TCP")
@mock_elb
@mock_elb_deprecated
def test_delete_listener():
conn = boto.connect_elb()
@ -161,7 +161,7 @@ def test_create_and_delete_listener_boto3_support():
balancer['ListenerDescriptions'][1]['Listener']['InstancePort'].should.equal(8443)
@mock_elb
@mock_elb_deprecated
def test_set_sslcertificate():
conn = boto.connect_elb()
@ -178,7 +178,7 @@ def test_set_sslcertificate():
listener1.ssl_certificate_id.should.equal("arn:certificate")
@mock_elb
@mock_elb_deprecated
def test_get_load_balancers_by_name():
conn = boto.connect_elb()
@ -193,7 +193,7 @@ def test_get_load_balancers_by_name():
conn.get_all_load_balancers(load_balancer_names=['my-lb1', 'my-lb2']).should.have.length_of(2)
@mock_elb
@mock_elb_deprecated
def test_delete_load_balancer():
conn = boto.connect_elb()
@ -209,7 +209,7 @@ def test_delete_load_balancer():
balancers.should.have.length_of(0)
@mock_elb
@mock_elb_deprecated
def test_create_health_check():
conn = boto.connect_elb()
@ -262,8 +262,8 @@ def test_create_health_check_boto3():
balancer['HealthCheck']['UnhealthyThreshold'].should.equal(5)
@mock_ec2
@mock_elb
@mock_ec2_deprecated
@mock_elb_deprecated
def test_register_instances():
ec2_conn = boto.connect_ec2()
reservation = ec2_conn.run_instances('ami-1234abcd', 2)
@ -307,8 +307,8 @@ def test_register_instances_boto3():
set(instance_ids).should.equal(set([instance_id1, instance_id2]))
@mock_ec2
@mock_elb
@mock_ec2_deprecated
@mock_elb_deprecated
def test_deregister_instances():
ec2_conn = boto.connect_ec2()
reservation = ec2_conn.run_instances('ami-1234abcd', 2)
@ -365,7 +365,7 @@ def test_deregister_instances_boto3():
balancer['Instances'][0]['InstanceId'].should.equal(instance_id2)
@mock_elb
@mock_elb_deprecated
def test_default_attributes():
conn = boto.connect_elb()
ports = [(80, 8080, 'http'), (443, 8443, 'tcp')]
@ -378,7 +378,7 @@ def test_default_attributes():
attributes.connecting_settings.idle_timeout.should.equal(60)
@mock_elb
@mock_elb_deprecated
def test_cross_zone_load_balancing_attribute():
conn = boto.connect_elb()
ports = [(80, 8080, 'http'), (443, 8443, 'tcp')]
@ -393,7 +393,7 @@ def test_cross_zone_load_balancing_attribute():
attributes.cross_zone_load_balancing.enabled.should.be.false
@mock_elb
@mock_elb_deprecated
def test_connection_draining_attribute():
conn = boto.connect_elb()
ports = [(80, 8080, 'http'), (443, 8443, 'tcp')]
@ -419,7 +419,7 @@ def test_connection_draining_attribute():
attributes.connection_draining.enabled.should.be.false
@mock_elb
@mock_elb_deprecated
def test_access_log_attribute():
conn = boto.connect_elb()
ports = [(80, 8080, 'http'), (443, 8443, 'tcp')]
@ -444,7 +444,7 @@ def test_access_log_attribute():
attributes.access_log.enabled.should.be.false
@mock_elb
@mock_elb_deprecated
def test_connection_settings_attribute():
conn = boto.connect_elb()
ports = [(80, 8080, 'http'), (443, 8443, 'tcp')]
@ -462,7 +462,7 @@ def test_connection_settings_attribute():
attributes = lb.get_attributes(force=True)
attributes.connecting_settings.idle_timeout.should.equal(60)
@mock_elb
@mock_elb_deprecated
def test_create_lb_cookie_stickiness_policy():
conn = boto.connect_elb()
ports = [(80, 8080, 'http'), (443, 8443, 'tcp')]
@ -482,7 +482,7 @@ def test_create_lb_cookie_stickiness_policy():
int(cookie_expiration_period_response_str).should.equal(cookie_expiration_period)
lb.policies.lb_cookie_stickiness_policies[0].policy_name.should.equal(policy_name)
@mock_elb
@mock_elb_deprecated
def test_create_lb_cookie_stickiness_policy_no_expiry():
conn = boto.connect_elb()
ports = [(80, 8080, 'http'), (443, 8443, 'tcp')]
@ -495,7 +495,7 @@ def test_create_lb_cookie_stickiness_policy_no_expiry():
lb.policies.lb_cookie_stickiness_policies[0].cookie_expiration_period.should.be.none
lb.policies.lb_cookie_stickiness_policies[0].policy_name.should.equal(policy_name)
@mock_elb
@mock_elb_deprecated
def test_create_app_cookie_stickiness_policy():
conn = boto.connect_elb()
ports = [(80, 8080, 'http'), (443, 8443, 'tcp')]
@ -509,7 +509,7 @@ def test_create_app_cookie_stickiness_policy():
lb.policies.app_cookie_stickiness_policies[0].cookie_name.should.equal(cookie_name)
lb.policies.app_cookie_stickiness_policies[0].policy_name.should.equal(policy_name)
@mock_elb
@mock_elb_deprecated
def test_create_lb_policy():
conn = boto.connect_elb()
ports = [(80, 8080, 'http'), (443, 8443, 'tcp')]
@ -521,7 +521,7 @@ def test_create_lb_policy():
lb = conn.get_all_load_balancers()[0]
lb.policies.other_policies[0].policy_name.should.equal(policy_name)
@mock_elb
@mock_elb_deprecated
def test_set_policies_of_listener():
conn = boto.connect_elb()
ports = [(80, 8080, 'http'), (443, 8443, 'tcp')]
@ -543,7 +543,7 @@ def test_set_policies_of_listener():
# by contrast to a backend, a listener stores only policy name strings
listener.policy_names[0].should.equal(policy_name)
@mock_elb
@mock_elb_deprecated
def test_set_policies_of_backend_server():
conn = boto.connect_elb()
ports = [(80, 8080, 'http'), (443, 8443, 'tcp')]
@ -562,8 +562,8 @@ def test_set_policies_of_backend_server():
# by contrast to a listener, a backend stores OtherPolicy objects
backend.policies[0].policy_name.should.equal(policy_name)
@mock_ec2
@mock_elb
@mock_ec2_deprecated
@mock_elb_deprecated
def test_describe_instance_health():
ec2_conn = boto.connect_ec2()
reservation = ec2_conn.run_instances('ami-1234abcd', 2)
@ -765,7 +765,7 @@ def test_subnets():
lb.should.have.key('VPCId').which.should.equal(vpc.id)
@mock_elb
@mock_elb_deprecated
def test_create_load_balancer_duplicate():
conn = boto.connect_elb()
ports = [(80, 8080, 'http'), (443, 8443, 'tcp')]

View file

@ -11,7 +11,7 @@ from boto.emr.step import StreamingStep
import six
import sure # noqa
from moto import mock_emr
from moto import mock_emr_deprecated
from tests.helpers import requires_boto_gte
@ -35,7 +35,7 @@ input_instance_groups = [
]
@mock_emr
@mock_emr_deprecated
def test_describe_cluster():
conn = boto.connect_emr()
args = run_jobflow_args.copy()
@ -106,7 +106,7 @@ def test_describe_cluster():
cluster.visibletoallusers.should.equal('true')
@mock_emr
@mock_emr_deprecated
def test_describe_jobflows():
conn = boto.connect_emr()
args = run_jobflow_args.copy()
@ -158,7 +158,7 @@ def test_describe_jobflows():
resp.should.have.length_of(200)
@mock_emr
@mock_emr_deprecated
def test_describe_jobflow():
conn = boto.connect_emr()
args = run_jobflow_args.copy()
@ -241,7 +241,7 @@ def test_describe_jobflow():
jf.visibletoallusers.should.equal('true')
@mock_emr
@mock_emr_deprecated
def test_list_clusters():
conn = boto.connect_emr()
args = run_jobflow_args.copy()
@ -309,7 +309,7 @@ def test_list_clusters():
resp.clusters.should.have.length_of(30)
@mock_emr
@mock_emr_deprecated
def test_run_jobflow():
conn = boto.connect_emr()
args = run_jobflow_args.copy()
@ -326,7 +326,7 @@ def test_run_jobflow():
job_flow.steps.should.have.length_of(0)
@mock_emr
@mock_emr_deprecated
def test_run_jobflow_in_multiple_regions():
regions = {}
for region in ['us-east-1', 'eu-west-1']:
@ -343,7 +343,7 @@ def test_run_jobflow_in_multiple_regions():
@requires_boto_gte("2.8")
@mock_emr
@mock_emr_deprecated
def test_run_jobflow_with_new_params():
# Test that run_jobflow works with newer params
conn = boto.connect_emr()
@ -351,7 +351,7 @@ def test_run_jobflow_with_new_params():
@requires_boto_gte("2.8")
@mock_emr
@mock_emr_deprecated
def test_run_jobflow_with_visible_to_all_users():
conn = boto.connect_emr()
for expected in (True, False):
@ -364,7 +364,7 @@ def test_run_jobflow_with_visible_to_all_users():
@requires_boto_gte("2.8")
@mock_emr
@mock_emr_deprecated
def test_run_jobflow_with_instance_groups():
input_groups = dict((g.name, g) for g in input_instance_groups)
conn = boto.connect_emr()
@ -384,7 +384,7 @@ def test_run_jobflow_with_instance_groups():
@requires_boto_gte("2.8")
@mock_emr
@mock_emr_deprecated
def test_set_termination_protection():
conn = boto.connect_emr()
job_id = conn.run_jobflow(**run_jobflow_args)
@ -401,7 +401,7 @@ def test_set_termination_protection():
@requires_boto_gte("2.8")
@mock_emr
@mock_emr_deprecated
def test_set_visible_to_all_users():
conn = boto.connect_emr()
args = run_jobflow_args.copy()
@ -419,7 +419,7 @@ def test_set_visible_to_all_users():
job_flow.visibletoallusers.should.equal('false')
@mock_emr
@mock_emr_deprecated
def test_terminate_jobflow():
conn = boto.connect_emr()
job_id = conn.run_jobflow(**run_jobflow_args)
@ -433,7 +433,7 @@ def test_terminate_jobflow():
# testing multiple end points for each feature
@mock_emr
@mock_emr_deprecated
def test_bootstrap_actions():
bootstrap_actions = [
BootstrapAction(
@ -466,7 +466,7 @@ def test_bootstrap_actions():
list(arg.value for arg in x.args).should.equal(y.args())
@mock_emr
@mock_emr_deprecated
def test_instance_groups():
input_groups = dict((g.name, g) for g in input_instance_groups)
@ -536,7 +536,7 @@ def test_instance_groups():
int(igs['task-2'].instancerunningcount).should.equal(3)
@mock_emr
@mock_emr_deprecated
def test_steps():
input_steps = [
StreamingStep(
@ -633,7 +633,7 @@ def test_steps():
test_list_steps_with_states()
@mock_emr
@mock_emr_deprecated
def test_tags():
input_tags = {"tag1": "val1", "tag2": "val2"}

View file

@ -4,10 +4,10 @@ from tempfile import NamedTemporaryFile
import boto.glacier
import sure # noqa
from moto import mock_glacier
from moto import mock_glacier_deprecated
@mock_glacier
@mock_glacier_deprecated
def test_create_and_delete_archive():
the_file = NamedTemporaryFile(delete=False)
the_file.write(b"some stuff")

View file

@ -5,10 +5,10 @@ import json
from boto.glacier.layer1 import Layer1
import sure # noqa
from moto import mock_glacier
from moto import mock_glacier_deprecated
@mock_glacier
@mock_glacier_deprecated
def test_init_glacier_job():
conn = Layer1(region_name="us-west-2")
vault_name = "my_vault"
@ -23,7 +23,7 @@ def test_init_glacier_job():
job_response['Location'].should.equal("//vaults/my_vault/jobs/{0}".format(job_id))
@mock_glacier
@mock_glacier_deprecated
def test_describe_job():
conn = Layer1(region_name="us-west-2")
vault_name = "my_vault"
@ -56,7 +56,7 @@ def test_describe_job():
})
@mock_glacier
@mock_glacier_deprecated
def test_list_glacier_jobs():
conn = Layer1(region_name="us-west-2")
vault_name = "my_vault"
@ -77,7 +77,7 @@ def test_list_glacier_jobs():
len(jobs['JobList']).should.equal(2)
@mock_glacier
@mock_glacier_deprecated
def test_get_job_output():
conn = Layer1(region_name="us-west-2")
vault_name = "my_vault"

View file

@ -3,10 +3,10 @@ from __future__ import unicode_literals
import boto.glacier
import sure # noqa
from moto import mock_glacier
from moto import mock_glacier_deprecated
@mock_glacier
@mock_glacier_deprecated
def test_create_vault():
conn = boto.glacier.connect_to_region("us-west-2")
@ -17,7 +17,7 @@ def test_create_vault():
vaults[0].name.should.equal("my_vault")
@mock_glacier
@mock_glacier_deprecated
def test_delete_vault():
conn = boto.glacier.connect_to_region("us-west-2")

View file

@ -6,7 +6,7 @@ import boto3
import sure # noqa
from boto.exception import BotoServerError
from botocore.exceptions import ClientError
from moto import mock_iam
from moto import mock_iam, mock_iam_deprecated
from moto.iam.models import aws_managed_policies
from nose.tools import assert_raises, assert_equals, assert_not_equals
from nose.tools import raises
@ -14,7 +14,7 @@ from nose.tools import raises
from tests.helpers import requires_boto_gte
@mock_iam()
@mock_iam_deprecated()
def test_get_all_server_certs():
conn = boto.connect_iam()
@ -26,7 +26,7 @@ def test_get_all_server_certs():
cert1.arn.should.equal("arn:aws:iam::123456789012:server-certificate/certname")
@mock_iam()
@mock_iam_deprecated()
def test_get_server_cert_doesnt_exist():
conn = boto.connect_iam()
@ -34,7 +34,7 @@ def test_get_server_cert_doesnt_exist():
conn.get_server_certificate("NonExistant")
@mock_iam()
@mock_iam_deprecated()
def test_get_server_cert():
conn = boto.connect_iam()
@ -44,7 +44,7 @@ def test_get_server_cert():
cert.arn.should.equal("arn:aws:iam::123456789012:server-certificate/certname")
@mock_iam()
@mock_iam_deprecated()
def test_upload_server_cert():
conn = boto.connect_iam()
@ -54,7 +54,7 @@ def test_upload_server_cert():
cert.arn.should.equal("arn:aws:iam::123456789012:server-certificate/certname")
@mock_iam()
@mock_iam_deprecated()
@raises(BotoServerError)
def test_get_role__should_throw__when_role_does_not_exist():
conn = boto.connect_iam()
@ -62,7 +62,7 @@ def test_get_role__should_throw__when_role_does_not_exist():
conn.get_role('unexisting_role')
@mock_iam()
@mock_iam_deprecated()
@raises(BotoServerError)
def test_get_instance_profile__should_throw__when_instance_profile_does_not_exist():
conn = boto.connect_iam()
@ -70,7 +70,7 @@ def test_get_instance_profile__should_throw__when_instance_profile_does_not_exis
conn.get_instance_profile('unexisting_instance_profile')
@mock_iam()
@mock_iam_deprecated()
def test_create_role_and_instance_profile():
conn = boto.connect_iam()
conn.create_instance_profile("my-profile", path="my-path")
@ -91,7 +91,7 @@ def test_create_role_and_instance_profile():
conn.list_roles().roles[0].role_name.should.equal('my-role')
@mock_iam()
@mock_iam_deprecated()
def test_remove_role_from_instance_profile():
conn = boto.connect_iam()
conn.create_instance_profile("my-profile", path="my-path")
@ -108,7 +108,7 @@ def test_remove_role_from_instance_profile():
dict(profile.roles).should.be.empty
@mock_iam()
@mock_iam_deprecated()
def test_list_instance_profiles():
conn = boto.connect_iam()
conn.create_instance_profile("my-profile", path="my-path")
@ -123,7 +123,7 @@ def test_list_instance_profiles():
profiles[0].roles.role_name.should.equal("my-role")
@mock_iam()
@mock_iam_deprecated()
def test_list_instance_profiles_for_role():
conn = boto.connect_iam()
@ -153,7 +153,7 @@ def test_list_instance_profiles_for_role():
len(profile_list).should.equal(0)
@mock_iam()
@mock_iam_deprecated()
def test_list_role_policies():
conn = boto.connect_iam()
conn.create_role("my-role")
@ -162,7 +162,7 @@ def test_list_role_policies():
role.policy_names[0].should.equal("test policy")
@mock_iam()
@mock_iam_deprecated()
def test_put_role_policy():
conn = boto.connect_iam()
conn.create_role("my-role", assume_role_policy_document="some policy", path="my-path")
@ -171,7 +171,7 @@ def test_put_role_policy():
policy.should.equal("test policy")
@mock_iam()
@mock_iam_deprecated()
def test_update_assume_role_policy():
conn = boto.connect_iam()
role = conn.create_role("my-role")
@ -180,7 +180,7 @@ def test_update_assume_role_policy():
role.assume_role_policy_document.should.equal("my-policy")
@mock_iam()
@mock_iam_deprecated()
def test_create_user():
conn = boto.connect_iam()
conn.create_user('my-user')
@ -188,7 +188,7 @@ def test_create_user():
conn.create_user('my-user')
@mock_iam()
@mock_iam_deprecated()
def test_get_user():
conn = boto.connect_iam()
with assert_raises(BotoServerError):
@ -210,7 +210,7 @@ def test_list_users():
user['Arn'].should.equal('arn:aws:iam::123456789012:user/my-user')
@mock_iam()
@mock_iam_deprecated()
def test_create_login_profile():
conn = boto.connect_iam()
with assert_raises(BotoServerError):
@ -221,7 +221,7 @@ def test_create_login_profile():
conn.create_login_profile('my-user', 'my-pass')
@mock_iam()
@mock_iam_deprecated()
def test_delete_login_profile():
conn = boto.connect_iam()
conn.create_user('my-user')
@ -231,7 +231,7 @@ def test_delete_login_profile():
conn.delete_login_profile('my-user')
@mock_iam()
@mock_iam_deprecated()
def test_create_access_key():
conn = boto.connect_iam()
with assert_raises(BotoServerError):
@ -240,7 +240,7 @@ def test_create_access_key():
conn.create_access_key('my-user')
@mock_iam()
@mock_iam_deprecated()
def test_get_all_access_keys():
conn = boto.connect_iam()
conn.create_user('my-user')
@ -257,7 +257,7 @@ def test_get_all_access_keys():
)
@mock_iam()
@mock_iam_deprecated()
def test_delete_access_key():
conn = boto.connect_iam()
conn.create_user('my-user')
@ -265,7 +265,7 @@ def test_delete_access_key():
conn.delete_access_key(access_key_id, 'my-user')
@mock_iam()
@mock_iam_deprecated()
def test_delete_user():
conn = boto.connect_iam()
with assert_raises(BotoServerError):
@ -274,7 +274,7 @@ def test_delete_user():
conn.delete_user('my-user')
@mock_iam()
@mock_iam_deprecated()
def test_generate_credential_report():
conn = boto.connect_iam()
result = conn.generate_credential_report()
@ -283,7 +283,7 @@ def test_generate_credential_report():
result['generate_credential_report_response']['generate_credential_report_result']['state'].should.equal('COMPLETE')
@mock_iam()
@mock_iam_deprecated()
def test_get_credential_report():
conn = boto.connect_iam()
conn.create_user('my-user')
@ -298,7 +298,7 @@ def test_get_credential_report():
@requires_boto_gte('2.39')
@mock_iam()
@mock_iam_deprecated()
def test_managed_policy():
conn = boto.connect_iam()

View file

@ -4,10 +4,10 @@ import sure # noqa
from nose.tools import assert_raises
from boto.exception import BotoServerError
from moto import mock_iam
from moto import mock_iam, mock_iam_deprecated
@mock_iam()
@mock_iam_deprecated()
def test_create_group():
conn = boto.connect_iam()
conn.create_group('my-group')
@ -15,7 +15,7 @@ def test_create_group():
conn.create_group('my-group')
@mock_iam()
@mock_iam_deprecated()
def test_get_group():
conn = boto.connect_iam()
conn.create_group('my-group')
@ -24,7 +24,7 @@ def test_get_group():
conn.get_group('not-group')
@mock_iam()
@mock_iam_deprecated()
def test_get_all_groups():
conn = boto.connect_iam()
conn.create_group('my-group1')
@ -33,7 +33,7 @@ def test_get_all_groups():
groups.should.have.length_of(2)
@mock_iam()
@mock_iam_deprecated()
def test_add_user_to_group():
conn = boto.connect_iam()
with assert_raises(BotoServerError):
@ -45,7 +45,7 @@ def test_add_user_to_group():
conn.add_user_to_group('my-group', 'my-user')
@mock_iam()
@mock_iam_deprecated()
def test_remove_user_from_group():
conn = boto.connect_iam()
with assert_raises(BotoServerError):
@ -58,7 +58,7 @@ def test_remove_user_from_group():
conn.remove_user_from_group('my-group', 'my-user')
@mock_iam()
@mock_iam_deprecated()
def test_get_groups_for_user():
conn = boto.connect_iam()
conn.create_group('my-group1')

View file

@ -4,10 +4,10 @@ import boto.kinesis
from boto.kinesis.exceptions import ResourceNotFoundException, InvalidArgumentException
import sure # noqa
from moto import mock_kinesis
from moto import mock_kinesis_deprecated
@mock_kinesis
@mock_kinesis_deprecated
def test_create_cluster():
conn = boto.kinesis.connect_to_region("us-west-2")
@ -25,13 +25,13 @@ def test_create_cluster():
shards.should.have.length_of(2)
@mock_kinesis
@mock_kinesis_deprecated
def test_describe_non_existant_stream():
conn = boto.kinesis.connect_to_region("us-east-1")
conn.describe_stream.when.called_with("not-a-stream").should.throw(ResourceNotFoundException)
@mock_kinesis
@mock_kinesis_deprecated
def test_list_and_delete_stream():
conn = boto.kinesis.connect_to_region("us-west-2")
@ -48,7 +48,7 @@ def test_list_and_delete_stream():
conn.delete_stream.when.called_with("not-a-stream").should.throw(ResourceNotFoundException)
@mock_kinesis
@mock_kinesis_deprecated
def test_basic_shard_iterator():
conn = boto.kinesis.connect_to_region("us-west-2")
@ -66,7 +66,7 @@ def test_basic_shard_iterator():
response['Records'].should.equal([])
@mock_kinesis
@mock_kinesis_deprecated
def test_get_invalid_shard_iterator():
conn = boto.kinesis.connect_to_region("us-west-2")
@ -76,7 +76,7 @@ def test_get_invalid_shard_iterator():
conn.get_shard_iterator.when.called_with(stream_name, "123", 'TRIM_HORIZON').should.throw(ResourceNotFoundException)
@mock_kinesis
@mock_kinesis_deprecated
def test_put_records():
conn = boto.kinesis.connect_to_region("us-west-2")
@ -107,7 +107,7 @@ def test_put_records():
record["SequenceNumber"].should.equal("1")
@mock_kinesis
@mock_kinesis_deprecated
def test_get_records_limit():
conn = boto.kinesis.connect_to_region("us-west-2")
@ -136,7 +136,7 @@ def test_get_records_limit():
response['Records'].should.have.length_of(2)
@mock_kinesis
@mock_kinesis_deprecated
def test_get_records_at_sequence_number():
# AT_SEQUENCE_NUMBER - Start reading exactly from the position denoted by a specific sequence number.
conn = boto.kinesis.connect_to_region("us-west-2")
@ -167,7 +167,7 @@ def test_get_records_at_sequence_number():
response['Records'][0]['Data'].should.equal('2')
@mock_kinesis
@mock_kinesis_deprecated
def test_get_records_after_sequence_number():
# AFTER_SEQUENCE_NUMBER - Start reading right after the position denoted by a specific sequence number.
conn = boto.kinesis.connect_to_region("us-west-2")
@ -197,7 +197,7 @@ def test_get_records_after_sequence_number():
response['Records'][0]['Data'].should.equal('3')
@mock_kinesis
@mock_kinesis_deprecated
def test_get_records_latest():
# LATEST - Start reading just after the most recent record in the shard, so that you always read the most recent data in the shard.
conn = boto.kinesis.connect_to_region("us-west-2")
@ -232,7 +232,7 @@ def test_get_records_latest():
response['Records'][0]['Data'].should.equal('last_record')
@mock_kinesis
@mock_kinesis_deprecated
def test_invalid_shard_iterator_type():
conn = boto.kinesis.connect_to_region("us-west-2")
stream_name = "my_stream"
@ -244,7 +244,7 @@ def test_invalid_shard_iterator_type():
stream_name, shard_id, 'invalid-type').should.throw(InvalidArgumentException)
@mock_kinesis
@mock_kinesis_deprecated
def test_add_tags():
conn = boto.kinesis.connect_to_region("us-west-2")
stream_name = "my_stream"
@ -257,7 +257,7 @@ def test_add_tags():
conn.add_tags_to_stream(stream_name, {'tag2':'val4'})
@mock_kinesis
@mock_kinesis_deprecated
def test_list_tags():
conn = boto.kinesis.connect_to_region("us-west-2")
stream_name = "my_stream"
@ -278,7 +278,7 @@ def test_list_tags():
tags.get('tag2').should.equal('val4')
@mock_kinesis
@mock_kinesis_deprecated
def test_remove_tags():
conn = boto.kinesis.connect_to_region("us-west-2")
stream_name = "my_stream"
@ -300,7 +300,7 @@ def test_remove_tags():
tags.get('tag2').should.equal(None)
@mock_kinesis
@mock_kinesis_deprecated
def test_split_shard():
conn = boto.kinesis.connect_to_region("us-west-2")
stream_name = 'my_stream'
@ -341,7 +341,7 @@ def test_split_shard():
sum([shard['SequenceNumberRange']['EndingSequenceNumber'] for shard in shards]).should.equal(99)
@mock_kinesis
@mock_kinesis_deprecated
def test_merge_shards():
conn = boto.kinesis.connect_to_region("us-west-2")
stream_name = 'my_stream'

View file

@ -5,10 +5,10 @@ import boto.kms
from boto.exception import JSONResponseError
from boto.kms.exceptions import AlreadyExistsException, NotFoundException
import sure # noqa
from moto import mock_kms
from moto import mock_kms_deprecated
from nose.tools import assert_raises
@mock_kms
@mock_kms_deprecated
def test_create_key():
conn = boto.kms.connect_to_region("us-west-2")
@ -19,7 +19,7 @@ def test_create_key():
key['KeyMetadata']['Enabled'].should.equal(True)
@mock_kms
@mock_kms_deprecated
def test_describe_key():
conn = boto.kms.connect_to_region("us-west-2")
key = conn.create_key(policy="my policy", description="my key", key_usage='ENCRYPT_DECRYPT')
@ -30,7 +30,7 @@ def test_describe_key():
key['KeyMetadata']['KeyUsage'].should.equal("ENCRYPT_DECRYPT")
@mock_kms
@mock_kms_deprecated
def test_describe_key_via_alias():
conn = boto.kms.connect_to_region("us-west-2")
key = conn.create_key(policy="my policy", description="my key", key_usage='ENCRYPT_DECRYPT')
@ -42,7 +42,7 @@ def test_describe_key_via_alias():
alias_key['KeyMetadata']['Arn'].should.equal(key['KeyMetadata']['Arn'])
@mock_kms
@mock_kms_deprecated
def test_describe_key_via_alias_not_found():
conn = boto.kms.connect_to_region("us-west-2")
key = conn.create_key(policy="my policy", description="my key", key_usage='ENCRYPT_DECRYPT')
@ -51,7 +51,7 @@ def test_describe_key_via_alias_not_found():
conn.describe_key.when.called_with('alias/not-found-alias').should.throw(JSONResponseError)
@mock_kms
@mock_kms_deprecated
def test_describe_key_via_arn():
conn = boto.kms.connect_to_region("us-west-2")
key = conn.create_key(policy="my policy", description="my key", key_usage='ENCRYPT_DECRYPT')
@ -63,13 +63,13 @@ def test_describe_key_via_arn():
the_key['KeyMetadata']['KeyId'].should.equal(key['KeyMetadata']['KeyId'])
@mock_kms
@mock_kms_deprecated
def test_describe_missing_key():
conn = boto.kms.connect_to_region("us-west-2")
conn.describe_key.when.called_with("not-a-key").should.throw(JSONResponseError)
@mock_kms
@mock_kms_deprecated
def test_list_keys():
conn = boto.kms.connect_to_region("us-west-2")
@ -80,7 +80,7 @@ def test_list_keys():
keys['Keys'].should.have.length_of(2)
@mock_kms
@mock_kms_deprecated
def test_enable_key_rotation():
conn = boto.kms.connect_to_region("us-west-2")
@ -91,7 +91,7 @@ def test_enable_key_rotation():
conn.get_key_rotation_status(key_id)['KeyRotationEnabled'].should.equal(True)
@mock_kms
@mock_kms_deprecated
def test_enable_key_rotation_via_arn():
conn = boto.kms.connect_to_region("us-west-2")
@ -104,13 +104,13 @@ def test_enable_key_rotation_via_arn():
@mock_kms
@mock_kms_deprecated
def test_enable_key_rotation_with_missing_key():
conn = boto.kms.connect_to_region("us-west-2")
conn.enable_key_rotation.when.called_with("not-a-key").should.throw(JSONResponseError)
@mock_kms
@mock_kms_deprecated
def test_enable_key_rotation_with_alias_name_should_fail():
conn = boto.kms.connect_to_region("us-west-2")
key = conn.create_key(policy="my policy", description="my key", key_usage='ENCRYPT_DECRYPT')
@ -122,7 +122,7 @@ def test_enable_key_rotation_with_alias_name_should_fail():
conn.enable_key_rotation.when.called_with('alias/my-alias').should.throw(JSONResponseError)
@mock_kms
@mock_kms_deprecated
def test_disable_key_rotation():
conn = boto.kms.connect_to_region("us-west-2")
@ -136,7 +136,7 @@ def test_disable_key_rotation():
conn.get_key_rotation_status(key_id)['KeyRotationEnabled'].should.equal(False)
@mock_kms
@mock_kms_deprecated
def test_encrypt():
"""
test_encrypt
@ -147,26 +147,26 @@ def test_encrypt():
response['CiphertextBlob'].should.equal(b'ZW5jcnlwdG1l')
@mock_kms
@mock_kms_deprecated
def test_decrypt():
conn = boto.kms.connect_to_region('us-west-2')
response = conn.decrypt('ZW5jcnlwdG1l'.encode('utf-8'))
response['Plaintext'].should.equal(b'encryptme')
@mock_kms
@mock_kms_deprecated
def test_disable_key_rotation_with_missing_key():
conn = boto.kms.connect_to_region("us-west-2")
conn.disable_key_rotation.when.called_with("not-a-key").should.throw(JSONResponseError)
@mock_kms
@mock_kms_deprecated
def test_get_key_rotation_status_with_missing_key():
conn = boto.kms.connect_to_region("us-west-2")
conn.get_key_rotation_status.when.called_with("not-a-key").should.throw(JSONResponseError)
@mock_kms
@mock_kms_deprecated
def test_get_key_rotation_status():
conn = boto.kms.connect_to_region("us-west-2")
@ -176,7 +176,7 @@ def test_get_key_rotation_status():
conn.get_key_rotation_status(key_id)['KeyRotationEnabled'].should.equal(False)
@mock_kms
@mock_kms_deprecated
def test_create_key_defaults_key_rotation():
conn = boto.kms.connect_to_region("us-west-2")
@ -186,7 +186,7 @@ def test_create_key_defaults_key_rotation():
conn.get_key_rotation_status(key_id)['KeyRotationEnabled'].should.equal(False)
@mock_kms
@mock_kms_deprecated
def test_get_key_policy():
conn = boto.kms.connect_to_region('us-west-2')
@ -196,7 +196,7 @@ def test_get_key_policy():
policy = conn.get_key_policy(key_id, 'default')
policy['Policy'].should.equal('my policy')
@mock_kms
@mock_kms_deprecated
def test_get_key_policy_via_arn():
conn = boto.kms.connect_to_region('us-west-2')
@ -205,7 +205,7 @@ def test_get_key_policy_via_arn():
policy['Policy'].should.equal('my policy')
@mock_kms
@mock_kms_deprecated
def test_put_key_policy():
conn = boto.kms.connect_to_region('us-west-2')
@ -217,7 +217,7 @@ def test_put_key_policy():
policy['Policy'].should.equal('new policy')
@mock_kms
@mock_kms_deprecated
def test_put_key_policy_via_arn():
conn = boto.kms.connect_to_region('us-west-2')
@ -229,7 +229,7 @@ def test_put_key_policy_via_arn():
policy['Policy'].should.equal('new policy')
@mock_kms
@mock_kms_deprecated
def test_put_key_policy_via_alias_should_not_update():
conn = boto.kms.connect_to_region('us-west-2')
@ -242,7 +242,7 @@ def test_put_key_policy_via_alias_should_not_update():
policy['Policy'].should.equal('my policy')
@mock_kms
@mock_kms_deprecated
def test_put_key_policy():
conn = boto.kms.connect_to_region('us-west-2')
@ -253,7 +253,7 @@ def test_put_key_policy():
policy['Policy'].should.equal('new policy')
@mock_kms
@mock_kms_deprecated
def test_list_key_policies():
conn = boto.kms.connect_to_region('us-west-2')
@ -264,7 +264,7 @@ def test_list_key_policies():
policies['PolicyNames'].should.equal(['default'])
@mock_kms
@mock_kms_deprecated
def test__create_alias__returns_none_if_correct():
kms = boto.connect_kms()
create_resp = kms.create_key()
@ -275,7 +275,7 @@ def test__create_alias__returns_none_if_correct():
resp.should.be.none
@mock_kms
@mock_kms_deprecated
def test__create_alias__raises_if_reserved_alias():
kms = boto.connect_kms()
create_resp = kms.create_key()
@ -300,7 +300,7 @@ def test__create_alias__raises_if_reserved_alias():
ex.status.should.equal(400)
@mock_kms
@mock_kms_deprecated
def test__create_alias__can_create_multiple_aliases_for_same_key_id():
kms = boto.connect_kms()
create_resp = kms.create_key()
@ -311,7 +311,7 @@ def test__create_alias__can_create_multiple_aliases_for_same_key_id():
kms.create_alias('alias/my-alias5', key_id).should.be.none
@mock_kms
@mock_kms_deprecated
def test__create_alias__raises_if_wrong_prefix():
kms = boto.connect_kms()
create_resp = kms.create_key()
@ -328,7 +328,7 @@ def test__create_alias__raises_if_wrong_prefix():
ex.status.should.equal(400)
@mock_kms
@mock_kms_deprecated
def test__create_alias__raises_if_duplicate():
region = 'us-west-2'
kms = boto.kms.connect_to_region(region)
@ -354,7 +354,7 @@ def test__create_alias__raises_if_duplicate():
ex.status.should.equal(400)
@mock_kms
@mock_kms_deprecated
def test__create_alias__raises_if_alias_has_restricted_characters():
kms = boto.connect_kms()
create_resp = kms.create_key()
@ -378,7 +378,7 @@ def test__create_alias__raises_if_alias_has_restricted_characters():
ex.status.should.equal(400)
@mock_kms
@mock_kms_deprecated
def test__create_alias__raises_if_alias_has_colon_character():
# For some reason, colons are not accepted for an alias, even though they are accepted by regex ^[a-zA-Z0-9:/_-]+$
kms = boto.connect_kms()
@ -401,7 +401,7 @@ def test__create_alias__raises_if_alias_has_colon_character():
ex.status.should.equal(400)
@mock_kms
@mock_kms_deprecated
def test__create_alias__accepted_characters():
kms = boto.connect_kms()
create_resp = kms.create_key()
@ -416,7 +416,7 @@ def test__create_alias__accepted_characters():
kms.create_alias(alias_name, key_id)
@mock_kms
@mock_kms_deprecated
def test__create_alias__raises_if_target_key_id_is_existing_alias():
kms = boto.connect_kms()
create_resp = kms.create_key()
@ -437,7 +437,7 @@ def test__create_alias__raises_if_target_key_id_is_existing_alias():
ex.status.should.equal(400)
@mock_kms
@mock_kms_deprecated
def test__delete_alias():
kms = boto.connect_kms()
create_resp = kms.create_key()
@ -454,7 +454,7 @@ def test__delete_alias():
kms.create_alias(alias, key_id)
@mock_kms
@mock_kms_deprecated
def test__delete_alias__raises_if_wrong_prefix():
kms = boto.connect_kms()
@ -470,7 +470,7 @@ def test__delete_alias__raises_if_wrong_prefix():
ex.status.should.equal(400)
@mock_kms
@mock_kms_deprecated
def test__delete_alias__raises_if_alias_is_not_found():
region = 'us-west-2'
kms = boto.kms.connect_to_region(region)
@ -490,7 +490,7 @@ def test__delete_alias__raises_if_alias_is_not_found():
ex.status.should.equal(400)
@mock_kms
@mock_kms_deprecated
def test__list_aliases():
region = "eu-west-1"
kms = boto.kms.connect_to_region(region)
@ -532,7 +532,7 @@ def test__list_aliases():
len(aliases).should.equal(7)
@mock_kms
@mock_kms_deprecated
def test__assert_valid_key_id():
from moto.kms.responses import _assert_valid_key_id
import uuid
@ -541,7 +541,7 @@ def test__assert_valid_key_id():
_assert_valid_key_id.when.called_with(str(uuid.uuid4())).should_not.throw(JSONResponseError)
@mock_kms
@mock_kms_deprecated
def test__assert_default_policy():
from moto.kms.responses import _assert_default_policy

View file

@ -66,7 +66,7 @@ def test_describe_layers():
rv1 = client.describe_layers(StackId=stack_id)
rv2 = client.describe_layers(LayerIds=[layer_id])
rv1.should.equal(rv2)
rv1['Layers'].should.equal(rv2['Layers'])
rv1['Layers'][0]['Name'].should.equal("TestLayer")

View file

@ -5,12 +5,12 @@ import boto.vpc
from boto.exception import BotoServerError
import sure # noqa
from moto import mock_ec2, mock_rds
from moto import mock_ec2_deprecated, mock_rds_deprecated
from tests.helpers import disable_on_py3
@disable_on_py3()
@mock_rds
@mock_rds_deprecated
def test_create_database():
conn = boto.rds.connect_to_region("us-west-2")
@ -27,7 +27,7 @@ def test_create_database():
@disable_on_py3()
@mock_rds
@mock_rds_deprecated
def test_get_databases():
conn = boto.rds.connect_to_region("us-west-2")
@ -44,14 +44,14 @@ def test_get_databases():
databases[0].id.should.equal("db-master-1")
@mock_rds
@mock_rds_deprecated
def test_describe_non_existant_database():
conn = boto.rds.connect_to_region("us-west-2")
conn.get_all_dbinstances.when.called_with("not-a-db").should.throw(BotoServerError)
@disable_on_py3()
@mock_rds
@mock_rds_deprecated
def test_delete_database():
conn = boto.rds.connect_to_region("us-west-2")
list(conn.get_all_dbinstances()).should.have.length_of(0)
@ -63,13 +63,13 @@ def test_delete_database():
list(conn.get_all_dbinstances()).should.have.length_of(0)
@mock_rds
@mock_rds_deprecated
def test_delete_non_existant_database():
conn = boto.rds.connect_to_region("us-west-2")
conn.delete_dbinstance.when.called_with("not-a-db").should.throw(BotoServerError)
@mock_rds
@mock_rds_deprecated
def test_create_database_security_group():
conn = boto.rds.connect_to_region("us-west-2")
@ -79,7 +79,7 @@ def test_create_database_security_group():
list(security_group.ip_ranges).should.equal([])
@mock_rds
@mock_rds_deprecated
def test_get_security_groups():
conn = boto.rds.connect_to_region("us-west-2")
@ -96,13 +96,13 @@ def test_get_security_groups():
databases[0].name.should.equal("db_sg1")
@mock_rds
@mock_rds_deprecated
def test_get_non_existant_security_group():
conn = boto.rds.connect_to_region("us-west-2")
conn.get_all_dbsecurity_groups.when.called_with("not-a-sg").should.throw(BotoServerError)
@mock_rds
@mock_rds_deprecated
def test_delete_database_security_group():
conn = boto.rds.connect_to_region("us-west-2")
conn.create_dbsecurity_group('db_sg', 'DB Security Group')
@ -113,14 +113,14 @@ def test_delete_database_security_group():
list(conn.get_all_dbsecurity_groups()).should.have.length_of(0)
@mock_rds
@mock_rds_deprecated
def test_delete_non_existant_security_group():
conn = boto.rds.connect_to_region("us-west-2")
conn.delete_dbsecurity_group.when.called_with("not-a-db").should.throw(BotoServerError)
@disable_on_py3()
@mock_rds
@mock_rds_deprecated
def test_security_group_authorize():
conn = boto.rds.connect_to_region("us-west-2")
security_group = conn.create_dbsecurity_group('db_sg', 'DB Security Group')
@ -133,7 +133,7 @@ def test_security_group_authorize():
@disable_on_py3()
@mock_rds
@mock_rds_deprecated
def test_add_security_group_to_database():
conn = boto.rds.connect_to_region("us-west-2")
@ -147,8 +147,8 @@ def test_add_security_group_to_database():
database.security_groups[0].name.should.equal("db_sg")
@mock_ec2
@mock_rds
@mock_ec2_deprecated
@mock_rds_deprecated
def test_add_database_subnet_group():
vpc_conn = boto.vpc.connect_to_region("us-west-2")
vpc = vpc_conn.create_vpc("10.0.0.0/16")
@ -163,8 +163,8 @@ def test_add_database_subnet_group():
list(subnet_group.subnet_ids).should.equal(subnet_ids)
@mock_ec2
@mock_rds
@mock_ec2_deprecated
@mock_rds_deprecated
def test_describe_database_subnet_group():
vpc_conn = boto.vpc.connect_to_region("us-west-2")
vpc = vpc_conn.create_vpc("10.0.0.0/16")
@ -180,8 +180,8 @@ def test_describe_database_subnet_group():
conn.get_all_db_subnet_groups.when.called_with("not-a-subnet").should.throw(BotoServerError)
@mock_ec2
@mock_rds
@mock_ec2_deprecated
@mock_rds_deprecated
def test_delete_database_subnet_group():
vpc_conn = boto.vpc.connect_to_region("us-west-2")
vpc = vpc_conn.create_vpc("10.0.0.0/16")
@ -198,8 +198,8 @@ def test_delete_database_subnet_group():
@disable_on_py3()
@mock_ec2
@mock_rds
@mock_ec2_deprecated
@mock_rds_deprecated
def test_create_database_in_subnet_group():
vpc_conn = boto.vpc.connect_to_region("us-west-2")
vpc = vpc_conn.create_vpc("10.0.0.0/16")
@ -216,7 +216,7 @@ def test_create_database_in_subnet_group():
@disable_on_py3()
@mock_rds
@mock_rds_deprecated
def test_create_database_replica():
conn = boto.rds.connect_to_region("us-west-2")
@ -239,7 +239,7 @@ def test_create_database_replica():
list(primary.read_replica_dbinstance_identifiers).should.have.length_of(0)
@disable_on_py3()
@mock_rds
@mock_rds_deprecated
def test_create_cross_region_database_replica():
west_1_conn = boto.rds.connect_to_region("us-west-1")
west_2_conn = boto.rds.connect_to_region("us-west-2")
@ -266,7 +266,7 @@ def test_create_cross_region_database_replica():
@disable_on_py3()
@mock_rds
@mock_rds_deprecated
def test_connecting_to_us_east_1():
# boto does not use us-east-1 in the URL for RDS,
# and that broke moto in the past:
@ -286,7 +286,7 @@ def test_connecting_to_us_east_1():
@disable_on_py3()
@mock_rds
@mock_rds_deprecated
def test_create_database_with_iops():
conn = boto.rds.connect_to_region("us-west-2")

View file

@ -1,7 +1,5 @@
from __future__ import unicode_literals
import boto.rds2
import boto.vpc
from botocore.exceptions import ClientError, ParamValidationError
import boto3
import sure # noqa

View file

@ -10,10 +10,10 @@ from boto.redshift.exceptions import (
)
import sure # noqa
from moto import mock_ec2, mock_redshift
from moto import mock_ec2_deprecated, mock_redshift_deprecated
@mock_redshift
@mock_redshift_deprecated
def test_create_cluster():
conn = boto.redshift.connect_to_region("us-east-1")
cluster_identifier = 'my_cluster'
@ -54,7 +54,7 @@ def test_create_cluster():
cluster['NumberOfNodes'].should.equal(3)
@mock_redshift
@mock_redshift_deprecated
def test_create_single_node_cluster():
conn = boto.redshift.connect_to_region("us-east-1")
cluster_identifier = 'my_cluster'
@ -78,7 +78,7 @@ def test_create_single_node_cluster():
cluster['NumberOfNodes'].should.equal(1)
@mock_redshift
@mock_redshift_deprecated
def test_default_cluster_attibutes():
conn = boto.redshift.connect_to_region("us-east-1")
cluster_identifier = 'my_cluster'
@ -105,8 +105,8 @@ def test_default_cluster_attibutes():
cluster['NumberOfNodes'].should.equal(1)
@mock_redshift
@mock_ec2
@mock_redshift_deprecated
@mock_ec2_deprecated
def test_create_cluster_in_subnet_group():
vpc_conn = boto.connect_vpc()
vpc = vpc_conn.create_vpc("10.0.0.0/16")
@ -131,7 +131,7 @@ def test_create_cluster_in_subnet_group():
cluster['ClusterSubnetGroupName'].should.equal('my_subnet_group')
@mock_redshift
@mock_redshift_deprecated
def test_create_cluster_with_security_group():
conn = boto.redshift.connect_to_region("us-east-1")
conn.create_cluster_security_group(
@ -158,8 +158,8 @@ def test_create_cluster_with_security_group():
set(group_names).should.equal(set(["security_group1", "security_group2"]))
@mock_redshift
@mock_ec2
@mock_redshift_deprecated
@mock_ec2_deprecated
def test_create_cluster_with_vpc_security_groups():
vpc_conn = boto.connect_vpc()
ec2_conn = boto.connect_ec2()
@ -181,7 +181,7 @@ def test_create_cluster_with_vpc_security_groups():
list(group_ids).should.equal([security_group.id])
@mock_redshift
@mock_redshift_deprecated
def test_create_cluster_with_parameter_group():
conn = boto.connect_redshift()
conn.create_cluster_parameter_group(
@ -203,13 +203,13 @@ def test_create_cluster_with_parameter_group():
cluster['ClusterParameterGroups'][0]['ParameterGroupName'].should.equal("my_parameter_group")
@mock_redshift
@mock_redshift_deprecated
def test_describe_non_existant_cluster():
conn = boto.redshift.connect_to_region("us-east-1")
conn.describe_clusters.when.called_with("not-a-cluster").should.throw(ClusterNotFound)
@mock_redshift
@mock_redshift_deprecated
def test_delete_cluster():
conn = boto.connect_redshift()
cluster_identifier = 'my_cluster'
@ -233,7 +233,7 @@ def test_delete_cluster():
conn.delete_cluster.when.called_with("not-a-cluster").should.throw(ClusterNotFound)
@mock_redshift
@mock_redshift_deprecated
def test_modify_cluster():
conn = boto.connect_redshift()
cluster_identifier = 'my_cluster'
@ -281,8 +281,8 @@ def test_modify_cluster():
cluster['NumberOfNodes'].should.equal(2)
@mock_redshift
@mock_ec2
@mock_redshift_deprecated
@mock_ec2_deprecated
def test_create_cluster_subnet_group():
vpc_conn = boto.connect_vpc()
vpc = vpc_conn.create_vpc("10.0.0.0/16")
@ -306,8 +306,8 @@ def test_create_cluster_subnet_group():
set(subnet_ids).should.equal(set([subnet1.id, subnet2.id]))
@mock_redshift
@mock_ec2
@mock_redshift_deprecated
@mock_ec2_deprecated
def test_create_invalid_cluster_subnet_group():
redshift_conn = boto.connect_redshift()
redshift_conn.create_cluster_subnet_group.when.called_with(
@ -317,14 +317,14 @@ def test_create_invalid_cluster_subnet_group():
).should.throw(InvalidSubnet)
@mock_redshift
@mock_redshift_deprecated
def test_describe_non_existant_subnet_group():
conn = boto.redshift.connect_to_region("us-east-1")
conn.describe_cluster_subnet_groups.when.called_with("not-a-subnet-group").should.throw(ClusterSubnetGroupNotFound)
@mock_redshift
@mock_ec2
@mock_redshift_deprecated
@mock_ec2_deprecated
def test_delete_cluster_subnet_group():
vpc_conn = boto.connect_vpc()
vpc = vpc_conn.create_vpc("10.0.0.0/16")
@ -351,7 +351,7 @@ def test_delete_cluster_subnet_group():
redshift_conn.delete_cluster_subnet_group.when.called_with("not-a-subnet-group").should.throw(ClusterSubnetGroupNotFound)
@mock_redshift
@mock_redshift_deprecated
def test_create_cluster_security_group():
conn = boto.connect_redshift()
conn.create_cluster_security_group(
@ -367,13 +367,13 @@ def test_create_cluster_security_group():
list(my_group['IPRanges']).should.equal([])
@mock_redshift
@mock_redshift_deprecated
def test_describe_non_existant_security_group():
conn = boto.redshift.connect_to_region("us-east-1")
conn.describe_cluster_security_groups.when.called_with("not-a-security-group").should.throw(ClusterSecurityGroupNotFound)
@mock_redshift
@mock_redshift_deprecated
def test_delete_cluster_security_group():
conn = boto.connect_redshift()
conn.create_cluster_security_group(
@ -395,7 +395,7 @@ def test_delete_cluster_security_group():
conn.delete_cluster_security_group.when.called_with("not-a-security-group").should.throw(ClusterSecurityGroupNotFound)
@mock_redshift
@mock_redshift_deprecated
def test_create_cluster_parameter_group():
conn = boto.connect_redshift()
conn.create_cluster_parameter_group(
@ -412,13 +412,13 @@ def test_create_cluster_parameter_group():
my_group['Description'].should.equal("This is my parameter group")
@mock_redshift
@mock_redshift_deprecated
def test_describe_non_existant_parameter_group():
conn = boto.redshift.connect_to_region("us-east-1")
conn.describe_cluster_parameter_groups.when.called_with("not-a-parameter-group").should.throw(ClusterParameterGroupNotFound)
@mock_redshift
@mock_redshift_deprecated
def test_delete_cluster_parameter_group():
conn = boto.connect_redshift()
conn.create_cluster_parameter_group(

View file

@ -9,10 +9,10 @@ import sure # noqa
import uuid
from moto import mock_route53
from moto import mock_route53, mock_route53_deprecated
@mock_route53
@mock_route53_deprecated
def test_hosted_zone():
conn = boto.connect_route53('the_key', 'the_secret')
firstzone = conn.create_hosted_zone("testdns.aws.com")
@ -34,7 +34,7 @@ def test_hosted_zone():
conn.get_hosted_zone.when.called_with("abcd").should.throw(boto.route53.exception.DNSServerError, "404 Not Found")
@mock_route53
@mock_route53_deprecated
def test_rrset():
conn = boto.connect_route53('the_key', 'the_secret')
@ -117,7 +117,7 @@ def test_rrset():
rrsets.should.have.length_of(0)
@mock_route53
@mock_route53_deprecated
def test_rrset_with_multiple_values():
conn = boto.connect_route53('the_key', 'the_secret')
zone = conn.create_hosted_zone("testdns.aws.com")
@ -134,7 +134,7 @@ def test_rrset_with_multiple_values():
set(rrsets[0].resource_records).should.equal(set(['1.2.3.4', '5.6.7.8']))
@mock_route53
@mock_route53_deprecated
def test_alias_rrset():
conn = boto.connect_route53('the_key', 'the_secret')
zone = conn.create_hosted_zone("testdns.aws.com")
@ -153,7 +153,7 @@ def test_alias_rrset():
rrsets[0].resource_records[0].should.equal('bar.testdns.aws.com')
@mock_route53
@mock_route53_deprecated
def test_create_health_check():
conn = boto.connect_route53('the_key', 'the_secret')
@ -183,7 +183,7 @@ def test_create_health_check():
config['FailureThreshold'].should.equal("2")
@mock_route53
@mock_route53_deprecated
def test_delete_health_check():
conn = boto.connect_route53('the_key', 'the_secret')
@ -204,7 +204,7 @@ def test_delete_health_check():
list(checks).should.have.length_of(0)
@mock_route53
@mock_route53_deprecated
def test_use_health_check_in_resource_record_set():
conn = boto.connect_route53('the_key', 'the_secret')
@ -229,7 +229,7 @@ def test_use_health_check_in_resource_record_set():
record_sets[0].health_check.should.equal(check_id)
@mock_route53
@mock_route53_deprecated
def test_hosted_zone_comment_preserved():
conn = boto.connect_route53('the_key', 'the_secret')
@ -246,7 +246,7 @@ def test_hosted_zone_comment_preserved():
zone.config["Comment"].should.equal("test comment")
@mock_route53
@mock_route53_deprecated
def test_deleting_weighted_route():
conn = boto.connect_route53()
@ -266,7 +266,7 @@ def test_deleting_weighted_route():
cname.identifier.should.equal('success-test-bar')
@mock_route53
@mock_route53_deprecated
def test_deleting_latency_route():
conn = boto.connect_route53()
@ -288,7 +288,7 @@ def test_deleting_latency_route():
cname.region.should.equal('us-west-1')
@mock_route53
@mock_route53_deprecated
def test_hosted_zone_private_zone_preserved():
conn = boto.connect_route53('the_key', 'the_secret')

View file

@ -20,7 +20,7 @@ from nose.tools import assert_raises
import sure # noqa
from moto import mock_s3
from moto import mock_s3, mock_s3_deprecated
REDUCED_PART_SIZE = 256
@ -56,7 +56,7 @@ class MyModel(object):
k.set_contents_from_string(self.value)
@mock_s3
@mock_s3_deprecated
def test_my_model_save():
# Create Bucket so that test can run
conn = boto.connect_s3('the_key', 'the_secret')
@ -69,7 +69,7 @@ def test_my_model_save():
conn.get_bucket('mybucket').get_key('steve').get_contents_as_string().should.equal(b'is awesome')
@mock_s3
@mock_s3_deprecated
def test_key_etag():
# Create Bucket so that test can run
conn = boto.connect_s3('the_key', 'the_secret')
@ -83,7 +83,7 @@ def test_key_etag():
'"d32bda93738f7e03adb22e66c90fbc04"')
@mock_s3
@mock_s3_deprecated
def test_multipart_upload_too_small():
conn = boto.connect_s3('the_key', 'the_secret')
bucket = conn.create_bucket("foobar")
@ -95,7 +95,7 @@ def test_multipart_upload_too_small():
multipart.complete_upload.should.throw(S3ResponseError)
@mock_s3
@mock_s3_deprecated
@reduced_min_part_size
def test_multipart_upload():
conn = boto.connect_s3('the_key', 'the_secret')
@ -112,7 +112,7 @@ def test_multipart_upload():
bucket.get_key("the-key").get_contents_as_string().should.equal(part1 + part2)
@mock_s3
@mock_s3_deprecated
@reduced_min_part_size
def test_multipart_upload_out_of_order():
conn = boto.connect_s3('the_key', 'the_secret')
@ -129,7 +129,7 @@ def test_multipart_upload_out_of_order():
bucket.get_key("the-key").get_contents_as_string().should.equal(part1 + part2)
@mock_s3
@mock_s3_deprecated
@reduced_min_part_size
def test_multipart_upload_with_headers():
conn = boto.connect_s3('the_key', 'the_secret')
@ -144,7 +144,7 @@ def test_multipart_upload_with_headers():
key.metadata.should.equal({"foo": "bar"})
@mock_s3
@mock_s3_deprecated
@reduced_min_part_size
def test_multipart_upload_with_copy_key():
conn = boto.connect_s3('the_key', 'the_secret')
@ -161,7 +161,7 @@ def test_multipart_upload_with_copy_key():
bucket.get_key("the-key").get_contents_as_string().should.equal(part1 + b"key_")
@mock_s3
@mock_s3_deprecated
@reduced_min_part_size
def test_multipart_upload_cancel():
conn = boto.connect_s3('the_key', 'the_secret')
@ -175,7 +175,7 @@ def test_multipart_upload_cancel():
# have the ability to list mulipart uploads for a bucket.
@mock_s3
@mock_s3_deprecated
@reduced_min_part_size
def test_multipart_etag():
# Create Bucket so that test can run
@ -194,7 +194,7 @@ def test_multipart_etag():
'"66d1a1a2ed08fd05c137f316af4ff255-2"')
@mock_s3
@mock_s3_deprecated
@reduced_min_part_size
def test_multipart_invalid_order():
# Create Bucket so that test can run
@ -214,7 +214,7 @@ def test_multipart_invalid_order():
multipart.key_name, multipart.id, xml).should.throw(S3ResponseError)
@mock_s3
@mock_s3_deprecated
@reduced_min_part_size
def test_multipart_duplicate_upload():
conn = boto.connect_s3('the_key', 'the_secret')
@ -232,7 +232,7 @@ def test_multipart_duplicate_upload():
bucket.get_key("the-key").get_contents_as_string().should.equal(part1 + part2)
@mock_s3
@mock_s3_deprecated
def test_list_multiparts():
# Create Bucket so that test can run
conn = boto.connect_s3('the_key', 'the_secret')
@ -253,7 +253,7 @@ def test_list_multiparts():
uploads.should.be.empty
@mock_s3
@mock_s3_deprecated
def test_key_save_to_missing_bucket():
conn = boto.connect_s3('the_key', 'the_secret')
bucket = conn.get_bucket('mybucket', validate=False)
@ -263,14 +263,14 @@ def test_key_save_to_missing_bucket():
key.set_contents_from_string.when.called_with("foobar").should.throw(S3ResponseError)
@mock_s3
@mock_s3_deprecated
def test_missing_key():
conn = boto.connect_s3('the_key', 'the_secret')
bucket = conn.create_bucket("foobar")
bucket.get_key("the-key").should.equal(None)
@mock_s3
@mock_s3_deprecated
def test_missing_key_urllib2():
conn = boto.connect_s3('the_key', 'the_secret')
conn.create_bucket("foobar")
@ -278,7 +278,7 @@ def test_missing_key_urllib2():
urlopen.when.called_with("http://foobar.s3.amazonaws.com/the-key").should.throw(HTTPError)
@mock_s3
@mock_s3_deprecated
def test_empty_key():
conn = boto.connect_s3('the_key', 'the_secret')
bucket = conn.create_bucket("foobar")
@ -291,7 +291,7 @@ def test_empty_key():
key.get_contents_as_string().should.equal(b'')
@mock_s3
@mock_s3_deprecated
def test_empty_key_set_on_existing_key():
conn = boto.connect_s3('the_key', 'the_secret')
bucket = conn.create_bucket("foobar")
@ -307,7 +307,7 @@ def test_empty_key_set_on_existing_key():
bucket.get_key("the-key").get_contents_as_string().should.equal(b'')
@mock_s3
@mock_s3_deprecated
def test_large_key_save():
conn = boto.connect_s3('the_key', 'the_secret')
bucket = conn.create_bucket("foobar")
@ -318,7 +318,7 @@ def test_large_key_save():
bucket.get_key("the-key").get_contents_as_string().should.equal(b'foobar' * 100000)
@mock_s3
@mock_s3_deprecated
def test_copy_key():
conn = boto.connect_s3('the_key', 'the_secret')
bucket = conn.create_bucket("foobar")
@ -332,7 +332,7 @@ def test_copy_key():
bucket.get_key("new-key").get_contents_as_string().should.equal(b"some value")
@mock_s3
@mock_s3_deprecated
def test_copy_key_with_version():
conn = boto.connect_s3('the_key', 'the_secret')
bucket = conn.create_bucket("foobar")
@ -348,7 +348,7 @@ def test_copy_key_with_version():
bucket.get_key("new-key").get_contents_as_string().should.equal(b"some value")
@mock_s3
@mock_s3_deprecated
def test_set_metadata():
conn = boto.connect_s3('the_key', 'the_secret')
bucket = conn.create_bucket("foobar")
@ -360,7 +360,7 @@ def test_set_metadata():
bucket.get_key('the-key').get_metadata('md').should.equal('Metadatastring')
@mock_s3
@mock_s3_deprecated
def test_copy_key_replace_metadata():
conn = boto.connect_s3('the_key', 'the_secret')
bucket = conn.create_bucket("foobar")
@ -377,7 +377,7 @@ def test_copy_key_replace_metadata():
@freeze_time("2012-01-01 12:00:00")
@mock_s3
@mock_s3_deprecated
def test_last_modified():
# See https://github.com/boto/boto/issues/466
conn = boto.connect_s3()
@ -392,19 +392,19 @@ def test_last_modified():
bucket.get_key("the-key").last_modified.should.equal('Sun, 01 Jan 2012 12:00:00 GMT')
@mock_s3
@mock_s3_deprecated
def test_missing_bucket():
conn = boto.connect_s3('the_key', 'the_secret')
conn.get_bucket.when.called_with('mybucket').should.throw(S3ResponseError)
@mock_s3
@mock_s3_deprecated
def test_bucket_with_dash():
conn = boto.connect_s3('the_key', 'the_secret')
conn.get_bucket.when.called_with('mybucket-test').should.throw(S3ResponseError)
@mock_s3
@mock_s3_deprecated
def test_create_existing_bucket():
"Trying to create a bucket that already exists should raise an Error"
conn = boto.s3.connect_to_region("us-west-2")
@ -413,7 +413,7 @@ def test_create_existing_bucket():
conn.create_bucket('foobar')
@mock_s3
@mock_s3_deprecated
def test_create_existing_bucket_in_us_east_1():
"Trying to create a bucket that already exists in us-east-1 returns the bucket"
@ -430,14 +430,14 @@ def test_create_existing_bucket_in_us_east_1():
bucket.name.should.equal("foobar")
@mock_s3
@mock_s3_deprecated
def test_other_region():
conn = S3Connection('key', 'secret', host='s3-website-ap-southeast-2.amazonaws.com')
conn.create_bucket("foobar")
list(conn.get_bucket("foobar").get_all_keys()).should.equal([])
@mock_s3
@mock_s3_deprecated
def test_bucket_deletion():
conn = boto.connect_s3('the_key', 'the_secret')
bucket = conn.create_bucket("foobar")
@ -459,7 +459,7 @@ def test_bucket_deletion():
conn.delete_bucket.when.called_with("foobar").should.throw(S3ResponseError)
@mock_s3
@mock_s3_deprecated
def test_get_all_buckets():
conn = boto.connect_s3('the_key', 'the_secret')
conn.create_bucket("foobar")
@ -470,6 +470,7 @@ def test_get_all_buckets():
@mock_s3
@mock_s3_deprecated
def test_post_to_bucket():
conn = boto.connect_s3('the_key', 'the_secret')
bucket = conn.create_bucket("foobar")
@ -483,6 +484,7 @@ def test_post_to_bucket():
@mock_s3
@mock_s3_deprecated
def test_post_with_metadata_to_bucket():
conn = boto.connect_s3('the_key', 'the_secret')
bucket = conn.create_bucket("foobar")
@ -496,7 +498,7 @@ def test_post_with_metadata_to_bucket():
bucket.get_key('the-key').get_metadata('test').should.equal('metadata')
@mock_s3
@mock_s3_deprecated
def test_delete_missing_key():
conn = boto.connect_s3('the_key', 'the_secret')
bucket = conn.create_bucket('foobar')
@ -505,7 +507,7 @@ def test_delete_missing_key():
deleted_key.key.should.equal("foobar")
@mock_s3
@mock_s3_deprecated
def test_delete_keys():
conn = boto.connect_s3('the_key', 'the_secret')
bucket = conn.create_bucket('foobar')
@ -523,7 +525,7 @@ def test_delete_keys():
keys[0].name.should.equal('file1')
@mock_s3
@mock_s3_deprecated
def test_delete_keys_with_invalid():
conn = boto.connect_s3('the_key', 'the_secret')
bucket = conn.create_bucket('foobar')
@ -552,7 +554,7 @@ def test_key_method_not_implemented():
requests.post.when.called_with("https://foobar.s3.amazonaws.com/foo").should.throw(NotImplementedError)
@mock_s3
@mock_s3_deprecated
def test_bucket_name_with_dot():
conn = boto.connect_s3()
bucket = conn.create_bucket('firstname.lastname')
@ -561,7 +563,7 @@ def test_bucket_name_with_dot():
k.set_contents_from_string('somedata')
@mock_s3
@mock_s3_deprecated
def test_key_with_special_characters():
conn = boto.connect_s3()
bucket = conn.create_bucket('test_bucket_name')
@ -574,7 +576,7 @@ def test_key_with_special_characters():
keys[0].name.should.equal("test_list_keys_2/x?y")
@mock_s3
@mock_s3_deprecated
def test_unicode_key_with_slash():
conn = boto.connect_s3('the_key', 'the_secret')
bucket = conn.create_bucket("foobar")
@ -586,7 +588,7 @@ def test_unicode_key_with_slash():
key.get_contents_as_string().should.equal(b'value')
@mock_s3
@mock_s3_deprecated
def test_bucket_key_listing_order():
conn = boto.connect_s3()
bucket = conn.create_bucket('test_bucket')
@ -628,7 +630,7 @@ def test_bucket_key_listing_order():
keys.should.equal([u'toplevel/x/'])
@mock_s3
@mock_s3_deprecated
def test_key_with_reduced_redundancy():
conn = boto.connect_s3()
bucket = conn.create_bucket('test_bucket_name')
@ -640,7 +642,7 @@ def test_key_with_reduced_redundancy():
list(bucket)[0].storage_class.should.equal('REDUCED_REDUNDANCY')
@mock_s3
@mock_s3_deprecated
def test_copy_key_reduced_redundancy():
conn = boto.connect_s3('the_key', 'the_secret')
bucket = conn.create_bucket("foobar")
@ -658,7 +660,7 @@ def test_copy_key_reduced_redundancy():
@freeze_time("2012-01-01 12:00:00")
@mock_s3
@mock_s3_deprecated
def test_restore_key():
conn = boto.connect_s3('the_key', 'the_secret')
bucket = conn.create_bucket("foobar")
@ -679,7 +681,7 @@ def test_restore_key():
@freeze_time("2012-01-01 12:00:00")
@mock_s3
@mock_s3_deprecated
def test_restore_key_headers():
conn = boto.connect_s3('the_key', 'the_secret')
bucket = conn.create_bucket("foobar")
@ -693,7 +695,7 @@ def test_restore_key_headers():
key.expiry_date.should.equal("Mon, 02 Jan 2012 12:00:00 GMT")
@mock_s3
@mock_s3_deprecated
def test_get_versioning_status():
conn = boto.connect_s3('the_key', 'the_secret')
bucket = conn.create_bucket('foobar')
@ -710,7 +712,7 @@ def test_get_versioning_status():
d.should.have.key('Versioning').being.equal('Suspended')
@mock_s3
@mock_s3_deprecated
def test_key_version():
conn = boto.connect_s3('the_key', 'the_secret')
bucket = conn.create_bucket('foobar')
@ -728,7 +730,7 @@ def test_key_version():
key.version_id.should.equal('1')
@mock_s3
@mock_s3_deprecated
def test_list_versions():
conn = boto.connect_s3('the_key', 'the_secret')
bucket = conn.create_bucket('foobar')
@ -754,7 +756,7 @@ def test_list_versions():
versions[1].get_contents_as_string().should.equal(b"Version 2")
@mock_s3
@mock_s3_deprecated
def test_acl_setting():
conn = boto.connect_s3()
bucket = conn.create_bucket('foobar')
@ -775,7 +777,7 @@ def test_acl_setting():
g.permission == 'READ' for g in grants), grants
@mock_s3
@mock_s3_deprecated
def test_acl_setting_via_headers():
conn = boto.connect_s3()
bucket = conn.create_bucket('foobar')
@ -797,7 +799,7 @@ def test_acl_setting_via_headers():
g.permission == 'FULL_CONTROL' for g in grants), grants
@mock_s3
@mock_s3_deprecated
def test_acl_switching():
conn = boto.connect_s3()
bucket = conn.create_bucket('foobar')
@ -814,7 +816,7 @@ def test_acl_switching():
g.permission == 'READ' for g in grants), grants
@mock_s3
@mock_s3_deprecated
def test_bucket_acl_setting():
conn = boto.connect_s3()
bucket = conn.create_bucket('foobar')
@ -826,7 +828,7 @@ def test_bucket_acl_setting():
g.permission == 'READ' for g in grants), grants
@mock_s3
@mock_s3_deprecated
def test_bucket_acl_switching():
conn = boto.connect_s3()
bucket = conn.create_bucket('foobar')
@ -839,7 +841,7 @@ def test_bucket_acl_switching():
g.permission == 'READ' for g in grants), grants
@mock_s3
@mock_s3_deprecated
def test_unicode_key():
conn = boto.connect_s3()
bucket = conn.create_bucket('mybucket')
@ -852,7 +854,7 @@ def test_unicode_key():
assert fetched_key.get_contents_as_string().decode("utf-8") == 'Hello world!'
@mock_s3
@mock_s3_deprecated
def test_unicode_value():
conn = boto.connect_s3()
bucket = conn.create_bucket('mybucket')
@ -864,7 +866,7 @@ def test_unicode_value():
assert key.get_contents_as_string().decode("utf-8") == u'こんにちは.jpg'
@mock_s3
@mock_s3_deprecated
def test_setting_content_encoding():
conn = boto.connect_s3()
bucket = conn.create_bucket('mybucket')
@ -877,14 +879,14 @@ def test_setting_content_encoding():
key.content_encoding.should.equal("gzip")
@mock_s3
@mock_s3_deprecated
def test_bucket_location():
conn = boto.s3.connect_to_region("us-west-2")
bucket = conn.create_bucket('mybucket')
bucket.get_location().should.equal("us-west-2")
@mock_s3
@mock_s3_deprecated
def test_ranged_get():
conn = boto.connect_s3()
bucket = conn.create_bucket('mybucket')
@ -926,7 +928,7 @@ def test_ranged_get():
key.size.should.equal(100)
@mock_s3
@mock_s3_deprecated
def test_policy():
conn = boto.connect_s3()
bucket_name = 'mybucket'
@ -976,6 +978,31 @@ def test_policy():
bucket.get_policy()
@mock_s3_deprecated
def test_website_configuration_xml():
conn = boto.connect_s3()
bucket = conn.create_bucket('test-bucket')
bucket.set_website_configuration_xml(TEST_XML)
bucket.get_website_configuration_xml().should.equal(TEST_XML)
@mock_s3_deprecated
def test_key_with_trailing_slash_in_ordinary_calling_format():
conn = boto.connect_s3(
'access_key',
'secret_key',
calling_format=boto.s3.connection.OrdinaryCallingFormat()
)
bucket = conn.create_bucket('test_bucket_name')
key_name = 'key_with_slash/'
key = Key(bucket, key_name)
key.set_contents_from_string('some value')
[k.name for k in bucket.get_all_keys()].should.contain(key_name)
"""
boto3
"""
@ -1235,28 +1262,3 @@ TEST_XML = """\
</ns0:RoutingRules>
</ns0:WebsiteConfiguration>
"""
@mock_s3
def test_website_configuration_xml():
conn = boto.connect_s3()
bucket = conn.create_bucket('test-bucket')
bucket.set_website_configuration_xml(TEST_XML)
bucket.get_website_configuration_xml().should.equal(TEST_XML)
@mock_s3
def test_key_with_trailing_slash_in_ordinary_calling_format():
conn = boto.connect_s3(
'access_key',
'secret_key',
calling_format=boto.s3.connection.OrdinaryCallingFormat()
)
bucket = conn.create_bucket('test_bucket_name')
key_name = 'key_with_slash/'
key = Key(bucket, key_name)
key.set_contents_from_string('some value')
[k.name for k in bucket.get_all_keys()].should.contain(key_name)

View file

@ -6,10 +6,10 @@ from boto.s3.lifecycle import Lifecycle, Transition, Expiration, Rule
import sure # noqa
from moto import mock_s3
from moto import mock_s3_deprecated
@mock_s3
@mock_s3_deprecated
def test_lifecycle_create():
conn = boto.s3.connect_to_region("us-west-1")
bucket = conn.create_bucket("foobar")
@ -26,7 +26,7 @@ def test_lifecycle_create():
list(lifecycle.transition).should.equal([])
@mock_s3
@mock_s3_deprecated
def test_lifecycle_with_glacier_transition():
conn = boto.s3.connect_to_region("us-west-1")
bucket = conn.create_bucket("foobar")
@ -44,7 +44,7 @@ def test_lifecycle_with_glacier_transition():
transition.date.should.equal(None)
@mock_s3
@mock_s3_deprecated
def test_lifecycle_multi():
conn = boto.s3.connect_to_region("us-west-1")
bucket = conn.create_bucket("foobar")
@ -86,7 +86,7 @@ def test_lifecycle_multi():
assert False, "Invalid rule id"
@mock_s3
@mock_s3_deprecated
def test_lifecycle_delete():
conn = boto.s3.connect_to_region("us-west-1")
bucket = conn.create_bucket("foobar")

View file

@ -12,7 +12,7 @@ import requests
import sure # noqa
from moto import mock_s3bucket_path
from moto import mock_s3, mock_s3_deprecated
def create_connection(key=None, secret=None):
@ -32,7 +32,7 @@ class MyModel(object):
k.set_contents_from_string(self.value)
@mock_s3bucket_path
@mock_s3_deprecated
def test_my_model_save():
# Create Bucket so that test can run
conn = create_connection('the_key', 'the_secret')
@ -45,14 +45,14 @@ def test_my_model_save():
conn.get_bucket('mybucket').get_key('steve').get_contents_as_string().should.equal(b'is awesome')
@mock_s3bucket_path
@mock_s3_deprecated
def test_missing_key():
conn = create_connection('the_key', 'the_secret')
bucket = conn.create_bucket("foobar")
bucket.get_key("the-key").should.equal(None)
@mock_s3bucket_path
@mock_s3_deprecated
def test_missing_key_urllib2():
conn = create_connection('the_key', 'the_secret')
conn.create_bucket("foobar")
@ -60,7 +60,7 @@ def test_missing_key_urllib2():
urlopen.when.called_with("http://s3.amazonaws.com/foobar/the-key").should.throw(HTTPError)
@mock_s3bucket_path
@mock_s3_deprecated
def test_empty_key():
conn = create_connection('the_key', 'the_secret')
bucket = conn.create_bucket("foobar")
@ -71,7 +71,7 @@ def test_empty_key():
bucket.get_key("the-key").get_contents_as_string().should.equal(b'')
@mock_s3bucket_path
@mock_s3_deprecated
def test_empty_key_set_on_existing_key():
conn = create_connection('the_key', 'the_secret')
bucket = conn.create_bucket("foobar")
@ -85,7 +85,7 @@ def test_empty_key_set_on_existing_key():
bucket.get_key("the-key").get_contents_as_string().should.equal(b'')
@mock_s3bucket_path
@mock_s3_deprecated
def test_large_key_save():
conn = create_connection('the_key', 'the_secret')
bucket = conn.create_bucket("foobar")
@ -96,7 +96,7 @@ def test_large_key_save():
bucket.get_key("the-key").get_contents_as_string().should.equal(b'foobar' * 100000)
@mock_s3bucket_path
@mock_s3_deprecated
def test_copy_key():
conn = create_connection('the_key', 'the_secret')
bucket = conn.create_bucket("foobar")
@ -110,7 +110,7 @@ def test_copy_key():
bucket.get_key("new-key").get_contents_as_string().should.equal(b"some value")
@mock_s3bucket_path
@mock_s3_deprecated
def test_set_metadata():
conn = create_connection('the_key', 'the_secret')
bucket = conn.create_bucket("foobar")
@ -123,7 +123,7 @@ def test_set_metadata():
@freeze_time("2012-01-01 12:00:00")
@mock_s3bucket_path
@mock_s3_deprecated
def test_last_modified():
# See https://github.com/boto/boto/issues/466
conn = create_connection()
@ -138,19 +138,19 @@ def test_last_modified():
bucket.get_key("the-key").last_modified.should.equal('Sun, 01 Jan 2012 12:00:00 GMT')
@mock_s3bucket_path
@mock_s3_deprecated
def test_missing_bucket():
conn = create_connection('the_key', 'the_secret')
conn.get_bucket.when.called_with('mybucket').should.throw(S3ResponseError)
@mock_s3bucket_path
@mock_s3_deprecated
def test_bucket_with_dash():
conn = create_connection('the_key', 'the_secret')
conn.get_bucket.when.called_with('mybucket-test').should.throw(S3ResponseError)
@mock_s3bucket_path
@mock_s3_deprecated
def test_bucket_deletion():
conn = create_connection('the_key', 'the_secret')
bucket = conn.create_bucket("foobar")
@ -172,7 +172,7 @@ def test_bucket_deletion():
conn.delete_bucket.when.called_with("foobar").should.throw(S3ResponseError)
@mock_s3bucket_path
@mock_s3_deprecated
def test_get_all_buckets():
conn = create_connection('the_key', 'the_secret')
conn.create_bucket("foobar")
@ -182,7 +182,8 @@ def test_get_all_buckets():
buckets.should.have.length_of(2)
@mock_s3bucket_path
@mock_s3
@mock_s3_deprecated
def test_post_to_bucket():
conn = create_connection('the_key', 'the_secret')
bucket = conn.create_bucket("foobar")
@ -195,7 +196,8 @@ def test_post_to_bucket():
bucket.get_key('the-key').get_contents_as_string().should.equal(b'nothing')
@mock_s3bucket_path
@mock_s3
@mock_s3_deprecated
def test_post_with_metadata_to_bucket():
conn = create_connection('the_key', 'the_secret')
bucket = conn.create_bucket("foobar")
@ -209,17 +211,17 @@ def test_post_with_metadata_to_bucket():
bucket.get_key('the-key').get_metadata('test').should.equal('metadata')
@mock_s3bucket_path
@mock_s3
def test_bucket_method_not_implemented():
requests.patch.when.called_with("https://s3.amazonaws.com/foobar").should.throw(NotImplementedError)
@mock_s3bucket_path
@mock_s3
def test_key_method_not_implemented():
requests.post.when.called_with("https://s3.amazonaws.com/foobar/foo").should.throw(NotImplementedError)
@mock_s3bucket_path
@mock_s3_deprecated
def test_bucket_name_with_dot():
conn = create_connection()
bucket = conn.create_bucket('firstname.lastname')
@ -228,7 +230,7 @@ def test_bucket_name_with_dot():
k.set_contents_from_string('somedata')
@mock_s3bucket_path
@mock_s3_deprecated
def test_key_with_special_characters():
conn = create_connection()
bucket = conn.create_bucket('test_bucket_name')
@ -241,7 +243,7 @@ def test_key_with_special_characters():
keys[0].name.should.equal("test_list_keys_2/*x+?^@~!y")
@mock_s3bucket_path
@mock_s3_deprecated
def test_bucket_key_listing_order():
conn = create_connection()
bucket = conn.create_bucket('test_bucket')
@ -283,7 +285,7 @@ def test_bucket_key_listing_order():
keys.should.equal(['toplevel/x/'])
@mock_s3bucket_path
@mock_s3_deprecated
def test_delete_keys():
conn = create_connection()
bucket = conn.create_bucket('foobar')
@ -301,7 +303,7 @@ def test_delete_keys():
keys[0].name.should.equal('file1')
@mock_s3bucket_path
@mock_s3_deprecated
def test_delete_keys_with_invalid():
conn = create_connection()
bucket = conn.create_bucket('foobar')

View file

@ -3,7 +3,7 @@ from __future__ import unicode_literals
import boto
from boto.s3.connection import OrdinaryCallingFormat
from moto import mock_s3bucket_path, mock_s3
from moto import mock_s3_deprecated
def create_connection(key=None, secret=None):
@ -11,12 +11,12 @@ def create_connection(key=None, secret=None):
def test_bucketpath_combo_serial():
@mock_s3bucket_path
@mock_s3_deprecated
def make_bucket_path():
conn = create_connection()
conn.create_bucket('mybucketpath')
@mock_s3
@mock_s3_deprecated
def make_bucket():
conn = boto.connect_s3('the_key', 'the_secret')
conn.create_bucket('mybucket')

View file

@ -6,10 +6,10 @@ from boto.exception import BotoServerError
import sure # noqa
from moto import mock_ses
from moto import mock_ses_deprecated
@mock_ses
@mock_ses_deprecated
def test_verify_email_identity():
conn = boto.connect_ses('the_key', 'the_secret')
conn.verify_email_identity("test@example.com")
@ -19,7 +19,7 @@ def test_verify_email_identity():
address.should.equal('test@example.com')
@mock_ses
@mock_ses_deprecated
def test_domain_verify():
conn = boto.connect_ses('the_key', 'the_secret')
@ -31,7 +31,7 @@ def test_domain_verify():
domains.should.equal(['domain1.com', 'domain2.com'])
@mock_ses
@mock_ses_deprecated
def test_delete_identity():
conn = boto.connect_ses('the_key', 'the_secret')
conn.verify_email_identity("test@example.com")
@ -41,7 +41,7 @@ def test_delete_identity():
conn.list_identities()['ListIdentitiesResponse']['ListIdentitiesResult']['Identities'].should.have.length_of(0)
@mock_ses
@mock_ses_deprecated
def test_send_email():
conn = boto.connect_ses('the_key', 'the_secret')
@ -56,7 +56,7 @@ def test_send_email():
sent_count = int(send_quota['GetSendQuotaResponse']['GetSendQuotaResult']['SentLast24Hours'])
sent_count.should.equal(1)
@mock_ses
@mock_ses_deprecated
def test_send_html_email():
conn = boto.connect_ses('the_key', 'the_secret')
@ -71,7 +71,7 @@ def test_send_html_email():
sent_count = int(send_quota['GetSendQuotaResponse']['GetSendQuotaResult']['SentLast24Hours'])
sent_count.should.equal(1)
@mock_ses
@mock_ses_deprecated
def test_send_raw_email():
conn = boto.connect_ses('the_key', 'the_secret')

View file

@ -2,11 +2,11 @@ from __future__ import unicode_literals
import boto
from boto.exception import BotoServerError
from moto import mock_sns
from moto import mock_sns_deprecated
import sure # noqa
@mock_sns
@mock_sns_deprecated
def test_create_platform_application():
conn = boto.connect_sns()
platform_application = conn.create_platform_application(
@ -21,7 +21,7 @@ def test_create_platform_application():
application_arn.should.equal('arn:aws:sns:us-east-1:123456789012:app/APNS/my-application')
@mock_sns
@mock_sns_deprecated
def test_get_platform_application_attributes():
conn = boto.connect_sns()
platform_application = conn.create_platform_application(
@ -40,13 +40,13 @@ def test_get_platform_application_attributes():
})
@mock_sns
@mock_sns_deprecated
def test_get_missing_platform_application_attributes():
conn = boto.connect_sns()
conn.get_platform_application_attributes.when.called_with("a-fake-arn").should.throw(BotoServerError)
@mock_sns
@mock_sns_deprecated
def test_set_platform_application_attributes():
conn = boto.connect_sns()
platform_application = conn.create_platform_application(
@ -68,7 +68,7 @@ def test_set_platform_application_attributes():
})
@mock_sns
@mock_sns_deprecated
def test_list_platform_applications():
conn = boto.connect_sns()
conn.create_platform_application(
@ -85,7 +85,7 @@ def test_list_platform_applications():
applications.should.have.length_of(2)
@mock_sns
@mock_sns_deprecated
def test_delete_platform_application():
conn = boto.connect_sns()
conn.create_platform_application(
@ -109,7 +109,7 @@ def test_delete_platform_application():
applications.should.have.length_of(1)
@mock_sns
@mock_sns_deprecated
def test_create_platform_endpoint():
conn = boto.connect_sns()
platform_application = conn.create_platform_application(
@ -131,7 +131,7 @@ def test_create_platform_endpoint():
endpoint_arn.should.contain("arn:aws:sns:us-east-1:123456789012:endpoint/APNS/my-application/")
@mock_sns
@mock_sns_deprecated
def test_get_list_endpoints_by_platform_application():
conn = boto.connect_sns()
platform_application = conn.create_platform_application(
@ -159,7 +159,7 @@ def test_get_list_endpoints_by_platform_application():
endpoint_list[0]['EndpointArn'].should.equal(endpoint_arn)
@mock_sns
@mock_sns_deprecated
def test_get_endpoint_attributes():
conn = boto.connect_sns()
platform_application = conn.create_platform_application(
@ -187,13 +187,13 @@ def test_get_endpoint_attributes():
})
@mock_sns
@mock_sns_deprecated
def test_get_missing_endpoint_attributes():
conn = boto.connect_sns()
conn.get_endpoint_attributes.when.called_with("a-fake-arn").should.throw(BotoServerError)
@mock_sns
@mock_sns_deprecated
def test_set_endpoint_attributes():
conn = boto.connect_sns()
platform_application = conn.create_platform_application(
@ -224,7 +224,7 @@ def test_set_endpoint_attributes():
})
@mock_sns
@mock_sns_deprecated
def test_delete_endpoint():
conn = boto.connect_sns()
platform_application = conn.create_platform_application(
@ -258,7 +258,7 @@ def test_delete_endpoint():
endpoint_list.should.have.length_of(0)
@mock_sns
@mock_sns_deprecated
def test_publish_to_platform_endpoint():
conn = boto.connect_sns()
platform_application = conn.create_platform_application(

View file

@ -3,14 +3,14 @@ from six.moves.urllib.parse import parse_qs
import boto
from freezegun import freeze_time
import httpretty
import sure # noqa
from moto import mock_sns, mock_sqs
from moto.packages.responses import responses
from moto import mock_sns, mock_sns_deprecated, mock_sqs_deprecated
@mock_sqs
@mock_sns
@mock_sqs_deprecated
@mock_sns_deprecated
def test_publish_to_sqs():
conn = boto.connect_sns()
conn.create_topic("some-topic")
@ -29,8 +29,8 @@ def test_publish_to_sqs():
message.get_body().should.equal('my message')
@mock_sqs
@mock_sns
@mock_sqs_deprecated
@mock_sns_deprecated
def test_publish_to_sqs_in_different_region():
conn = boto.sns.connect_to_region("us-west-1")
conn.create_topic("some-topic")
@ -51,10 +51,11 @@ def test_publish_to_sqs_in_different_region():
@freeze_time("2013-01-01")
@mock_sns
@mock_sns_deprecated
def test_publish_to_http():
httpretty.HTTPretty.register_uri(
responses.add(
method="POST",
uri="http://example.com/foobar",
url="http://example.com/foobar",
)
conn = boto.connect_sns()
@ -67,7 +68,7 @@ def test_publish_to_http():
response = conn.publish(topic=topic_arn, message="my message", subject="my subject")
message_id = response['PublishResponse']['PublishResult']['MessageId']
last_request = httpretty.last_request()
last_request = responses.calls[-1].request
last_request.method.should.equal("POST")
parse_qs(last_request.body.decode('utf-8')).should.equal({
"Type": ["Notification"],
@ -81,3 +82,5 @@ def test_publish_to_http():
"SigningCertURL": ["https://sns.us-east-1.amazonaws.com/SimpleNotificationService-f3ecfb7224c7233fe7bb5f59f96de52f.pem"],
"UnsubscribeURL": ["https://sns.us-east-1.amazonaws.com/?Action=Unsubscribe&SubscriptionArn=arn:aws:sns:us-east-1:123456789012:some-topic:2bcfbf39-05c3-41de-beaa-fcfcc21c8f55"],
})

View file

@ -3,9 +3,9 @@ from six.moves.urllib.parse import parse_qs
import boto3
from freezegun import freeze_time
import httpretty
import sure # noqa
from moto.packages.responses import responses
from moto import mock_sns, mock_sqs
@ -56,9 +56,9 @@ def test_publish_to_sqs_in_different_region():
@freeze_time("2013-01-01")
@mock_sns
def test_publish_to_http():
httpretty.HTTPretty.register_uri(
responses.add(
method="POST",
uri="http://example.com/foobar",
url="http://example.com/foobar",
)
conn = boto3.client('sns', region_name='us-east-1')
@ -73,7 +73,7 @@ def test_publish_to_http():
response = conn.publish(TopicArn=topic_arn, Message="my message", Subject="my subject")
message_id = response['MessageId']
last_request = httpretty.last_request()
last_request = responses.calls[-2].request
last_request.method.should.equal("POST")
parse_qs(last_request.body.decode('utf-8')).should.equal({
"Type": ["Notification"],

View file

@ -3,11 +3,11 @@ import boto
import sure # noqa
from moto import mock_sns
from moto import mock_sns_deprecated
from moto.sns.models import DEFAULT_PAGE_SIZE
@mock_sns
@mock_sns_deprecated
def test_creating_subscription():
conn = boto.connect_sns()
conn.create_topic("some-topic")
@ -32,7 +32,7 @@ def test_creating_subscription():
subscriptions.should.have.length_of(0)
@mock_sns
@mock_sns_deprecated
def test_getting_subscriptions_by_topic():
conn = boto.connect_sns()
conn.create_topic("topic1")
@ -51,7 +51,7 @@ def test_getting_subscriptions_by_topic():
topic1_subscriptions[0]['Endpoint'].should.equal("http://example1.com/")
@mock_sns
@mock_sns_deprecated
def test_subscription_paging():
conn = boto.connect_sns()
conn.create_topic("topic1")

View file

@ -5,11 +5,11 @@ import six
import sure # noqa
from boto.exception import BotoServerError
from moto import mock_sns
from moto import mock_sns_deprecated
from moto.sns.models import DEFAULT_TOPIC_POLICY, DEFAULT_EFFECTIVE_DELIVERY_POLICY, DEFAULT_PAGE_SIZE
@mock_sns
@mock_sns_deprecated
def test_create_and_delete_topic():
conn = boto.connect_sns()
conn.create_topic("some-topic")
@ -31,20 +31,20 @@ def test_create_and_delete_topic():
topics.should.have.length_of(0)
@mock_sns
@mock_sns_deprecated
def test_get_missing_topic():
conn = boto.connect_sns()
conn.get_topic_attributes.when.called_with("a-fake-arn").should.throw(BotoServerError)
@mock_sns
@mock_sns_deprecated
def test_create_topic_in_multiple_regions():
for region in ['us-west-1', 'us-west-2']:
conn = boto.sns.connect_to_region(region)
conn.create_topic("some-topic")
list(conn.get_all_topics()["ListTopicsResponse"]["ListTopicsResult"]["Topics"]).should.have.length_of(1)
@mock_sns
@mock_sns_deprecated
def test_topic_corresponds_to_region():
for region in ['us-east-1', 'us-west-2']:
conn = boto.sns.connect_to_region(region)
@ -53,7 +53,7 @@ def test_topic_corresponds_to_region():
topic_arn = topics_json["ListTopicsResponse"]["ListTopicsResult"]["Topics"][0]['TopicArn']
topic_arn.should.equal("arn:aws:sns:{0}:123456789012:some-topic".format(region))
@mock_sns
@mock_sns_deprecated
def test_topic_attributes():
conn = boto.connect_sns()
conn.create_topic("some-topic")
@ -95,7 +95,7 @@ def test_topic_attributes():
attributes["DisplayName"].should.equal("My display name")
attributes["DeliveryPolicy"].should.equal("{'http': {'defaultHealthyRetryPolicy': {'numRetries': 5}}}")
@mock_sns
@mock_sns_deprecated
def test_topic_paging():
conn = boto.connect_sns()
for index in range(DEFAULT_PAGE_SIZE + int(DEFAULT_PAGE_SIZE / 2)):

View file

@ -10,16 +10,15 @@ import requests
import sure # noqa
import time
from moto import mock_sqs
from moto import mock_sqs, mock_sqs_deprecated
from tests.helpers import requires_boto_gte
import tests.backport_assert_raises # noqa
from nose.tools import assert_raises
sqs = boto3.resource('sqs', region_name='us-east-1')
@mock_sqs
def test_create_queue():
sqs = boto3.resource('sqs', region_name='us-east-1')
new_queue = sqs.create_queue(QueueName='test-queue')
new_queue.should_not.be.none
new_queue.should.have.property('url').should.contain('test-queue')
@ -34,11 +33,13 @@ def test_create_queue():
@mock_sqs
def test_get_inexistent_queue():
sqs = boto3.resource('sqs', region_name='us-east-1')
sqs.get_queue_by_name.when.called_with(QueueName='nonexisting-queue').should.throw(botocore.exceptions.ClientError)
@mock_sqs
def test_message_send():
sqs = boto3.resource('sqs', region_name='us-east-1')
queue = sqs.create_queue(QueueName="blah")
msg = queue.send_message(MessageBody="derp")
@ -52,6 +53,8 @@ def test_message_send():
@mock_sqs
def test_set_queue_attributes():
sqs = boto3.resource('sqs', region_name='us-east-1')
conn = boto3.client('sqs', region_name='us-west-1')
queue = sqs.create_queue(QueueName="blah")
queue.attributes['VisibilityTimeout'].should.equal("30")
@ -90,6 +93,7 @@ def test_get_queue_with_prefix():
@mock_sqs
def test_delete_queue():
sqs = boto3.resource('sqs', region_name='us-east-1')
conn = boto3.client("sqs", region_name='us-east-1')
conn.create_queue(QueueName="test-queue", Attributes={"VisibilityTimeout": "60"})
queue = sqs.Queue('test-queue')
@ -105,6 +109,7 @@ def test_delete_queue():
@mock_sqs
def test_set_queue_attribute():
sqs = boto3.resource('sqs', region_name='us-east-1')
conn = boto3.client("sqs", region_name='us-east-1')
conn.create_queue(QueueName="test-queue", Attributes={"VisibilityTimeout": '60'})
@ -118,6 +123,7 @@ def test_set_queue_attribute():
@mock_sqs
def test_send_message():
sqs = boto3.resource('sqs', region_name='us-east-1')
conn = boto3.client("sqs", region_name='us-east-1')
conn.create_queue(QueueName="test-queue")
queue = sqs.Queue("test-queue")
@ -134,7 +140,7 @@ def test_send_message():
messages[1]['Body'].should.equal(body_two)
@mock_sqs
@mock_sqs_deprecated
def test_send_message_with_xml_characters():
conn = boto.connect_sqs('the_key', 'the_secret')
queue = conn.create_queue("test-queue", visibility_timeout=60)
@ -150,7 +156,7 @@ def test_send_message_with_xml_characters():
@requires_boto_gte("2.28")
@mock_sqs
@mock_sqs_deprecated
def test_send_message_with_attributes():
conn = boto.connect_sqs('the_key', 'the_secret')
queue = conn.create_queue("test-queue", visibility_timeout=60)
@ -175,7 +181,7 @@ def test_send_message_with_attributes():
dict(messages[0].message_attributes[name]).should.equal(value)
@mock_sqs
@mock_sqs_deprecated
def test_send_message_with_delay():
conn = boto.connect_sqs('the_key', 'the_secret')
queue = conn.create_queue("test-queue", visibility_timeout=60)
@ -196,7 +202,7 @@ def test_send_message_with_delay():
queue.count().should.equal(0)
@mock_sqs
@mock_sqs_deprecated
def test_send_large_message_fails():
conn = boto.connect_sqs('the_key', 'the_secret')
queue = conn.create_queue("test-queue", visibility_timeout=60)
@ -208,7 +214,7 @@ def test_send_large_message_fails():
queue.write.when.called_with(huge_message).should.throw(SQSError)
@mock_sqs
@mock_sqs_deprecated
def test_message_becomes_inflight_when_received():
conn = boto.connect_sqs('the_key', 'the_secret')
queue = conn.create_queue("test-queue", visibility_timeout=2)
@ -229,7 +235,7 @@ def test_message_becomes_inflight_when_received():
queue.count().should.equal(1)
@mock_sqs
@mock_sqs_deprecated
def test_receive_message_with_explicit_visibility_timeout():
conn = boto.connect_sqs('the_key', 'the_secret')
queue = conn.create_queue("test-queue", visibility_timeout=60)
@ -246,7 +252,7 @@ def test_receive_message_with_explicit_visibility_timeout():
# Message should remain visible
queue.count().should.equal(1)
@mock_sqs
@mock_sqs_deprecated
def test_change_message_visibility():
conn = boto.connect_sqs('the_key', 'the_secret')
queue = conn.create_queue("test-queue", visibility_timeout=2)
@ -280,7 +286,7 @@ def test_change_message_visibility():
queue.count().should.equal(0)
@mock_sqs
@mock_sqs_deprecated
def test_message_attributes():
conn = boto.connect_sqs('the_key', 'the_secret')
queue = conn.create_queue("test-queue", visibility_timeout=2)
@ -304,7 +310,7 @@ def test_message_attributes():
assert message_attributes.get('SenderId')
@mock_sqs
@mock_sqs_deprecated
def test_read_message_from_queue():
conn = boto.connect_sqs()
queue = conn.create_queue('testqueue')
@ -316,7 +322,7 @@ def test_read_message_from_queue():
message.get_body().should.equal(body)
@mock_sqs
@mock_sqs_deprecated
def test_queue_length():
conn = boto.connect_sqs('the_key', 'the_secret')
queue = conn.create_queue("test-queue", visibility_timeout=60)
@ -327,7 +333,7 @@ def test_queue_length():
queue.count().should.equal(2)
@mock_sqs
@mock_sqs_deprecated
def test_delete_message():
conn = boto.connect_sqs('the_key', 'the_secret')
queue = conn.create_queue("test-queue", visibility_timeout=60)
@ -348,7 +354,7 @@ def test_delete_message():
queue.count().should.equal(0)
@mock_sqs
@mock_sqs_deprecated
def test_send_batch_operation():
conn = boto.connect_sqs('the_key', 'the_secret')
queue = conn.create_queue("test-queue", visibility_timeout=60)
@ -370,7 +376,7 @@ def test_send_batch_operation():
@requires_boto_gte("2.28")
@mock_sqs
@mock_sqs_deprecated
def test_send_batch_operation_with_message_attributes():
conn = boto.connect_sqs('the_key', 'the_secret')
queue = conn.create_queue("test-queue", visibility_timeout=60)
@ -386,7 +392,7 @@ def test_send_batch_operation_with_message_attributes():
dict(messages[0].message_attributes[name]).should.equal(value)
@mock_sqs
@mock_sqs_deprecated
def test_delete_batch_operation():
conn = boto.connect_sqs('the_key', 'the_secret')
queue = conn.create_queue("test-queue", visibility_timeout=60)
@ -408,7 +414,7 @@ def test_sqs_method_not_implemented():
requests.post.when.called_with("https://sqs.amazonaws.com/?Action=[foobar]").should.throw(NotImplementedError)
@mock_sqs
@mock_sqs_deprecated
def test_queue_attributes():
conn = boto.connect_sqs('the_key', 'the_secret')
@ -438,7 +444,7 @@ def test_queue_attributes():
attribute_names.should.contain('QueueArn')
@mock_sqs
@mock_sqs_deprecated
def test_change_message_visibility_on_invalid_receipt():
conn = boto.connect_sqs('the_key', 'the_secret')
queue = conn.create_queue("test-queue", visibility_timeout=1)
@ -465,7 +471,7 @@ def test_change_message_visibility_on_invalid_receipt():
original_message.change_visibility.when.called_with(100).should.throw(SQSError)
@mock_sqs
@mock_sqs_deprecated
def test_change_message_visibility_on_visible_message():
conn = boto.connect_sqs('the_key', 'the_secret')
queue = conn.create_queue("test-queue", visibility_timeout=1)
@ -488,7 +494,7 @@ def test_change_message_visibility_on_visible_message():
original_message.change_visibility.when.called_with(100).should.throw(SQSError)
@mock_sqs
@mock_sqs_deprecated
def test_purge_action():
conn = boto.sqs.connect_to_region("us-east-1")
@ -501,7 +507,7 @@ def test_purge_action():
queue.count().should.equal(0)
@mock_sqs
@mock_sqs_deprecated
def test_delete_message_after_visibility_timeout():
VISIBILITY_TIMEOUT = 1
conn = boto.sqs.connect_to_region("us-east-1")

View file

@ -6,11 +6,11 @@ import boto3
from freezegun import freeze_time
import sure # noqa
from moto import mock_sts
from moto import mock_sts, mock_sts_deprecated
@freeze_time("2012-01-01 12:00:00")
@mock_sts
@mock_sts_deprecated
def test_get_session_token():
conn = boto.connect_sts()
token = conn.get_session_token(duration=123)
@ -22,7 +22,7 @@ def test_get_session_token():
@freeze_time("2012-01-01 12:00:00")
@mock_sts
@mock_sts_deprecated
def test_get_federation_token():
conn = boto.connect_sts()
token = conn.get_federation_token(duration=123, name="Bob")
@ -36,7 +36,7 @@ def test_get_federation_token():
@freeze_time("2012-01-01 12:00:00")
@mock_sts
@mock_sts_deprecated
def test_assume_role():
conn = boto.connect_sts()

View file

@ -1,14 +1,14 @@
from boto.swf.exceptions import SWFResponseError
from freezegun import freeze_time
from moto import mock_swf
from moto import mock_swf_deprecated
from moto.swf import swf_backend
from ..utils import setup_workflow, SCHEDULE_ACTIVITY_TASK_DECISION
# PollForActivityTask endpoint
@mock_swf
@mock_swf_deprecated
def test_poll_for_activity_task_when_one():
conn = setup_workflow()
decision_token = conn.poll_for_decision_task("test-domain", "queue")["taskToken"]
@ -26,14 +26,14 @@ def test_poll_for_activity_task_when_one():
)
@mock_swf
@mock_swf_deprecated
def test_poll_for_activity_task_when_none():
conn = setup_workflow()
resp = conn.poll_for_activity_task("test-domain", "activity-task-list")
resp.should.equal({"startedEventId": 0})
@mock_swf
@mock_swf_deprecated
def test_poll_for_activity_task_on_non_existent_queue():
conn = setup_workflow()
resp = conn.poll_for_activity_task("test-domain", "non-existent-queue")
@ -41,7 +41,7 @@ def test_poll_for_activity_task_on_non_existent_queue():
# CountPendingActivityTasks endpoint
@mock_swf
@mock_swf_deprecated
def test_count_pending_activity_tasks():
conn = setup_workflow()
decision_token = conn.poll_for_decision_task("test-domain", "queue")["taskToken"]
@ -53,7 +53,7 @@ def test_count_pending_activity_tasks():
resp.should.equal({"count": 1, "truncated": False})
@mock_swf
@mock_swf_deprecated
def test_count_pending_decision_tasks_on_non_existent_task_list():
conn = setup_workflow()
resp = conn.count_pending_activity_tasks("test-domain", "non-existent")
@ -61,7 +61,7 @@ def test_count_pending_decision_tasks_on_non_existent_task_list():
# RespondActivityTaskCompleted endpoint
@mock_swf
@mock_swf_deprecated
def test_respond_activity_task_completed():
conn = setup_workflow()
decision_token = conn.poll_for_decision_task("test-domain", "queue")["taskToken"]
@ -80,7 +80,7 @@ def test_respond_activity_task_completed():
)
@mock_swf
@mock_swf_deprecated
def test_respond_activity_task_completed_on_closed_workflow_execution():
conn = setup_workflow()
decision_token = conn.poll_for_decision_task("test-domain", "queue")["taskToken"]
@ -99,7 +99,7 @@ def test_respond_activity_task_completed_on_closed_workflow_execution():
).should.throw(SWFResponseError, "WorkflowExecution=")
@mock_swf
@mock_swf_deprecated
def test_respond_activity_task_completed_with_task_already_completed():
conn = setup_workflow()
decision_token = conn.poll_for_decision_task("test-domain", "queue")["taskToken"]
@ -116,7 +116,7 @@ def test_respond_activity_task_completed_with_task_already_completed():
# RespondActivityTaskFailed endpoint
@mock_swf
@mock_swf_deprecated
def test_respond_activity_task_failed():
conn = setup_workflow()
decision_token = conn.poll_for_decision_task("test-domain", "queue")["taskToken"]
@ -138,7 +138,7 @@ def test_respond_activity_task_failed():
)
@mock_swf
@mock_swf_deprecated
def test_respond_activity_task_completed_with_wrong_token():
# NB: we just test ONE failure case for RespondActivityTaskFailed
# because the safeguards are shared with RespondActivityTaskCompleted, so
@ -155,7 +155,7 @@ def test_respond_activity_task_completed_with_wrong_token():
# RecordActivityTaskHeartbeat endpoint
@mock_swf
@mock_swf_deprecated
def test_record_activity_task_heartbeat():
conn = setup_workflow()
decision_token = conn.poll_for_decision_task("test-domain", "queue")["taskToken"]
@ -168,7 +168,7 @@ def test_record_activity_task_heartbeat():
resp.should.equal({"cancelRequested": False})
@mock_swf
@mock_swf_deprecated
def test_record_activity_task_heartbeat_with_wrong_token():
conn = setup_workflow()
decision_token = conn.poll_for_decision_task("test-domain", "queue")["taskToken"]
@ -182,7 +182,7 @@ def test_record_activity_task_heartbeat_with_wrong_token():
).should.throw(SWFResponseError)
@mock_swf
@mock_swf_deprecated
def test_record_activity_task_heartbeat_sets_details_in_case_of_timeout():
conn = setup_workflow()
decision_token = conn.poll_for_decision_task("test-domain", "queue")["taskToken"]

View file

@ -1,11 +1,11 @@
import boto
from boto.swf.exceptions import SWFResponseError
from moto import mock_swf
from moto import mock_swf_deprecated
# RegisterActivityType endpoint
@mock_swf
@mock_swf_deprecated
def test_register_activity_type():
conn = boto.connect_swf("the_key", "the_secret")
conn.register_domain("test-domain", "60")
@ -17,7 +17,7 @@ def test_register_activity_type():
actype["activityType"]["version"].should.equal("v1.0")
@mock_swf
@mock_swf_deprecated
def test_register_already_existing_activity_type():
conn = boto.connect_swf("the_key", "the_secret")
conn.register_domain("test-domain", "60")
@ -28,7 +28,7 @@ def test_register_already_existing_activity_type():
).should.throw(SWFResponseError)
@mock_swf
@mock_swf_deprecated
def test_register_with_wrong_parameter_type():
conn = boto.connect_swf("the_key", "the_secret")
conn.register_domain("test-domain", "60")
@ -39,7 +39,7 @@ def test_register_with_wrong_parameter_type():
# ListActivityTypes endpoint
@mock_swf
@mock_swf_deprecated
def test_list_activity_types():
conn = boto.connect_swf("the_key", "the_secret")
conn.register_domain("test-domain", "60")
@ -52,7 +52,7 @@ def test_list_activity_types():
names.should.equal(["a-test-activity", "b-test-activity", "c-test-activity"])
@mock_swf
@mock_swf_deprecated
def test_list_activity_types_reverse_order():
conn = boto.connect_swf("the_key", "the_secret")
conn.register_domain("test-domain", "60")
@ -67,7 +67,7 @@ def test_list_activity_types_reverse_order():
# DeprecateActivityType endpoint
@mock_swf
@mock_swf_deprecated
def test_deprecate_activity_type():
conn = boto.connect_swf("the_key", "the_secret")
conn.register_domain("test-domain", "60")
@ -80,7 +80,7 @@ def test_deprecate_activity_type():
actype["activityType"]["version"].should.equal("v1.0")
@mock_swf
@mock_swf_deprecated
def test_deprecate_already_deprecated_activity_type():
conn = boto.connect_swf("the_key", "the_secret")
conn.register_domain("test-domain", "60")
@ -92,7 +92,7 @@ def test_deprecate_already_deprecated_activity_type():
).should.throw(SWFResponseError)
@mock_swf
@mock_swf_deprecated
def test_deprecate_non_existent_activity_type():
conn = boto.connect_swf("the_key", "the_secret")
conn.register_domain("test-domain", "60")
@ -103,7 +103,7 @@ def test_deprecate_non_existent_activity_type():
# DescribeActivityType endpoint
@mock_swf
@mock_swf_deprecated
def test_describe_activity_type():
conn = boto.connect_swf("the_key", "the_secret")
conn.register_domain("test-domain", "60")
@ -118,7 +118,7 @@ def test_describe_activity_type():
infos["status"].should.equal("REGISTERED")
@mock_swf
@mock_swf_deprecated
def test_describe_non_existent_activity_type():
conn = boto.connect_swf("the_key", "the_secret")
conn.register_domain("test-domain", "60")

View file

@ -1,14 +1,14 @@
from boto.swf.exceptions import SWFResponseError
from freezegun import freeze_time
from moto import mock_swf
from moto import mock_swf_deprecated
from moto.swf import swf_backend
from ..utils import setup_workflow
# PollForDecisionTask endpoint
@mock_swf
@mock_swf_deprecated
def test_poll_for_decision_task_when_one():
conn = setup_workflow()
@ -23,7 +23,7 @@ def test_poll_for_decision_task_when_one():
resp["events"][-1]["decisionTaskStartedEventAttributes"]["identity"].should.equal("srv01")
@mock_swf
@mock_swf_deprecated
def test_poll_for_decision_task_when_none():
conn = setup_workflow()
conn.poll_for_decision_task("test-domain", "queue")
@ -34,14 +34,14 @@ def test_poll_for_decision_task_when_none():
resp.should.equal({"previousStartedEventId": 0, "startedEventId": 0})
@mock_swf
@mock_swf_deprecated
def test_poll_for_decision_task_on_non_existent_queue():
conn = setup_workflow()
resp = conn.poll_for_decision_task("test-domain", "non-existent-queue")
resp.should.equal({"previousStartedEventId": 0, "startedEventId": 0})
@mock_swf
@mock_swf_deprecated
def test_poll_for_decision_task_with_reverse_order():
conn = setup_workflow()
resp = conn.poll_for_decision_task("test-domain", "queue", reverse_order=True)
@ -50,7 +50,7 @@ def test_poll_for_decision_task_with_reverse_order():
# CountPendingDecisionTasks endpoint
@mock_swf
@mock_swf_deprecated
def test_count_pending_decision_tasks():
conn = setup_workflow()
conn.poll_for_decision_task("test-domain", "queue")
@ -58,14 +58,14 @@ def test_count_pending_decision_tasks():
resp.should.equal({"count": 1, "truncated": False})
@mock_swf
@mock_swf_deprecated
def test_count_pending_decision_tasks_on_non_existent_task_list():
conn = setup_workflow()
resp = conn.count_pending_decision_tasks("test-domain", "non-existent")
resp.should.equal({"count": 0, "truncated": False})
@mock_swf
@mock_swf_deprecated
def test_count_pending_decision_tasks_after_decision_completes():
conn = setup_workflow()
resp = conn.poll_for_decision_task("test-domain", "queue")
@ -76,7 +76,7 @@ def test_count_pending_decision_tasks_after_decision_completes():
# RespondDecisionTaskCompleted endpoint
@mock_swf
@mock_swf_deprecated
def test_respond_decision_task_completed_with_no_decision():
conn = setup_workflow()
@ -108,7 +108,7 @@ def test_respond_decision_task_completed_with_no_decision():
resp["latestExecutionContext"].should.equal("free-form context")
@mock_swf
@mock_swf_deprecated
def test_respond_decision_task_completed_with_wrong_token():
conn = setup_workflow()
conn.poll_for_decision_task("test-domain", "queue")
@ -117,7 +117,7 @@ def test_respond_decision_task_completed_with_wrong_token():
).should.throw(SWFResponseError)
@mock_swf
@mock_swf_deprecated
def test_respond_decision_task_completed_on_close_workflow_execution():
conn = setup_workflow()
resp = conn.poll_for_decision_task("test-domain", "queue")
@ -133,7 +133,7 @@ def test_respond_decision_task_completed_on_close_workflow_execution():
).should.throw(SWFResponseError)
@mock_swf
@mock_swf_deprecated
def test_respond_decision_task_completed_with_task_already_completed():
conn = setup_workflow()
resp = conn.poll_for_decision_task("test-domain", "queue")
@ -145,7 +145,7 @@ def test_respond_decision_task_completed_with_task_already_completed():
).should.throw(SWFResponseError)
@mock_swf
@mock_swf_deprecated
def test_respond_decision_task_completed_with_complete_workflow_execution():
conn = setup_workflow()
resp = conn.poll_for_decision_task("test-domain", "queue")
@ -170,7 +170,7 @@ def test_respond_decision_task_completed_with_complete_workflow_execution():
resp["events"][-1]["workflowExecutionCompletedEventAttributes"]["result"].should.equal("foo bar")
@mock_swf
@mock_swf_deprecated
def test_respond_decision_task_completed_with_close_decision_not_last():
conn = setup_workflow()
resp = conn.poll_for_decision_task("test-domain", "queue")
@ -186,7 +186,7 @@ def test_respond_decision_task_completed_with_close_decision_not_last():
).should.throw(SWFResponseError, r"Close must be last decision in list")
@mock_swf
@mock_swf_deprecated
def test_respond_decision_task_completed_with_invalid_decision_type():
conn = setup_workflow()
resp = conn.poll_for_decision_task("test-domain", "queue")
@ -204,7 +204,7 @@ def test_respond_decision_task_completed_with_invalid_decision_type():
)
@mock_swf
@mock_swf_deprecated
def test_respond_decision_task_completed_with_missing_attributes():
conn = setup_workflow()
resp = conn.poll_for_decision_task("test-domain", "queue")
@ -226,7 +226,7 @@ def test_respond_decision_task_completed_with_missing_attributes():
)
@mock_swf
@mock_swf_deprecated
def test_respond_decision_task_completed_with_missing_attributes_totally():
conn = setup_workflow()
resp = conn.poll_for_decision_task("test-domain", "queue")
@ -245,7 +245,7 @@ def test_respond_decision_task_completed_with_missing_attributes_totally():
)
@mock_swf
@mock_swf_deprecated
def test_respond_decision_task_completed_with_fail_workflow_execution():
conn = setup_workflow()
resp = conn.poll_for_decision_task("test-domain", "queue")
@ -272,7 +272,7 @@ def test_respond_decision_task_completed_with_fail_workflow_execution():
attrs["details"].should.equal("foo")
@mock_swf
@mock_swf_deprecated
@freeze_time("2015-01-01 12:00:00")
def test_respond_decision_task_completed_with_schedule_activity_task():
conn = setup_workflow()

View file

@ -1,11 +1,11 @@
import boto
from boto.swf.exceptions import SWFResponseError
from moto import mock_swf
from moto import mock_swf_deprecated
# RegisterDomain endpoint
@mock_swf
@mock_swf_deprecated
def test_register_domain():
conn = boto.connect_swf("the_key", "the_secret")
conn.register_domain("test-domain", "60", description="A test domain")
@ -18,7 +18,7 @@ def test_register_domain():
domain["description"].should.equal("A test domain")
@mock_swf
@mock_swf_deprecated
def test_register_already_existing_domain():
conn = boto.connect_swf("the_key", "the_secret")
conn.register_domain("test-domain", "60", description="A test domain")
@ -28,7 +28,7 @@ def test_register_already_existing_domain():
).should.throw(SWFResponseError)
@mock_swf
@mock_swf_deprecated
def test_register_with_wrong_parameter_type():
conn = boto.connect_swf("the_key", "the_secret")
@ -38,7 +38,7 @@ def test_register_with_wrong_parameter_type():
# ListDomains endpoint
@mock_swf
@mock_swf_deprecated
def test_list_domains_order():
conn = boto.connect_swf("the_key", "the_secret")
conn.register_domain("b-test-domain", "60")
@ -50,7 +50,7 @@ def test_list_domains_order():
names.should.equal(["a-test-domain", "b-test-domain", "c-test-domain"])
@mock_swf
@mock_swf_deprecated
def test_list_domains_reverse_order():
conn = boto.connect_swf("the_key", "the_secret")
conn.register_domain("b-test-domain", "60")
@ -63,7 +63,7 @@ def test_list_domains_reverse_order():
# DeprecateDomain endpoint
@mock_swf
@mock_swf_deprecated
def test_deprecate_domain():
conn = boto.connect_swf("the_key", "the_secret")
conn.register_domain("test-domain", "60", description="A test domain")
@ -75,7 +75,7 @@ def test_deprecate_domain():
domain["name"].should.equal("test-domain")
@mock_swf
@mock_swf_deprecated
def test_deprecate_already_deprecated_domain():
conn = boto.connect_swf("the_key", "the_secret")
conn.register_domain("test-domain", "60", description="A test domain")
@ -86,7 +86,7 @@ def test_deprecate_already_deprecated_domain():
).should.throw(SWFResponseError)
@mock_swf
@mock_swf_deprecated
def test_deprecate_non_existent_domain():
conn = boto.connect_swf("the_key", "the_secret")
@ -96,7 +96,7 @@ def test_deprecate_non_existent_domain():
# DescribeDomain endpoint
@mock_swf
@mock_swf_deprecated
def test_describe_domain():
conn = boto.connect_swf("the_key", "the_secret")
conn.register_domain("test-domain", "60", description="A test domain")
@ -108,7 +108,7 @@ def test_describe_domain():
domain["domainInfo"]["status"].should.equal("REGISTERED")
@mock_swf
@mock_swf_deprecated
def test_describe_non_existent_domain():
conn = boto.connect_swf("the_key", "the_secret")

View file

@ -1,13 +1,13 @@
from freezegun import freeze_time
from moto import mock_swf
from moto import mock_swf_deprecated
from ..utils import setup_workflow, SCHEDULE_ACTIVITY_TASK_DECISION
# Activity Task Heartbeat timeout
# Default value in workflow helpers: 5 mins
@mock_swf
@mock_swf_deprecated
def test_activity_task_heartbeat_timeout():
with freeze_time("2015-01-01 12:00:00"):
conn = setup_workflow()
@ -36,7 +36,7 @@ def test_activity_task_heartbeat_timeout():
# Decision Task Start to Close timeout
# Default value in workflow helpers: 5 mins
@mock_swf
@mock_swf_deprecated
def test_decision_task_start_to_close_timeout():
pass
with freeze_time("2015-01-01 12:00:00"):
@ -70,7 +70,7 @@ def test_decision_task_start_to_close_timeout():
# Workflow Execution Start to Close timeout
# Default value in workflow helpers: 2 hours
@mock_swf
@mock_swf_deprecated
def test_workflow_execution_start_to_close_timeout():
pass
with freeze_time("2015-01-01 12:00:00"):

View file

@ -6,12 +6,12 @@ import sure # noqa
# Ensure 'assert_raises' context manager support for Python 2.6
import tests.backport_assert_raises # noqa
from moto import mock_swf
from moto import mock_swf_deprecated
from moto.core.utils import unix_time
# Utils
@mock_swf
@mock_swf_deprecated
def setup_swf_environment():
conn = boto.connect_swf("the_key", "the_secret")
conn.register_domain("test-domain", "60", description="A test domain")
@ -26,7 +26,7 @@ def setup_swf_environment():
# StartWorkflowExecution endpoint
@mock_swf
@mock_swf_deprecated
def test_start_workflow_execution():
conn = setup_swf_environment()
@ -34,7 +34,7 @@ def test_start_workflow_execution():
wf.should.contain("runId")
@mock_swf
@mock_swf_deprecated
def test_start_already_started_workflow_execution():
conn = setup_swf_environment()
conn.start_workflow_execution("test-domain", "uid-abcd1234", "test-workflow", "v1.0")
@ -44,7 +44,7 @@ def test_start_already_started_workflow_execution():
).should.throw(SWFResponseError)
@mock_swf
@mock_swf_deprecated
def test_start_workflow_execution_on_deprecated_type():
conn = setup_swf_environment()
conn.deprecate_workflow_type("test-domain", "test-workflow", "v1.0")
@ -55,7 +55,7 @@ def test_start_workflow_execution_on_deprecated_type():
# DescribeWorkflowExecution endpoint
@mock_swf
@mock_swf_deprecated
def test_describe_workflow_execution():
conn = setup_swf_environment()
hsh = conn.start_workflow_execution("test-domain", "uid-abcd1234", "test-workflow", "v1.0")
@ -66,7 +66,7 @@ def test_describe_workflow_execution():
wfe["executionInfo"]["executionStatus"].should.equal("OPEN")
@mock_swf
@mock_swf_deprecated
def test_describe_non_existent_workflow_execution():
conn = setup_swf_environment()
@ -76,7 +76,7 @@ def test_describe_non_existent_workflow_execution():
# GetWorkflowExecutionHistory endpoint
@mock_swf
@mock_swf_deprecated
def test_get_workflow_execution_history():
conn = setup_swf_environment()
hsh = conn.start_workflow_execution("test-domain", "uid-abcd1234", "test-workflow", "v1.0")
@ -87,7 +87,7 @@ def test_get_workflow_execution_history():
types.should.equal(["WorkflowExecutionStarted", "DecisionTaskScheduled"])
@mock_swf
@mock_swf_deprecated
def test_get_workflow_execution_history_with_reverse_order():
conn = setup_swf_environment()
hsh = conn.start_workflow_execution("test-domain", "uid-abcd1234", "test-workflow", "v1.0")
@ -99,7 +99,7 @@ def test_get_workflow_execution_history_with_reverse_order():
types.should.equal(["DecisionTaskScheduled", "WorkflowExecutionStarted"])
@mock_swf
@mock_swf_deprecated
def test_get_workflow_execution_history_on_non_existent_workflow_execution():
conn = setup_swf_environment()
@ -109,7 +109,7 @@ def test_get_workflow_execution_history_on_non_existent_workflow_execution():
# ListOpenWorkflowExecutions endpoint
@mock_swf
@mock_swf_deprecated
def test_list_open_workflow_executions():
conn = setup_swf_environment()
# One open workflow execution
@ -143,7 +143,7 @@ def test_list_open_workflow_executions():
# ListClosedWorkflowExecutions endpoint
@mock_swf
@mock_swf_deprecated
def test_list_closed_workflow_executions():
conn = setup_swf_environment()
# Leave one workflow execution open to make sure it isn't displayed
@ -178,7 +178,7 @@ def test_list_closed_workflow_executions():
# TerminateWorkflowExecution endpoint
@mock_swf
@mock_swf_deprecated
def test_terminate_workflow_execution():
conn = setup_swf_environment()
run_id = conn.start_workflow_execution(
@ -200,7 +200,7 @@ def test_terminate_workflow_execution():
attrs["cause"].should.equal("OPERATOR_INITIATED")
@mock_swf
@mock_swf_deprecated
def test_terminate_workflow_execution_with_wrong_workflow_or_run_id():
conn = setup_swf_environment()
run_id = conn.start_workflow_execution(

View file

@ -1,11 +1,12 @@
import sure
import boto
from moto import mock_swf
from moto import mock_swf_deprecated
from boto.swf.exceptions import SWFResponseError
# RegisterWorkflowType endpoint
@mock_swf
@mock_swf_deprecated
def test_register_workflow_type():
conn = boto.connect_swf("the_key", "the_secret")
conn.register_domain("test-domain", "60")
@ -17,7 +18,7 @@ def test_register_workflow_type():
actype["workflowType"]["version"].should.equal("v1.0")
@mock_swf
@mock_swf_deprecated
def test_register_already_existing_workflow_type():
conn = boto.connect_swf("the_key", "the_secret")
conn.register_domain("test-domain", "60")
@ -28,7 +29,7 @@ def test_register_already_existing_workflow_type():
).should.throw(SWFResponseError)
@mock_swf
@mock_swf_deprecated
def test_register_with_wrong_parameter_type():
conn = boto.connect_swf("the_key", "the_secret")
conn.register_domain("test-domain", "60")
@ -39,7 +40,7 @@ def test_register_with_wrong_parameter_type():
# ListWorkflowTypes endpoint
@mock_swf
@mock_swf_deprecated
def test_list_workflow_types():
conn = boto.connect_swf("the_key", "the_secret")
conn.register_domain("test-domain", "60")
@ -52,7 +53,7 @@ def test_list_workflow_types():
names.should.equal(["a-test-workflow", "b-test-workflow", "c-test-workflow"])
@mock_swf
@mock_swf_deprecated
def test_list_workflow_types_reverse_order():
conn = boto.connect_swf("the_key", "the_secret")
conn.register_domain("test-domain", "60")
@ -67,7 +68,7 @@ def test_list_workflow_types_reverse_order():
# DeprecateWorkflowType endpoint
@mock_swf
@mock_swf_deprecated
def test_deprecate_workflow_type():
conn = boto.connect_swf("the_key", "the_secret")
conn.register_domain("test-domain", "60")
@ -80,7 +81,7 @@ def test_deprecate_workflow_type():
actype["workflowType"]["version"].should.equal("v1.0")
@mock_swf
@mock_swf_deprecated
def test_deprecate_already_deprecated_workflow_type():
conn = boto.connect_swf("the_key", "the_secret")
conn.register_domain("test-domain", "60")
@ -92,7 +93,7 @@ def test_deprecate_already_deprecated_workflow_type():
).should.throw(SWFResponseError)
@mock_swf
@mock_swf_deprecated
def test_deprecate_non_existent_workflow_type():
conn = boto.connect_swf("the_key", "the_secret")
conn.register_domain("test-domain", "60")
@ -103,7 +104,7 @@ def test_deprecate_non_existent_workflow_type():
# DescribeWorkflowType endpoint
@mock_swf
@mock_swf_deprecated
def test_describe_workflow_type():
conn = boto.connect_swf("the_key", "the_secret")
conn.register_domain("test-domain", "60")
@ -120,7 +121,7 @@ def test_describe_workflow_type():
infos["status"].should.equal("REGISTERED")
@mock_swf
@mock_swf_deprecated
def test_describe_non_existent_workflow_type():
conn = boto.connect_swf("the_key", "the_secret")
conn.register_domain("test-domain", "60")