add endpoint tests for AddTags, RemoveTags and DescribeTags to test_elb.py

update sure requirement to 1.2.24
fix assert int to float compare in test_swf/responses/test_timeouts.py
This commit is contained in:
mfranke 2015-12-09 21:33:42 +01:00
parent 5d47aa8c84
commit cace459167
3 changed files with 113 additions and 5 deletions

View File

@ -1,7 +1,7 @@
-r requirements.txt -r requirements.txt
mock mock
nose nose
sure<1.2.4 sure>=1.2.24
coverage coverage
freezegun freezegun
flask flask

View File

@ -1,5 +1,6 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import boto3 import boto3
import botocore
import boto import boto
import boto.ec2.elb import boto.ec2.elb
from boto.ec2.elb import HealthCheck from boto.ec2.elb import HealthCheck
@ -18,7 +19,6 @@ import sure # noqa
from moto import mock_elb, mock_ec2 from moto import mock_elb, mock_ec2
@mock_elb @mock_elb
def test_create_load_balancer(): def test_create_load_balancer():
conn = boto.connect_elb() conn = boto.connect_elb()
@ -583,3 +583,111 @@ def test_describe_instance_health():
instances_health.should.have.length_of(1) instances_health.should.have.length_of(1)
instances_health[0].instance_id.should.equal(instance_id1) instances_health[0].instance_id.should.equal(instance_id1)
instances_health[0].state.should.equal('InService') instances_health[0].state.should.equal('InService')
@mock_elb
def test_add_remove_tags():
client = boto3.client('elb', region_name='us-east-1')
client.add_tags.when.called_with(LoadBalancerNames=['my-lb'],
Tags=[{
'Key': 'a',
'Value': 'b'
}]).should.throw(botocore.exceptions.ClientError)
client.create_load_balancer(
LoadBalancerName='my-lb',
Listeners=[{'Protocol':'tcp', 'LoadBalancerPort':80, 'InstancePort':8080}],
AvailabilityZones=['us-east-1a', 'us-east-1b']
)
list(client.describe_load_balancers()['LoadBalancerDescriptions']).should.have.length_of(1)
client.add_tags(LoadBalancerNames=['my-lb'],
Tags=[{
'Key': 'a',
'Value': 'a'
}])
tags = dict([(d['Key'], d['Value']) for d in client.describe_tags(LoadBalancerNames=['my-lb'])['TagDescriptions'][0]['Tags']])
tags.should.have('a').should.equal('a')
client.add_tags(LoadBalancerNames=['my-lb'],
Tags=[{
'Key': 'a',
'Value': 'b'
}, {
'Key': 'b',
'Value': 'b'
}, {
'Key': 'c',
'Value': 'b'
}, {
'Key': 'd',
'Value': 'b'
}, {
'Key': 'e',
'Value': 'b'
}, {
'Key': 'f',
'Value': 'b'
}, {
'Key': 'g',
'Value': 'b'
}, {
'Key': 'h',
'Value': 'b'
}, {
'Key': 'i',
'Value': 'b'
}, {
'Key': 'j',
'Value': 'b'
}])
client.add_tags.when.called_with(LoadBalancerNames=['my-lb'],
Tags=[{
'Key': 'k',
'Value': 'b'
}]).should.throw(botocore.exceptions.ClientError)
client.add_tags(LoadBalancerNames=['my-lb'],
Tags=[{
'Key': 'j',
'Value': 'c'
}])
tags = dict([(d['Key'], d['Value']) for d in client.describe_tags(LoadBalancerNames=['my-lb'])['TagDescriptions'][0]['Tags']])
tags.should.have.key('a').which.should.equal('b')
tags.should.have.key('b').which.should.equal('b')
tags.should.have.key('c').which.should.equal('b')
tags.should.have.key('d').which.should.equal('b')
tags.should.have.key('e').which.should.equal('b')
tags.should.have.key('f').which.should.equal('b')
tags.should.have.key('g').which.should.equal('b')
tags.should.have.key('h').which.should.equal('b')
tags.should.have.key('i').which.should.equal('b')
tags.should.have.key('j').which.should.equal('c')
tags.shouldnt.have.key('k')
client.remove_tags(LoadBalancerNames=['my-lb'],
Tags=[{
'Key': 'a'
}])
tags = dict([(d['Key'], d['Value']) for d in client.describe_tags(LoadBalancerNames=['my-lb'])['TagDescriptions'][0]['Tags']])
tags.shouldnt.have.key('a')
tags.should.have.key('b').which.should.equal('b')
tags.should.have.key('c').which.should.equal('b')
tags.should.have.key('d').which.should.equal('b')
tags.should.have.key('e').which.should.equal('b')
tags.should.have.key('f').which.should.equal('b')
tags.should.have.key('g').which.should.equal('b')
tags.should.have.key('h').which.should.equal('b')
tags.should.have.key('i').which.should.equal('b')
tags.should.have.key('j').which.should.equal('c')

View File

@ -31,7 +31,7 @@ def test_activity_task_heartbeat_timeout():
attrs = resp["events"][-2]["activityTaskTimedOutEventAttributes"] attrs = resp["events"][-2]["activityTaskTimedOutEventAttributes"]
attrs["timeoutType"].should.equal("HEARTBEAT") attrs["timeoutType"].should.equal("HEARTBEAT")
# checks that event has been emitted at 12:05:00, not 12:05:30 # checks that event has been emitted at 12:05:00, not 12:05:30
resp["events"][-2]["eventTimestamp"].should.equal(1420113900) resp["events"][-2]["eventTimestamp"].should.equal(1420113900.0)
resp["events"][-1]["eventType"].should.equal("DecisionTaskScheduled") resp["events"][-1]["eventType"].should.equal("DecisionTaskScheduled")
@ -66,7 +66,7 @@ def test_decision_task_start_to_close_timeout():
"scheduledEventId": 2, "startedEventId": 3, "timeoutType": "START_TO_CLOSE" "scheduledEventId": 2, "startedEventId": 3, "timeoutType": "START_TO_CLOSE"
}) })
# checks that event has been emitted at 12:05:00, not 12:05:30 # checks that event has been emitted at 12:05:00, not 12:05:30
resp["events"][-2]["eventTimestamp"].should.equal(1420113900) resp["events"][-2]["eventTimestamp"].should.equal(1420113900.0)
# Workflow Execution Start to Close timeout # Workflow Execution Start to Close timeout
# Default value in workflow helpers: 2 hours # Default value in workflow helpers: 2 hours
@ -97,4 +97,4 @@ def test_workflow_execution_start_to_close_timeout():
"childPolicy": "ABANDON", "timeoutType": "START_TO_CLOSE" "childPolicy": "ABANDON", "timeoutType": "START_TO_CLOSE"
}) })
# checks that event has been emitted at 14:00:00, not 14:00:30 # checks that event has been emitted at 14:00:00, not 14:00:30
resp["events"][-1]["eventTimestamp"].should.equal(1420120800) resp["events"][-1]["eventTimestamp"].should.equal(1420120800.0)