summaryrefslogtreecommitdiff
path: root/tests/unit/ec2/test_ec2object.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/ec2/test_ec2object.py')
-rw-r--r--tests/unit/ec2/test_ec2object.py82
1 files changed, 74 insertions, 8 deletions
diff --git a/tests/unit/ec2/test_ec2object.py b/tests/unit/ec2/test_ec2object.py
index 9b57df5f..14841e91 100644
--- a/tests/unit/ec2/test_ec2object.py
+++ b/tests/unit/ec2/test_ec2object.py
@@ -47,8 +47,8 @@ class TestAddTags(AWSMockServiceTestCase):
'Version'])
self.assertEqual(taggedEC2Object.tags, {
- "already_present_key":"already_present_value",
- "new_key":"new_value"})
+ "already_present_key": "already_present_value",
+ "new_key": "new_value"})
def test_add_tags(self):
self.set_http_response(status_code=200)
@@ -56,7 +56,7 @@ class TestAddTags(AWSMockServiceTestCase):
taggedEC2Object.id = "i-abcd1234"
taggedEC2Object.tags["already_present_key"] = "already_present_value"
- taggedEC2Object.add_tags({"key1":"value1", "key2":"value2"})
+ taggedEC2Object.add_tags({"key1": "value1", "key2": "value2"})
self.assert_request_parameters({
'ResourceId.1': 'i-abcd1234',
@@ -70,8 +70,8 @@ class TestAddTags(AWSMockServiceTestCase):
'Version'])
self.assertEqual(taggedEC2Object.tags, {
- "already_present_key":"already_present_value",
- "key1":"value1",
+ "already_present_key": "already_present_value",
+ "key1": "value1",
"key2": "value2"})
@@ -99,7 +99,7 @@ class TestRemoveTags(AWSMockServiceTestCase):
'SignatureVersion', 'Timestamp',
'Version'])
- self.assertEqual(taggedEC2Object.tags, {"key2":"value2"})
+ self.assertEqual(taggedEC2Object.tags, {"key2": "value2"})
def test_remove_tag_no_value(self):
self.set_http_response(status_code=200)
@@ -118,7 +118,7 @@ class TestRemoveTags(AWSMockServiceTestCase):
'SignatureVersion', 'Timestamp',
'Version'])
- self.assertEqual(taggedEC2Object.tags, {"key2":"value2"})
+ self.assertEqual(taggedEC2Object.tags, {"key2": "value2"})
def test_remove_tag_empty_value(self):
self.set_http_response(status_code=200)
@@ -138,7 +138,73 @@ class TestRemoveTags(AWSMockServiceTestCase):
'SignatureVersion', 'Timestamp',
'Version'])
- self.assertEqual(taggedEC2Object.tags, {"key2":"value2"})
+ self.assertEqual(taggedEC2Object.tags,
+ {"key1": "value1", "key2": "value2"})
+
+ def test_remove_tags(self):
+ self.set_http_response(status_code=200)
+ taggedEC2Object = TaggedEC2Object(self.service_connection)
+ taggedEC2Object.id = "i-abcd1234"
+ taggedEC2Object.tags["key1"] = "value1"
+ taggedEC2Object.tags["key2"] = "value2"
+
+ taggedEC2Object.remove_tags({"key1": "value1", "key2": "value2"})
+
+ self.assert_request_parameters({
+ 'ResourceId.1': 'i-abcd1234',
+ 'Action': 'DeleteTags',
+ 'Tag.1.Key': 'key1',
+ 'Tag.1.Value': 'value1',
+ 'Tag.2.Key': 'key2',
+ 'Tag.2.Value': 'value2'},
+ ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
+ 'SignatureVersion', 'Timestamp',
+ 'Version'])
+
+ self.assertEqual(taggedEC2Object.tags, {})
+
+ def test_remove_tags_wrong_values(self):
+ self.set_http_response(status_code=200)
+ taggedEC2Object = TaggedEC2Object(self.service_connection)
+ taggedEC2Object.id = "i-abcd1234"
+ taggedEC2Object.tags["key1"] = "value1"
+ taggedEC2Object.tags["key2"] = "value2"
+
+ taggedEC2Object.remove_tags({"key1": "value1", "key2": "value3"})
+
+ self.assert_request_parameters({
+ 'ResourceId.1': 'i-abcd1234',
+ 'Action': 'DeleteTags',
+ 'Tag.1.Key': 'key1',
+ 'Tag.1.Value': 'value1',
+ 'Tag.2.Key': 'key2',
+ 'Tag.2.Value': 'value3'},
+ ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
+ 'SignatureVersion', 'Timestamp',
+ 'Version'])
+
+ self.assertEqual(taggedEC2Object.tags, {"key2": "value2"})
+
+ def test_remove_tags_none_values(self):
+ self.set_http_response(status_code=200)
+ taggedEC2Object = TaggedEC2Object(self.service_connection)
+ taggedEC2Object.id = "i-abcd1234"
+ taggedEC2Object.tags["key1"] = "value1"
+ taggedEC2Object.tags["key2"] = "value2"
+
+ taggedEC2Object.remove_tags({"key1": "value1", "key2": None})
+
+ self.assert_request_parameters({
+ 'ResourceId.1': 'i-abcd1234',
+ 'Action': 'DeleteTags',
+ 'Tag.1.Key': 'key1',
+ 'Tag.1.Value': 'value1',
+ 'Tag.2.Key': 'key2'},
+ ignore_params_values=['AWSAccessKeyId', 'SignatureMethod',
+ 'SignatureVersion', 'Timestamp',
+ 'Version'])
+
+ self.assertEqual(taggedEC2Object.tags, {})
if __name__ == '__main__':