use sure for unit test assertions
This commit is contained in:
parent
1e851fb1d8
commit
414f8086b0
@ -1,59 +1,64 @@
|
||||
import unittest
|
||||
import sure
|
||||
|
||||
from moto.utilities.tagging_service import TaggingService
|
||||
|
||||
|
||||
class TestTaggingService(unittest.TestCase):
|
||||
def test_list_empty(self):
|
||||
svc = TaggingService()
|
||||
result = svc.list_tags_for_resource("test")
|
||||
self.assertEqual(result, {"Tags": []})
|
||||
def test_list_empty():
|
||||
svc = TaggingService()
|
||||
result = svc.list_tags_for_resource("test")
|
||||
|
||||
def test_create_tag(self):
|
||||
svc = TaggingService("TheTags", "TagKey", "TagValue")
|
||||
tags = [{"TagKey": "key_key", "TagValue": "value_value"}]
|
||||
svc.tag_resource("arn", tags)
|
||||
actual = svc.list_tags_for_resource("arn")
|
||||
expected = {"TheTags": [{"TagKey": "key_key", "TagValue": "value_value"}]}
|
||||
self.assertDictEqual(expected, actual)
|
||||
|
||||
def test_create_tag_without_value(self):
|
||||
svc = TaggingService()
|
||||
tags = [{"Key": "key_key"}]
|
||||
svc.tag_resource("arn", tags)
|
||||
actual = svc.list_tags_for_resource("arn")
|
||||
expected = {"Tags": [{"Key": "key_key", "Value": None}]}
|
||||
self.assertDictEqual(expected, actual)
|
||||
|
||||
def test_delete_tag_using_names(self):
|
||||
svc = TaggingService()
|
||||
tags = [{"Key": "key_key", "Value": "value_value"}]
|
||||
svc.tag_resource("arn", tags)
|
||||
svc.untag_resource_using_names("arn", ["key_key"])
|
||||
result = svc.list_tags_for_resource("arn")
|
||||
self.assertEqual(result, {"Tags": []})
|
||||
|
||||
def test_list_empty_delete(self):
|
||||
svc = TaggingService()
|
||||
svc.untag_resource_using_names("arn", ["key_key"])
|
||||
result = svc.list_tags_for_resource("arn")
|
||||
self.assertEqual(result, {"Tags": []})
|
||||
|
||||
def test_delete_tag_using_tags(self):
|
||||
svc = TaggingService()
|
||||
tags = [{"Key": "key_key", "Value": "value_value"}]
|
||||
svc.tag_resource("arn", tags)
|
||||
svc.untag_resource_using_tags("arn", tags)
|
||||
result = svc.list_tags_for_resource("arn")
|
||||
self.assertEqual(result, {"Tags": []})
|
||||
|
||||
def test_extract_tag_names(self):
|
||||
svc = TaggingService()
|
||||
tags = [{"Key": "key1", "Value": "value1"}, {"Key": "key2", "Value": "value2"}]
|
||||
actual = svc.extract_tag_names(tags)
|
||||
expected = ["key1", "key2"]
|
||||
self.assertEqual(expected, actual)
|
||||
{"Tags": []}.should.be.equal(result)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
def test_create_tag():
|
||||
svc = TaggingService("TheTags", "TagKey", "TagValue")
|
||||
tags = [{"TagKey": "key_key", "TagValue": "value_value"}]
|
||||
svc.tag_resource("arn", tags)
|
||||
actual = svc.list_tags_for_resource("arn")
|
||||
expected = {"TheTags": [{"TagKey": "key_key", "TagValue": "value_value"}]}
|
||||
|
||||
expected.should.be.equal(actual)
|
||||
|
||||
def test_create_tag_without_value():
|
||||
svc = TaggingService()
|
||||
tags = [{"Key": "key_key"}]
|
||||
svc.tag_resource("arn", tags)
|
||||
actual = svc.list_tags_for_resource("arn")
|
||||
expected = {"Tags": [{"Key": "key_key", "Value": None}]}
|
||||
|
||||
expected.should.be.equal(actual)
|
||||
|
||||
def test_delete_tag_using_names():
|
||||
svc = TaggingService()
|
||||
tags = [{"Key": "key_key", "Value": "value_value"}]
|
||||
svc.tag_resource("arn", tags)
|
||||
svc.untag_resource_using_names("arn", ["key_key"])
|
||||
result = svc.list_tags_for_resource("arn")
|
||||
|
||||
{"Tags": []}.should.be.equal(result)
|
||||
|
||||
def test_list_empty_delete():
|
||||
svc = TaggingService()
|
||||
svc.untag_resource_using_names("arn", ["key_key"])
|
||||
result = svc.list_tags_for_resource("arn")
|
||||
|
||||
{"Tags": []}.should.be.equal(result)
|
||||
|
||||
def test_delete_tag_using_tags():
|
||||
svc = TaggingService()
|
||||
tags = [{"Key": "key_key", "Value": "value_value"}]
|
||||
svc.tag_resource("arn", tags)
|
||||
svc.untag_resource_using_tags("arn", tags)
|
||||
result = svc.list_tags_for_resource("arn")
|
||||
|
||||
{"Tags": []}.should.be.equal(result)
|
||||
|
||||
|
||||
def test_extract_tag_names():
|
||||
svc = TaggingService()
|
||||
tags = [{"Key": "key1", "Value": "value1"}, {"Key": "key2", "Value": "value2"}]
|
||||
actual = svc.extract_tag_names(tags)
|
||||
expected = ["key1", "key2"]
|
||||
|
||||
expected.should.be.equal(actual)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user