From 300776a0d9fb37eef9a18dba82633a0593ceecea Mon Sep 17 00:00:00 2001 From: Allen Sanabria Date: Sun, 27 Mar 2016 16:16:52 -0700 Subject: [PATCH 1/6] Including unit tests. * Including unit tests as per https://groups.google.com/forum/#!topic/ansible-devel/ejY4CjKeC34 * This test suite is automatically run in https://github.com/linuxdynasty/ld-ansible-modules Originally from ansible/ansible-modules-extras@1cc5ea7418ad61a58b127f876699149abadb02f5 --- test/unit/cloud/amazon/test_kinesis_stream.py | 491 ++++++++++++++++++ 1 file changed, 491 insertions(+) create mode 100644 test/unit/cloud/amazon/test_kinesis_stream.py diff --git a/test/unit/cloud/amazon/test_kinesis_stream.py b/test/unit/cloud/amazon/test_kinesis_stream.py new file mode 100644 index 00000000000..5404ef99716 --- /dev/null +++ b/test/unit/cloud/amazon/test_kinesis_stream.py @@ -0,0 +1,491 @@ +#!/usr/bin/python + +import boto3 +import unittest + +from collections import namedtuple +from ansible.parsing.dataloader import DataLoader +from ansible.vars import VariableManager +from ansible.inventory import Inventory +from ansible.playbook.play import Play +from ansible.executor.task_queue_manager import TaskQueueManager + +import cloud.amazon.kinesis_stream as kinesis_stream + +Options = ( + namedtuple( + 'Options', [ + 'connection', 'module_path', 'forks', 'become', 'become_method', + 'become_user', 'remote_user', 'private_key_file', 'ssh_common_args', + 'sftp_extra_args', 'scp_extra_args', 'ssh_extra_args', 'verbosity', + 'check' + ] + ) +) +# initialize needed objects +variable_manager = VariableManager() +loader = DataLoader() +options = ( + Options( + connection='local', + module_path='cloud/amazon', + forks=1, become=None, become_method=None, become_user=None, check=True, + remote_user=None, private_key_file=None, ssh_common_args=None, + sftp_extra_args=None, scp_extra_args=None, ssh_extra_args=None, + verbosity=10 + ) +) +passwords = dict(vault_pass='') + +aws_region = 'us-west-2' + +# create inventory and pass to var manager +inventory = Inventory(loader=loader, variable_manager=variable_manager, host_list='localhost') +variable_manager.set_inventory(inventory) + +def run(play): + tqm = None + results = None + try: + tqm = TaskQueueManager( + inventory=inventory, + variable_manager=variable_manager, + loader=loader, + options=options, + passwords=passwords, + stdout_callback='default', + ) + results = tqm.run(play) + finally: + if tqm is not None: + tqm.cleanup() + return tqm, results + +class AnsibleKinesisStreamTasks(unittest.TestCase): + + def test_a_create_stream_1(self): + play_source = dict( + name = "Create Kinesis Stream with 10 Shards", + hosts = 'localhost', + gather_facts = 'no', + tasks = [ + dict( + action=dict( + module='kinesis_stream', + args=dict( + name='stream-test', + shards=10, + wait='yes', + region=aws_region, + ) + ), + register='stream', + ) + ] + ) + play = Play().load(play_source, variable_manager=variable_manager, loader=loader) + tqm, results = run(play) + self.failUnless(tqm._stats.ok['localhost'] == 1) + + def test_a_create_stream_2(self): + play_source = dict( + name = "Create Kinesis Stream with 10 Shards and create a tag called environment", + hosts = 'localhost', + gather_facts = 'no', + tasks = [ + dict( + action=dict( + module='kinesis_stream', + args=dict( + name='stream-test', + region=aws_region, + shards=10, + tags=dict( + env='development' + ), + wait='yes' + ) + ), + register='stream' + ) + ] + ) + play = Play().load(play_source, variable_manager=variable_manager, loader=loader) + tqm, results = run(play) + self.failUnless(tqm._stats.ok['localhost'] == 1) + + def test_a_create_stream_3(self): + play_source = dict( + name = "Create Kinesis Stream with 10 Shards and create a tag called environment and Change the default retention period from 24 to 48", + hosts = 'localhost', + gather_facts = 'no', + tasks = [ + dict( + action=dict( + module='kinesis_stream', + args=dict( + name='stream-test', + retention_period=48, + region=aws_region, + shards=10, + tags=dict( + env='development' + ), + wait='yes' + ) + ), + register='stream' + ) + ] + ) + play = Play().load(play_source, variable_manager=variable_manager, loader=loader) + tqm, results = run(play) + self.failUnless(tqm._stats.ok['localhost'] == 1) + + def test_b_create_stream_1(self): + play_source = dict( + name = "Create Kinesis Stream with out specifying the number of shards", + hosts = 'localhost', + gather_facts = 'no', + tasks = [ + dict( + action=dict( + module='kinesis_stream', + args=dict( + name='stream-test', + region=aws_region, + wait='yes' + ) + ), + register='stream' + ) + ] + ) + play = Play().load(play_source, variable_manager=variable_manager, loader=loader) + tqm, results = run(play) + self.failUnless(tqm._stats.failures['localhost'] == 1) + + def test_b_create_stream_2(self): + play_source = dict( + name = "Create Kinesis Stream with specifying the retention period less than 24 hours", + hosts = 'localhost', + gather_facts = 'no', + tasks = [ + dict( + action=dict( + module='kinesis_stream', + args=dict( + name='stream-test', + region=aws_region, + retention_period=23, + shards=10, + wait='yes' + ) + ), + register='stream' + ) + ] + ) + play = Play().load(play_source, variable_manager=variable_manager, loader=loader) + tqm, results = run(play) + self.failUnless(tqm._stats.failures['localhost'] == 1) + + def test_c_delete_stream_(self): + play_source = dict( + name = "Delete Kinesis Stream test-stream", + hosts = 'localhost', + gather_facts = 'no', + tasks = [ + dict( + action=dict( + module='kinesis_stream', + args=dict( + name='stream-test', + region=aws_region, + state='absent', + wait='yes' + ) + ) + ) + ] + ) + play = Play().load(play_source, variable_manager=variable_manager, loader=loader) + tqm, results = run(play) + self.failUnless(tqm._stats.ok['localhost'] == 1) + + +class AnsibleKinesisStreamFunctions(unittest.TestCase): + + def test_convert_to_lower(self): + example = { + 'HasMoreShards': True, + 'RetentionPeriodHours': 24, + 'StreamName': 'test', + 'StreamARN': 'arn:aws:kinesis:east-side:123456789:stream/test', + 'StreamStatus': 'ACTIVE' + } + converted_example = kinesis_stream.convert_to_lower(example) + keys = converted_example.keys() + keys.sort() + for i in range(len(keys)): + if i == 0: + self.assertEqual(keys[i], 'has_more_shards') + if i == 1: + self.assertEqual(keys[i], 'retention_period_hours') + if i == 2: + self.assertEqual(keys[i], 'stream_arn') + if i == 3: + self.assertEqual(keys[i], 'stream_name') + if i == 4: + self.assertEqual(keys[i], 'stream_status') + + def test_make_tags_in_aws_format(self): + example = { + 'env': 'development' + } + should_return = [ + { + 'Key': 'env', + 'Value': 'development' + } + ] + aws_tags = kinesis_stream.make_tags_in_aws_format(example) + self.assertEqual(aws_tags, should_return) + + def test_make_tags_in_proper_format(self): + example = [ + { + 'Key': 'env', + 'Value': 'development' + }, + { + 'Key': 'service', + 'Value': 'web' + } + ] + should_return = { + 'env': 'development', + 'service': 'web' + } + proper_tags = kinesis_stream.make_tags_in_proper_format(example) + self.assertEqual(proper_tags, should_return) + + def test_recreate_tags_from_list(self): + example = [('environment', 'development'), ('service', 'web')] + should_return = [ + { + 'Key': 'environment', + 'Value': 'development' + }, + { + 'Key': 'service', + 'Value': 'web' + } + ] + aws_tags = kinesis_stream.recreate_tags_from_list(example) + self.assertEqual(aws_tags, should_return) + + def test_get_tags(self): + client = boto3.client('kinesis', region_name='us-west-2') + success, err_msg, tags = kinesis_stream.get_tags(client, 'test', True) + self.assertTrue(success) + should_return = [ + { + 'Key': 'DryRunMode', + 'Value': 'true' + } + ] + self.assertEqual(tags, should_return) + + def test_find_stream(self): + client = boto3.client('kinesis', region_name='us-west-2') + success, err_msg, stream = ( + kinesis_stream.find_stream(client, 'test', check_mode=True) + ) + should_return = { + 'HasMoreShards': True, + 'RetentionPeriodHours': 24, + 'StreamName': 'test', + 'StreamARN': 'arn:aws:kinesis:east-side:123456789:stream/test', + 'StreamStatus': 'ACTIVE' + } + self.assertTrue(success) + self.assertEqual(stream, should_return) + + def test_wait_for_status(self): + client = boto3.client('kinesis', region_name='us-west-2') + success, err_msg, stream = ( + kinesis_stream.wait_for_status( + client, 'test', 'ACTIVE', check_mode=True + ) + ) + should_return = { + 'HasMoreShards': True, + 'RetentionPeriodHours': 24, + 'StreamName': 'test', + 'StreamARN': 'arn:aws:kinesis:east-side:123456789:stream/test', + 'StreamStatus': 'ACTIVE' + } + self.assertTrue(success) + self.assertEqual(stream, should_return) + + def test_tags_action_create(self): + client = boto3.client('kinesis', region_name='us-west-2') + tags = { + 'env': 'development', + 'service': 'web' + } + success, err_msg = ( + kinesis_stream.tags_action( + client, 'test', tags, 'create', check_mode=True + ) + ) + self.assertTrue(success) + + def test_tags_action_delete(self): + client = boto3.client('kinesis', region_name='us-west-2') + tags = { + 'env': 'development', + 'service': 'web' + } + success, err_msg = ( + kinesis_stream.tags_action( + client, 'test', tags, 'delete', check_mode=True + ) + ) + self.assertTrue(success) + + def test_tags_action_invalid(self): + client = boto3.client('kinesis', region_name='us-west-2') + tags = { + 'env': 'development', + 'service': 'web' + } + success, err_msg = ( + kinesis_stream.tags_action( + client, 'test', tags, 'append', check_mode=True + ) + ) + self.assertFalse(success) + + def test_update_tags(self): + client = boto3.client('kinesis', region_name='us-west-2') + tags = { + 'env': 'development', + 'service': 'web' + } + success, err_msg = ( + kinesis_stream.update_tags( + client, 'test', tags, check_mode=True + ) + ) + self.assertTrue(success) + + def test_stream_action_create(self): + client = boto3.client('kinesis', region_name='us-west-2') + success, err_msg = ( + kinesis_stream.stream_action( + client, 'test', 10, 'create', check_mode=True + ) + ) + self.assertTrue(success) + + def test_stream_action_delete(self): + client = boto3.client('kinesis', region_name='us-west-2') + success, err_msg = ( + kinesis_stream.stream_action( + client, 'test', 10, 'delete', check_mode=True + ) + ) + self.assertTrue(success) + + def test_stream_action_invalid(self): + client = boto3.client('kinesis', region_name='us-west-2') + success, err_msg = ( + kinesis_stream.stream_action( + client, 'test', 10, 'append', check_mode=True + ) + ) + self.assertFalse(success) + + def test_retention_action_increase(self): + client = boto3.client('kinesis', region_name='us-west-2') + success, err_msg = ( + kinesis_stream.retention_action( + client, 'test', 48, 'increase', check_mode=True + ) + ) + self.assertTrue(success) + + def test_retention_action_decrease(self): + client = boto3.client('kinesis', region_name='us-west-2') + success, err_msg = ( + kinesis_stream.retention_action( + client, 'test', 24, 'decrease', check_mode=True + ) + ) + self.assertTrue(success) + + def test_retention_action_invalid(self): + client = boto3.client('kinesis', region_name='us-west-2') + success, err_msg = ( + kinesis_stream.retention_action( + client, 'test', 24, 'create', check_mode=True + ) + ) + self.assertFalse(success) + + def test_update(self): + client = boto3.client('kinesis', region_name='us-west-2') + current_stream = { + 'HasMoreShards': True, + 'RetentionPeriodHours': 24, + 'StreamName': 'test', + 'StreamARN': 'arn:aws:kinesis:east-side:123456789:stream/test', + 'StreamStatus': 'ACTIVE' + } + tags = { + 'env': 'development', + 'service': 'web' + } + success, changed, err_msg = ( + kinesis_stream.update( + client, current_stream, 'test', retention_period=48, + tags=tags, check_mode=True + ) + ) + self.assertTrue(success) + self.assertTrue(changed) + self.assertEqual(err_msg, 'Kinesis Stream test updated successfully.') + + def test_create_stream(self): + client = boto3.client('kinesis', region_name='us-west-2') + tags = { + 'env': 'development', + 'service': 'web' + } + success, changed, err_msg, results = ( + kinesis_stream.create_stream( + client, 'test', number_of_shards=10, retention_period=48, + tags=tags, check_mode=True + ) + ) + should_return = { + 'has_more_shards': True, + 'retention_period_hours': 24, + 'stream_name': 'test', + 'stream_arn': 'arn:aws:kinesis:east-side:123456789:stream/test', + 'stream_status': 'ACTIVE', + 'tags': tags, + } + self.assertTrue(success) + self.assertTrue(changed) + self.assertEqual(results, should_return) + self.assertEqual(err_msg, 'Kinesis Stream test updated successfully.') + + +def main(): + unittest.main() + +if __name__ == '__main__': + main() From 9a4ce30789c43cd009c1d204486b34ba1e4fafba Mon Sep 17 00:00:00 2001 From: Allen Sanabria Date: Mon, 28 Mar 2016 07:39:15 -0700 Subject: [PATCH 2/6] Removed Ansible API based tests from this PR Originally from ansible/ansible-modules-extras@e9fcb8b28620268bc57407b010bfbecd08eb8dd1 --- test/unit/cloud/amazon/test_kinesis_stream.py | 236 ++---------------- 1 file changed, 15 insertions(+), 221 deletions(-) diff --git a/test/unit/cloud/amazon/test_kinesis_stream.py b/test/unit/cloud/amazon/test_kinesis_stream.py index 5404ef99716..280ec5e2de6 100644 --- a/test/unit/cloud/amazon/test_kinesis_stream.py +++ b/test/unit/cloud/amazon/test_kinesis_stream.py @@ -3,216 +3,10 @@ import boto3 import unittest -from collections import namedtuple -from ansible.parsing.dataloader import DataLoader -from ansible.vars import VariableManager -from ansible.inventory import Inventory -from ansible.playbook.play import Play -from ansible.executor.task_queue_manager import TaskQueueManager - import cloud.amazon.kinesis_stream as kinesis_stream -Options = ( - namedtuple( - 'Options', [ - 'connection', 'module_path', 'forks', 'become', 'become_method', - 'become_user', 'remote_user', 'private_key_file', 'ssh_common_args', - 'sftp_extra_args', 'scp_extra_args', 'ssh_extra_args', 'verbosity', - 'check' - ] - ) -) -# initialize needed objects -variable_manager = VariableManager() -loader = DataLoader() -options = ( - Options( - connection='local', - module_path='cloud/amazon', - forks=1, become=None, become_method=None, become_user=None, check=True, - remote_user=None, private_key_file=None, ssh_common_args=None, - sftp_extra_args=None, scp_extra_args=None, ssh_extra_args=None, - verbosity=10 - ) -) -passwords = dict(vault_pass='') - aws_region = 'us-west-2' -# create inventory and pass to var manager -inventory = Inventory(loader=loader, variable_manager=variable_manager, host_list='localhost') -variable_manager.set_inventory(inventory) - -def run(play): - tqm = None - results = None - try: - tqm = TaskQueueManager( - inventory=inventory, - variable_manager=variable_manager, - loader=loader, - options=options, - passwords=passwords, - stdout_callback='default', - ) - results = tqm.run(play) - finally: - if tqm is not None: - tqm.cleanup() - return tqm, results - -class AnsibleKinesisStreamTasks(unittest.TestCase): - - def test_a_create_stream_1(self): - play_source = dict( - name = "Create Kinesis Stream with 10 Shards", - hosts = 'localhost', - gather_facts = 'no', - tasks = [ - dict( - action=dict( - module='kinesis_stream', - args=dict( - name='stream-test', - shards=10, - wait='yes', - region=aws_region, - ) - ), - register='stream', - ) - ] - ) - play = Play().load(play_source, variable_manager=variable_manager, loader=loader) - tqm, results = run(play) - self.failUnless(tqm._stats.ok['localhost'] == 1) - - def test_a_create_stream_2(self): - play_source = dict( - name = "Create Kinesis Stream with 10 Shards and create a tag called environment", - hosts = 'localhost', - gather_facts = 'no', - tasks = [ - dict( - action=dict( - module='kinesis_stream', - args=dict( - name='stream-test', - region=aws_region, - shards=10, - tags=dict( - env='development' - ), - wait='yes' - ) - ), - register='stream' - ) - ] - ) - play = Play().load(play_source, variable_manager=variable_manager, loader=loader) - tqm, results = run(play) - self.failUnless(tqm._stats.ok['localhost'] == 1) - - def test_a_create_stream_3(self): - play_source = dict( - name = "Create Kinesis Stream with 10 Shards and create a tag called environment and Change the default retention period from 24 to 48", - hosts = 'localhost', - gather_facts = 'no', - tasks = [ - dict( - action=dict( - module='kinesis_stream', - args=dict( - name='stream-test', - retention_period=48, - region=aws_region, - shards=10, - tags=dict( - env='development' - ), - wait='yes' - ) - ), - register='stream' - ) - ] - ) - play = Play().load(play_source, variable_manager=variable_manager, loader=loader) - tqm, results = run(play) - self.failUnless(tqm._stats.ok['localhost'] == 1) - - def test_b_create_stream_1(self): - play_source = dict( - name = "Create Kinesis Stream with out specifying the number of shards", - hosts = 'localhost', - gather_facts = 'no', - tasks = [ - dict( - action=dict( - module='kinesis_stream', - args=dict( - name='stream-test', - region=aws_region, - wait='yes' - ) - ), - register='stream' - ) - ] - ) - play = Play().load(play_source, variable_manager=variable_manager, loader=loader) - tqm, results = run(play) - self.failUnless(tqm._stats.failures['localhost'] == 1) - - def test_b_create_stream_2(self): - play_source = dict( - name = "Create Kinesis Stream with specifying the retention period less than 24 hours", - hosts = 'localhost', - gather_facts = 'no', - tasks = [ - dict( - action=dict( - module='kinesis_stream', - args=dict( - name='stream-test', - region=aws_region, - retention_period=23, - shards=10, - wait='yes' - ) - ), - register='stream' - ) - ] - ) - play = Play().load(play_source, variable_manager=variable_manager, loader=loader) - tqm, results = run(play) - self.failUnless(tqm._stats.failures['localhost'] == 1) - - def test_c_delete_stream_(self): - play_source = dict( - name = "Delete Kinesis Stream test-stream", - hosts = 'localhost', - gather_facts = 'no', - tasks = [ - dict( - action=dict( - module='kinesis_stream', - args=dict( - name='stream-test', - region=aws_region, - state='absent', - wait='yes' - ) - ) - ) - ] - ) - play = Play().load(play_source, variable_manager=variable_manager, loader=loader) - tqm, results = run(play) - self.failUnless(tqm._stats.ok['localhost'] == 1) - class AnsibleKinesisStreamFunctions(unittest.TestCase): @@ -286,7 +80,7 @@ class AnsibleKinesisStreamFunctions(unittest.TestCase): self.assertEqual(aws_tags, should_return) def test_get_tags(self): - client = boto3.client('kinesis', region_name='us-west-2') + client = boto3.client('kinesis', region_name=aws_region) success, err_msg, tags = kinesis_stream.get_tags(client, 'test', True) self.assertTrue(success) should_return = [ @@ -298,7 +92,7 @@ class AnsibleKinesisStreamFunctions(unittest.TestCase): self.assertEqual(tags, should_return) def test_find_stream(self): - client = boto3.client('kinesis', region_name='us-west-2') + client = boto3.client('kinesis', region_name=aws_region) success, err_msg, stream = ( kinesis_stream.find_stream(client, 'test', check_mode=True) ) @@ -313,7 +107,7 @@ class AnsibleKinesisStreamFunctions(unittest.TestCase): self.assertEqual(stream, should_return) def test_wait_for_status(self): - client = boto3.client('kinesis', region_name='us-west-2') + client = boto3.client('kinesis', region_name=aws_region) success, err_msg, stream = ( kinesis_stream.wait_for_status( client, 'test', 'ACTIVE', check_mode=True @@ -330,7 +124,7 @@ class AnsibleKinesisStreamFunctions(unittest.TestCase): self.assertEqual(stream, should_return) def test_tags_action_create(self): - client = boto3.client('kinesis', region_name='us-west-2') + client = boto3.client('kinesis', region_name=aws_region) tags = { 'env': 'development', 'service': 'web' @@ -343,7 +137,7 @@ class AnsibleKinesisStreamFunctions(unittest.TestCase): self.assertTrue(success) def test_tags_action_delete(self): - client = boto3.client('kinesis', region_name='us-west-2') + client = boto3.client('kinesis', region_name=aws_region) tags = { 'env': 'development', 'service': 'web' @@ -356,7 +150,7 @@ class AnsibleKinesisStreamFunctions(unittest.TestCase): self.assertTrue(success) def test_tags_action_invalid(self): - client = boto3.client('kinesis', region_name='us-west-2') + client = boto3.client('kinesis', region_name=aws_region) tags = { 'env': 'development', 'service': 'web' @@ -369,7 +163,7 @@ class AnsibleKinesisStreamFunctions(unittest.TestCase): self.assertFalse(success) def test_update_tags(self): - client = boto3.client('kinesis', region_name='us-west-2') + client = boto3.client('kinesis', region_name=aws_region) tags = { 'env': 'development', 'service': 'web' @@ -382,7 +176,7 @@ class AnsibleKinesisStreamFunctions(unittest.TestCase): self.assertTrue(success) def test_stream_action_create(self): - client = boto3.client('kinesis', region_name='us-west-2') + client = boto3.client('kinesis', region_name=aws_region) success, err_msg = ( kinesis_stream.stream_action( client, 'test', 10, 'create', check_mode=True @@ -391,7 +185,7 @@ class AnsibleKinesisStreamFunctions(unittest.TestCase): self.assertTrue(success) def test_stream_action_delete(self): - client = boto3.client('kinesis', region_name='us-west-2') + client = boto3.client('kinesis', region_name=aws_region) success, err_msg = ( kinesis_stream.stream_action( client, 'test', 10, 'delete', check_mode=True @@ -400,7 +194,7 @@ class AnsibleKinesisStreamFunctions(unittest.TestCase): self.assertTrue(success) def test_stream_action_invalid(self): - client = boto3.client('kinesis', region_name='us-west-2') + client = boto3.client('kinesis', region_name=aws_region) success, err_msg = ( kinesis_stream.stream_action( client, 'test', 10, 'append', check_mode=True @@ -409,7 +203,7 @@ class AnsibleKinesisStreamFunctions(unittest.TestCase): self.assertFalse(success) def test_retention_action_increase(self): - client = boto3.client('kinesis', region_name='us-west-2') + client = boto3.client('kinesis', region_name=aws_region) success, err_msg = ( kinesis_stream.retention_action( client, 'test', 48, 'increase', check_mode=True @@ -418,7 +212,7 @@ class AnsibleKinesisStreamFunctions(unittest.TestCase): self.assertTrue(success) def test_retention_action_decrease(self): - client = boto3.client('kinesis', region_name='us-west-2') + client = boto3.client('kinesis', region_name=aws_region) success, err_msg = ( kinesis_stream.retention_action( client, 'test', 24, 'decrease', check_mode=True @@ -427,7 +221,7 @@ class AnsibleKinesisStreamFunctions(unittest.TestCase): self.assertTrue(success) def test_retention_action_invalid(self): - client = boto3.client('kinesis', region_name='us-west-2') + client = boto3.client('kinesis', region_name=aws_region) success, err_msg = ( kinesis_stream.retention_action( client, 'test', 24, 'create', check_mode=True @@ -436,7 +230,7 @@ class AnsibleKinesisStreamFunctions(unittest.TestCase): self.assertFalse(success) def test_update(self): - client = boto3.client('kinesis', region_name='us-west-2') + client = boto3.client('kinesis', region_name=aws_region) current_stream = { 'HasMoreShards': True, 'RetentionPeriodHours': 24, @@ -459,7 +253,7 @@ class AnsibleKinesisStreamFunctions(unittest.TestCase): self.assertEqual(err_msg, 'Kinesis Stream test updated successfully.') def test_create_stream(self): - client = boto3.client('kinesis', region_name='us-west-2') + client = boto3.client('kinesis', region_name=aws_region) tags = { 'env': 'development', 'service': 'web' From 56377b9d00ff886b7f41a0a034da984f3017bba2 Mon Sep 17 00:00:00 2001 From: Allen Sanabria Date: Mon, 28 Mar 2016 20:38:52 -0700 Subject: [PATCH 3/6] Updated module to be compliant with test cases. * Added integration tests * Added unit tests Originally from ansible/ansible-modules-extras@ee523be26c3d4677f0393dc9976ecd1778098324 --- .../cloud/amazon/test_ec2_vpc_nat_gateway.py | 486 ++++++++++++++++++ 1 file changed, 486 insertions(+) create mode 100644 test/unit/cloud/amazon/test_ec2_vpc_nat_gateway.py diff --git a/test/unit/cloud/amazon/test_ec2_vpc_nat_gateway.py b/test/unit/cloud/amazon/test_ec2_vpc_nat_gateway.py new file mode 100644 index 00000000000..e2d3573499e --- /dev/null +++ b/test/unit/cloud/amazon/test_ec2_vpc_nat_gateway.py @@ -0,0 +1,486 @@ +#!/usr/bin/python + +import boto3 +import unittest + +from collections import namedtuple +from ansible.parsing.dataloader import DataLoader +from ansible.vars import VariableManager +from ansible.inventory import Inventory +from ansible.playbook.play import Play +from ansible.executor.task_queue_manager import TaskQueueManager + +import cloud.amazon.ec2_vpc_nat_gateway as ng + +Options = ( + namedtuple( + 'Options', [ + 'connection', 'module_path', 'forks', 'become', 'become_method', + 'become_user', 'remote_user', 'private_key_file', 'ssh_common_args', + 'sftp_extra_args', 'scp_extra_args', 'ssh_extra_args', 'verbosity', + 'check' + ] + ) +) +# initialize needed objects +variable_manager = VariableManager() +loader = DataLoader() +options = ( + Options( + connection='local', + module_path='cloud/amazon', + forks=1, become=None, become_method=None, become_user=None, check=True, + remote_user=None, private_key_file=None, ssh_common_args=None, + sftp_extra_args=None, scp_extra_args=None, ssh_extra_args=None, + verbosity=3 + ) +) +passwords = dict(vault_pass='') + +aws_region = 'us-west-2' + +# create inventory and pass to var manager +inventory = Inventory(loader=loader, variable_manager=variable_manager, host_list='localhost') +variable_manager.set_inventory(inventory) + +def run(play): + tqm = None + results = None + try: + tqm = TaskQueueManager( + inventory=inventory, + variable_manager=variable_manager, + loader=loader, + options=options, + passwords=passwords, + stdout_callback='default', + ) + results = tqm.run(play) + finally: + if tqm is not None: + tqm.cleanup() + return tqm, results + +class AnsibleVpcNatGatewayTasks(unittest.TestCase): + + def test_create_gateway_using_allocation_id(self): + play_source = dict( + name = "Create new nat gateway with eip allocation-id", + hosts = 'localhost', + gather_facts = 'no', + tasks = [ + dict( + action=dict( + module='ec2_vpc_nat_gateway', + args=dict( + subnet_id='subnet-12345678', + allocation_id='eipalloc-12345678', + wait='yes', + region=aws_region, + ) + ), + register='nat_gateway', + ), + dict( + action=dict( + module='debug', + args=dict( + msg='{{nat_gateway}}' + ) + ) + ) + ] + ) + play = Play().load(play_source, variable_manager=variable_manager, loader=loader) + tqm, results = run(play) + self.failUnless(tqm._stats.ok['localhost'] == 2) + self.failUnless(tqm._stats.changed['localhost'] == 1) + + def test_create_gateway_using_allocation_id_idempotent(self): + play_source = dict( + name = "Create new nat gateway with eip allocation-id", + hosts = 'localhost', + gather_facts = 'no', + tasks = [ + dict( + action=dict( + module='ec2_vpc_nat_gateway', + args=dict( + subnet_id='subnet-123456789', + allocation_id='eipalloc-1234567', + wait='yes', + region=aws_region, + ) + ), + register='nat_gateway', + ), + dict( + action=dict( + module='debug', + args=dict( + msg='{{nat_gateway}}' + ) + ) + ) + ] + ) + play = Play().load(play_source, variable_manager=variable_manager, loader=loader) + tqm, results = run(play) + self.failUnless(tqm._stats.ok['localhost'] == 2) + self.assertFalse(tqm._stats.changed.has_key('localhost')) + + def test_create_gateway_using_eip_address(self): + play_source = dict( + name = "Create new nat gateway with eip address", + hosts = 'localhost', + gather_facts = 'no', + tasks = [ + dict( + action=dict( + module='ec2_vpc_nat_gateway', + args=dict( + subnet_id='subnet-12345678', + eip_address='55.55.55.55', + wait='yes', + region=aws_region, + ) + ), + register='nat_gateway', + ), + dict( + action=dict( + module='debug', + args=dict( + msg='{{nat_gateway}}' + ) + ) + ) + ] + ) + play = Play().load(play_source, variable_manager=variable_manager, loader=loader) + tqm, results = run(play) + self.failUnless(tqm._stats.ok['localhost'] == 2) + self.failUnless(tqm._stats.changed['localhost'] == 1) + + def test_create_gateway_using_eip_address_idempotent(self): + play_source = dict( + name = "Create new nat gateway with eip address", + hosts = 'localhost', + gather_facts = 'no', + tasks = [ + dict( + action=dict( + module='ec2_vpc_nat_gateway', + args=dict( + subnet_id='subnet-123456789', + eip_address='55.55.55.55', + wait='yes', + region=aws_region, + ) + ), + register='nat_gateway', + ), + dict( + action=dict( + module='debug', + args=dict( + msg='{{nat_gateway}}' + ) + ) + ) + ] + ) + play = Play().load(play_source, variable_manager=variable_manager, loader=loader) + tqm, results = run(play) + self.failUnless(tqm._stats.ok['localhost'] == 2) + self.assertFalse(tqm._stats.changed.has_key('localhost')) + + def test_create_gateway_in_subnet_only_if_one_does_not_exist_already(self): + play_source = dict( + name = "Create new nat gateway only if one does not exist already", + hosts = 'localhost', + gather_facts = 'no', + tasks = [ + dict( + action=dict( + module='ec2_vpc_nat_gateway', + args=dict( + if_exist_do_not_create='yes', + subnet_id='subnet-123456789', + wait='yes', + region=aws_region, + ) + ), + register='nat_gateway', + ), + dict( + action=dict( + module='debug', + args=dict( + msg='{{nat_gateway}}' + ) + ) + ) + ] + ) + play = Play().load(play_source, variable_manager=variable_manager, loader=loader) + tqm, results = run(play) + self.failUnless(tqm._stats.ok['localhost'] == 2) + self.assertFalse(tqm._stats.changed.has_key('localhost')) + + def test_delete_gateway(self): + play_source = dict( + name = "Delete Nat Gateway", + hosts = 'localhost', + gather_facts = 'no', + tasks = [ + dict( + action=dict( + module='ec2_vpc_nat_gateway', + args=dict( + nat_gateway_id='nat-123456789', + state='absent', + wait='yes', + region=aws_region, + ) + ), + register='nat_gateway', + ), + dict( + action=dict( + module='debug', + args=dict( + msg='{{nat_gateway}}' + ) + ) + ) + ] + ) + play = Play().load(play_source, variable_manager=variable_manager, loader=loader) + tqm, results = run(play) + self.failUnless(tqm._stats.ok['localhost'] == 2) + self.assertTrue(tqm._stats.changed.has_key('localhost')) + +class AnsibleEc2VpcNatGatewayFunctions(unittest.TestCase): + + def test_convert_to_lower(self): + example = ng.DRY_RUN_GATEWAY_UNCONVERTED + converted_example = ng.convert_to_lower(example[0]) + keys = converted_example.keys() + keys.sort() + for i in range(len(keys)): + if i == 0: + self.assertEqual(keys[i], 'create_time') + if i == 1: + self.assertEqual(keys[i], 'nat_gateway_addresses') + gw_addresses_keys = converted_example[keys[i]][0].keys() + gw_addresses_keys.sort() + for j in range(len(gw_addresses_keys)): + if j == 0: + self.assertEqual(gw_addresses_keys[j], 'allocation_id') + if j == 1: + self.assertEqual(gw_addresses_keys[j], 'network_interface_id') + if j == 2: + self.assertEqual(gw_addresses_keys[j], 'private_ip') + if j == 3: + self.assertEqual(gw_addresses_keys[j], 'public_ip') + if i == 2: + self.assertEqual(keys[i], 'nat_gateway_id') + if i == 3: + self.assertEqual(keys[i], 'state') + if i == 4: + self.assertEqual(keys[i], 'subnet_id') + if i == 5: + self.assertEqual(keys[i], 'vpc_id') + + def test_get_nat_gateways(self): + client = boto3.client('ec2', region_name=aws_region) + success, err_msg, stream = ( + ng.get_nat_gateways(client, 'subnet-123456789', check_mode=True) + ) + should_return = ng.DRY_RUN_GATEWAYS + self.assertTrue(success) + self.assertEqual(stream, should_return) + + def test_get_nat_gateways_no_gateways_found(self): + client = boto3.client('ec2', region_name=aws_region) + success, err_msg, stream = ( + ng.get_nat_gateways(client, 'subnet-1234567', check_mode=True) + ) + self.assertTrue(success) + self.assertEqual(stream, []) + + def test_wait_for_status(self): + client = boto3.client('ec2', region_name=aws_region) + success, err_msg, gws = ( + ng.wait_for_status( + client, 5, 'nat-123456789', 'available', check_mode=True + ) + ) + should_return = ng.DRY_RUN_GATEWAYS[0] + self.assertTrue(success) + self.assertEqual(gws, should_return) + + def test_wait_for_status_to_timeout(self): + client = boto3.client('ec2', region_name=aws_region) + success, err_msg, gws = ( + ng.wait_for_status( + client, 2, 'nat-12345678', 'available', check_mode=True + ) + ) + self.assertFalse(success) + self.assertEqual(gws, []) + + def test_gateway_in_subnet_exists_with_allocation_id(self): + client = boto3.client('ec2', region_name=aws_region) + gws, err_msg = ( + ng.gateway_in_subnet_exists( + client, 'subnet-123456789', 'eipalloc-1234567', check_mode=True + ) + ) + should_return = ng.DRY_RUN_GATEWAYS + self.assertEqual(gws, should_return) + + def test_gateway_in_subnet_exists_with_allocation_id_does_not_exist(self): + client = boto3.client('ec2', region_name=aws_region) + gws, err_msg = ( + ng.gateway_in_subnet_exists( + client, 'subnet-123456789', 'eipalloc-123', check_mode=True + ) + ) + should_return = list() + self.assertEqual(gws, should_return) + + def test_gateway_in_subnet_exists_without_allocation_id(self): + client = boto3.client('ec2', region_name=aws_region) + gws, err_msg = ( + ng.gateway_in_subnet_exists( + client, 'subnet-123456789', check_mode=True + ) + ) + should_return = ng.DRY_RUN_GATEWAYS + self.assertEqual(gws, should_return) + + def test_get_eip_allocation_id_by_address(self): + client = boto3.client('ec2', region_name=aws_region) + allocation_id, _ = ( + ng.get_eip_allocation_id_by_address( + client, '55.55.55.55', check_mode=True + ) + ) + should_return = 'eipalloc-1234567' + self.assertEqual(allocation_id, should_return) + + def test_get_eip_allocation_id_by_address_does_not_exist(self): + client = boto3.client('ec2', region_name=aws_region) + allocation_id, err_msg = ( + ng.get_eip_allocation_id_by_address( + client, '52.52.52.52', check_mode=True + ) + ) + self.assertEqual(err_msg, 'EIP 52.52.52.52 does not exist') + self.assertIsNone(allocation_id) + + def test_allocate_eip_address(self): + client = boto3.client('ec2', region_name=aws_region) + success, err_msg, eip_id = ( + ng.allocate_eip_address( + client, check_mode=True + ) + ) + self.assertTrue(success) + + def test_release_address(self): + client = boto3.client('ec2', region_name=aws_region) + success = ( + ng.release_address( + client, 'eipalloc-1234567', check_mode=True + ) + ) + self.assertTrue(success) + + def test_create(self): + client = boto3.client('ec2', region_name=aws_region) + success, changed, err_msg, results = ( + ng.create( + client, 'subnet-123456', 'eipalloc-1234567', check_mode=True + ) + ) + self.assertTrue(success) + self.assertTrue(changed) + + def test_pre_create(self): + client = boto3.client('ec2', region_name=aws_region) + success, changed, err_msg, results = ( + ng.pre_create( + client, 'subnet-123456', check_mode=True + ) + ) + self.assertTrue(success) + self.assertTrue(changed) + + def test_pre_create_idemptotent_with_allocation_id(self): + client = boto3.client('ec2', region_name=aws_region) + success, changed, err_msg, results = ( + ng.pre_create( + client, 'subnet-123456789', allocation_id='eipalloc-1234567', check_mode=True + ) + ) + self.assertTrue(success) + self.assertFalse(changed) + + def test_pre_create_idemptotent_with_eip_address(self): + client = boto3.client('ec2', region_name=aws_region) + success, changed, err_msg, results = ( + ng.pre_create( + client, 'subnet-123456789', eip_address='55.55.55.55', check_mode=True + ) + ) + self.assertTrue(success) + self.assertFalse(changed) + + def test_pre_create_idemptotent_if_exist_do_not_create(self): + client = boto3.client('ec2', region_name=aws_region) + success, changed, err_msg, results = ( + ng.pre_create( + client, 'subnet-123456789', if_exist_do_not_create=True, check_mode=True + ) + ) + self.assertTrue(success) + self.assertFalse(changed) + + def test_delete(self): + client = boto3.client('ec2', region_name=aws_region) + success, changed, err_msg, _ = ( + ng.remove( + client, 'nat-123456789', check_mode=True + ) + ) + self.assertTrue(success) + self.assertTrue(changed) + + def test_delete_and_release_ip(self): + client = boto3.client('ec2', region_name=aws_region) + success, changed, err_msg, _ = ( + ng.remove( + client, 'nat-123456789', release_eip=True, check_mode=True + ) + ) + self.assertTrue(success) + self.assertTrue(changed) + + def test_delete_if_does_not_exist(self): + client = boto3.client('ec2', region_name=aws_region) + success, changed, err_msg, _ = ( + ng.remove( + client, 'nat-12345', check_mode=True + ) + ) + self.assertFalse(success) + self.assertFalse(changed) + +def main(): + unittest.main() + +if __name__ == '__main__': + main() From 423b14436a67dcb4fd0c212d52fa8f7f9132e8f6 Mon Sep 17 00:00:00 2001 From: Allen Sanabria Date: Thu, 4 Aug 2016 13:10:11 -0700 Subject: [PATCH 4/6] updated tests to reflect dict vs list Originally from ansible/ansible-modules-extras@461553bda80dafc33c006f58640cf1254ae057d7 --- test/unit/cloud/amazon/test_ec2_vpc_nat_gateway.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/cloud/amazon/test_ec2_vpc_nat_gateway.py b/test/unit/cloud/amazon/test_ec2_vpc_nat_gateway.py index e2d3573499e..7c4f163ad40 100644 --- a/test/unit/cloud/amazon/test_ec2_vpc_nat_gateway.py +++ b/test/unit/cloud/amazon/test_ec2_vpc_nat_gateway.py @@ -329,7 +329,7 @@ class AnsibleEc2VpcNatGatewayFunctions(unittest.TestCase): ) ) self.assertFalse(success) - self.assertEqual(gws, []) + self.assertEqual(gws, {}) def test_gateway_in_subnet_exists_with_allocation_id(self): client = boto3.client('ec2', region_name=aws_region) From e56229747a114ae51e51a72196ebb179337dca85 Mon Sep 17 00:00:00 2001 From: Allen Sanabria Date: Thu, 4 Aug 2016 18:14:36 -0700 Subject: [PATCH 5/6] fixed error message for releasing an ip when not waiting for the nat gateway to delete successfully 1st Originally from ansible/ansible-modules-extras@950d76af0b73aff58ab0b9042ee8789b0d1f7dfb --- test/unit/cloud/amazon/test_ec2_vpc_nat_gateway.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/cloud/amazon/test_ec2_vpc_nat_gateway.py b/test/unit/cloud/amazon/test_ec2_vpc_nat_gateway.py index 7c4f163ad40..1b75c88a143 100644 --- a/test/unit/cloud/amazon/test_ec2_vpc_nat_gateway.py +++ b/test/unit/cloud/amazon/test_ec2_vpc_nat_gateway.py @@ -392,7 +392,7 @@ class AnsibleEc2VpcNatGatewayFunctions(unittest.TestCase): def test_release_address(self): client = boto3.client('ec2', region_name=aws_region) - success = ( + success, _ = ( ng.release_address( client, 'eipalloc-1234567', check_mode=True ) From 37271867b1690d3b7aa9284a5c3b41d06e0cd3c8 Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Mon, 31 Oct 2016 16:44:06 -0700 Subject: [PATCH 6/6] Move amazon unit tests and apply fixes. - Update import for relocated tests. - Fix test to expect changed from update_tags. - Add checks for boto3 and botocore to tests. - Set check mode with kwarg. - Python 3 fixes for unit tests. - Python 2.6 fix for unit tests. --- test/units/modules/extras/__init__.py | 0 test/units/modules/extras/cloud/__init__.py | 0 .../modules/extras/cloud/amazon/__init__.py | 0 .../cloud/amazon/test_ec2_vpc_nat_gateway.py | 29 +++++++++++++------ .../cloud/amazon/test_kinesis_stream.py | 21 ++++++++++---- 5 files changed, 36 insertions(+), 14 deletions(-) create mode 100644 test/units/modules/extras/__init__.py create mode 100644 test/units/modules/extras/cloud/__init__.py create mode 100644 test/units/modules/extras/cloud/amazon/__init__.py rename test/{unit => units/modules/extras}/cloud/amazon/test_ec2_vpc_nat_gateway.py (95%) rename test/{unit => units/modules/extras}/cloud/amazon/test_kinesis_stream.py (95%) diff --git a/test/units/modules/extras/__init__.py b/test/units/modules/extras/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/units/modules/extras/cloud/__init__.py b/test/units/modules/extras/cloud/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/units/modules/extras/cloud/amazon/__init__.py b/test/units/modules/extras/cloud/amazon/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/unit/cloud/amazon/test_ec2_vpc_nat_gateway.py b/test/units/modules/extras/cloud/amazon/test_ec2_vpc_nat_gateway.py similarity index 95% rename from test/unit/cloud/amazon/test_ec2_vpc_nat_gateway.py rename to test/units/modules/extras/cloud/amazon/test_ec2_vpc_nat_gateway.py index 1b75c88a143..573fa377787 100644 --- a/test/unit/cloud/amazon/test_ec2_vpc_nat_gateway.py +++ b/test/units/modules/extras/cloud/amazon/test_ec2_vpc_nat_gateway.py @@ -1,6 +1,17 @@ #!/usr/bin/python -import boto3 +from nose.plugins.skip import SkipTest + +try: + import boto3 + import botocore + HAS_BOTO3 = True +except ImportError: + HAS_BOTO3 = False + +if not HAS_BOTO3: + raise SkipTest("test_ec2_vpc_nat_gateway.py requires the python module 'boto3' and 'botocore'") + import unittest from collections import namedtuple @@ -10,7 +21,7 @@ from ansible.inventory import Inventory from ansible.playbook.play import Play from ansible.executor.task_queue_manager import TaskQueueManager -import cloud.amazon.ec2_vpc_nat_gateway as ng +import ansible.modules.extras.cloud.amazon.ec2_vpc_nat_gateway as ng Options = ( namedtuple( @@ -127,7 +138,7 @@ class AnsibleVpcNatGatewayTasks(unittest.TestCase): play = Play().load(play_source, variable_manager=variable_manager, loader=loader) tqm, results = run(play) self.failUnless(tqm._stats.ok['localhost'] == 2) - self.assertFalse(tqm._stats.changed.has_key('localhost')) + self.assertFalse('localhost' in tqm._stats.changed) def test_create_gateway_using_eip_address(self): play_source = dict( @@ -193,7 +204,7 @@ class AnsibleVpcNatGatewayTasks(unittest.TestCase): play = Play().load(play_source, variable_manager=variable_manager, loader=loader) tqm, results = run(play) self.failUnless(tqm._stats.ok['localhost'] == 2) - self.assertFalse(tqm._stats.changed.has_key('localhost')) + self.assertFalse('localhost' in tqm._stats.changed) def test_create_gateway_in_subnet_only_if_one_does_not_exist_already(self): play_source = dict( @@ -226,7 +237,7 @@ class AnsibleVpcNatGatewayTasks(unittest.TestCase): play = Play().load(play_source, variable_manager=variable_manager, loader=loader) tqm, results = run(play) self.failUnless(tqm._stats.ok['localhost'] == 2) - self.assertFalse(tqm._stats.changed.has_key('localhost')) + self.assertFalse('localhost' in tqm._stats.changed) def test_delete_gateway(self): play_source = dict( @@ -259,21 +270,21 @@ class AnsibleVpcNatGatewayTasks(unittest.TestCase): play = Play().load(play_source, variable_manager=variable_manager, loader=loader) tqm, results = run(play) self.failUnless(tqm._stats.ok['localhost'] == 2) - self.assertTrue(tqm._stats.changed.has_key('localhost')) + self.assertTrue('localhost' in tqm._stats.changed) class AnsibleEc2VpcNatGatewayFunctions(unittest.TestCase): def test_convert_to_lower(self): example = ng.DRY_RUN_GATEWAY_UNCONVERTED converted_example = ng.convert_to_lower(example[0]) - keys = converted_example.keys() + keys = list(converted_example.keys()) keys.sort() for i in range(len(keys)): if i == 0: self.assertEqual(keys[i], 'create_time') if i == 1: self.assertEqual(keys[i], 'nat_gateway_addresses') - gw_addresses_keys = converted_example[keys[i]][0].keys() + gw_addresses_keys = list(converted_example[keys[i]][0].keys()) gw_addresses_keys.sort() for j in range(len(gw_addresses_keys)): if j == 0: @@ -379,7 +390,7 @@ class AnsibleEc2VpcNatGatewayFunctions(unittest.TestCase): ) ) self.assertEqual(err_msg, 'EIP 52.52.52.52 does not exist') - self.assertIsNone(allocation_id) + self.assertTrue(allocation_id is None) def test_allocate_eip_address(self): client = boto3.client('ec2', region_name=aws_region) diff --git a/test/unit/cloud/amazon/test_kinesis_stream.py b/test/units/modules/extras/cloud/amazon/test_kinesis_stream.py similarity index 95% rename from test/unit/cloud/amazon/test_kinesis_stream.py rename to test/units/modules/extras/cloud/amazon/test_kinesis_stream.py index 280ec5e2de6..7b5dcff67c4 100644 --- a/test/unit/cloud/amazon/test_kinesis_stream.py +++ b/test/units/modules/extras/cloud/amazon/test_kinesis_stream.py @@ -1,9 +1,20 @@ #!/usr/bin/python -import boto3 +from nose.plugins.skip import SkipTest + +try: + import boto3 + import botocore + HAS_BOTO3 = True +except ImportError: + HAS_BOTO3 = False + +if not HAS_BOTO3: + raise SkipTest("test_kinesis_stream.py requires the python module 'boto3' and 'botocore'") + import unittest -import cloud.amazon.kinesis_stream as kinesis_stream +import ansible.modules.extras.cloud.amazon.kinesis_stream as kinesis_stream aws_region = 'us-west-2' @@ -19,7 +30,7 @@ class AnsibleKinesisStreamFunctions(unittest.TestCase): 'StreamStatus': 'ACTIVE' } converted_example = kinesis_stream.convert_to_lower(example) - keys = converted_example.keys() + keys = list(converted_example.keys()) keys.sort() for i in range(len(keys)): if i == 0: @@ -81,7 +92,7 @@ class AnsibleKinesisStreamFunctions(unittest.TestCase): def test_get_tags(self): client = boto3.client('kinesis', region_name=aws_region) - success, err_msg, tags = kinesis_stream.get_tags(client, 'test', True) + success, err_msg, tags = kinesis_stream.get_tags(client, 'test', check_mode=True) self.assertTrue(success) should_return = [ { @@ -168,7 +179,7 @@ class AnsibleKinesisStreamFunctions(unittest.TestCase): 'env': 'development', 'service': 'web' } - success, err_msg = ( + success, changed, err_msg = ( kinesis_stream.update_tags( client, 'test', tags, check_mode=True )