From 37f643ecb40557d3d48d8f754b023601d63c9287 Mon Sep 17 00:00:00 2001 From: Dan Tenenbaum Date: Thu, 3 Nov 2016 14:12:20 -0700 Subject: [PATCH 1/4] bump tag limit from 10 to 50 to align with actual AWS limit --- moto/ec2/models.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/moto/ec2/models.py b/moto/ec2/models.py index 1e43dbb9e..902ebdac4 100755 --- a/moto/ec2/models.py +++ b/moto/ec2/models.py @@ -815,9 +815,9 @@ class TagBackend(object): raise InvalidParameterValueErrorTagNull() for resource_id in resource_ids: if resource_id in self.tags: - if len(self.tags[resource_id]) + len([tag for tag in tags if not tag.startswith("aws:")]) > 10: + if len(self.tags[resource_id]) + len([tag for tag in tags if not tag.startswith("aws:")]) > 50: raise TagLimitExceeded() - elif len([tag for tag in tags if not tag.startswith("aws:")]) > 10: + elif len([tag for tag in tags if not tag.startswith("aws:")]) > 50: raise TagLimitExceeded() for resource_id in resource_ids: for tag in tags: From ffa6b1d9c15fc784eba08dd6bf4e796b7392cd3f Mon Sep 17 00:00:00 2001 From: Dan Tenenbaum Date: Thu, 3 Nov 2016 14:24:47 -0700 Subject: [PATCH 2/4] should pass unit tests --- tests/test_ec2/test_tags.py | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/tests/test_ec2/test_tags.py b/tests/test_ec2/test_tags.py index a5a124eb6..034e2c01b 100644 --- a/tests/test_ec2/test_tags.py +++ b/tests/test_ec2/test_tags.py @@ -113,17 +113,9 @@ def test_tag_limit_exceeded(): conn = boto.connect_ec2('the_key', 'the_secret') reservation = conn.run_instances('ami-1234abcd') instance = reservation.instances[0] - tag_dict = {'01': '', - '02': '', - '03': '', - '04': '', - '05': '', - '06': '', - '07': '', - '08': '', - '09': '', - '10': '', - '11': ''} + tag_dict = {} + for i in range(51): + tag_dict['{:02}'.format(i)] = '' with assert_raises(EC2ResponseError) as cm: conn.create_tags(instance.id, tag_dict) From de0a7413098d9bdad795432d4a87393626d23199 Mon Sep 17 00:00:00 2001 From: Dan Tenenbaum Date: Thu, 3 Nov 2016 14:30:35 -0700 Subject: [PATCH 3/4] syntax fix --- tests/test_ec2/test_tags.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_ec2/test_tags.py b/tests/test_ec2/test_tags.py index 034e2c01b..552054d51 100644 --- a/tests/test_ec2/test_tags.py +++ b/tests/test_ec2/test_tags.py @@ -115,7 +115,7 @@ def test_tag_limit_exceeded(): instance = reservation.instances[0] tag_dict = {} for i in range(51): - tag_dict['{:02}'.format(i)] = '' + tag_dict['{:02d}'.format(i+1)] = '' with assert_raises(EC2ResponseError) as cm: conn.create_tags(instance.id, tag_dict) From ed7ea86f7bf6cb39e2edd2d02fe1e2e43f6ddf10 Mon Sep 17 00:00:00 2001 From: Dan Tenenbaum Date: Thu, 3 Nov 2016 14:42:23 -0700 Subject: [PATCH 4/4] add positional argument for python 2.6 compatiblity --- tests/test_ec2/test_tags.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_ec2/test_tags.py b/tests/test_ec2/test_tags.py index 552054d51..4a85eb6e1 100644 --- a/tests/test_ec2/test_tags.py +++ b/tests/test_ec2/test_tags.py @@ -115,7 +115,7 @@ def test_tag_limit_exceeded(): instance = reservation.instances[0] tag_dict = {} for i in range(51): - tag_dict['{:02d}'.format(i+1)] = '' + tag_dict['{0:02d}'.format(i+1)] = '' with assert_raises(EC2ResponseError) as cm: conn.create_tags(instance.id, tag_dict)