Permalink
Browse files

Merge pull request #2533 from avanash/develop

Fix the ec2.elb.listener.Listener class's __getitem__ method. Fixes #2533.
  • Loading branch information...
danielgtaylor committed Aug 20, 2014
2 parents c8c625a + 3997c0c commit 7b67f98e8d6c717672314d40ec63d05a5a06c662
Showing with 27 additions and 1 deletion.
  1. +3 −1 boto/ec2/elb/listener.py
  2. +24 −0 tests/unit/ec2/elb/test_listener.py
View
@@ -80,6 +80,8 @@ def __getitem__(self, key):
return self.instance_port
if key == 2:
return self.protocol
if key == 4:
if key == 3:
return self.instance_protocol
if key == 4:
return self.ssl_certificate_id
raise KeyError
@@ -4,6 +4,7 @@
import boto.resultset
from boto.ec2.elb.loadbalancer import LoadBalancer
from boto.ec2.elb.listener import Listener
LISTENERS_RESPONSE = b"""<?xml version="1.0" encoding="UTF-8"?>
@@ -96,6 +97,29 @@ def test_parse_complex(self):
]
)
class TestListenerGetItem(unittest.TestCase):
def test_getitem_for_http_listener(self):
listener = Listener(load_balancer_port=80,
instance_port=80,
protocol='HTTP',
instance_protocol='HTTP')
self.assertEqual(listener[0], 80)
self.assertEqual(listener[1], 80)
self.assertEqual(listener[2], 'HTTP')
self.assertEqual(listener[3], 'HTTP')
def test_getitem_for_https_listener(self):
listener = Listener(load_balancer_port=443,
instance_port=80,
protocol='HTTPS',
instance_protocol='HTTP',
ssl_certificate_id='look_at_me_im_an_arn')
self.assertEqual(listener[0], 443)
self.assertEqual(listener[1], 80)
self.assertEqual(listener[2], 'HTTPS')
self.assertEqual(listener[3], 'HTTP')
self.assertEqual(listener[4], 'look_at_me_im_an_arn')
if __name__ == '__main__':
unittest.main()

0 comments on commit 7b67f98

Please sign in to comment.