def test_reboot_cache_clusters_all_nodes(aws_client):
    client = MagicMock()
    aws_client.return_value = client
    cluster_ids = ["MyTestCacheCluster"]

    client.describe_cache_clusters.return_value = {
        "CacheClusters": [{
            "CacheClusterId":
            "MyTestCacheCluster",
            "CacheNodes": [
                {
                    "CacheNodeId": "0001"
                },
                {
                    "CacheNodeId": "0002"
                },
                {
                    "CacheNodeId": "0003"
                },
                {
                    "CacheNodeId": "0004"
                },
            ],
        }]
    }
    client.reboot_cache_cluster.return_value = {
        "CacheCluster": {
            "CacheClusterId":
            "MyTestCacheCluster",
            "CacheNodes": [
                {
                    "CacheNodeId": "0001"
                },
                {
                    "CacheNodeId": "0002"
                },
                {
                    "CacheNodeId": "0003"
                },
                {
                    "CacheNodeId": "0004"
                },
            ],
        }
    }

    results = reboot_cache_clusters(cluster_ids)
    client.describe_cache_clusters.assert_called_with(
        CacheClusterId=cluster_ids[0], ShowCacheNodeInfo=True)
    client.reboot_cache_cluster.assert_called_with(
        CacheClusterId=cluster_ids[0],
        CacheNodeIdsToReboot=["0001", "0002", "0003", "0004"],
    )
    assert results[0]["CacheClusterId"] == cluster_ids[0]
def test_reboot_cache_clusters_all_nodes(aws_client):
    client = MagicMock()
    aws_client.return_value = client
    cluster_ids = ['MyTestCacheCluster']

    client.describe_cache_clusters.return_value = {
        'CacheClusters': [{
            'CacheClusterId':
            'MyTestCacheCluster',
            'CacheNodes': [{
                'CacheNodeId': '0001'
            }, {
                'CacheNodeId': '0002'
            }, {
                'CacheNodeId': '0003'
            }, {
                'CacheNodeId': '0004'
            }]
        }]
    }
    client.reboot_cache_cluster.return_value = {
        'CacheCluster': {
            'CacheClusterId':
            'MyTestCacheCluster',
            'CacheNodes': [{
                'CacheNodeId': '0001'
            }, {
                'CacheNodeId': '0002'
            }, {
                'CacheNodeId': '0003'
            }, {
                'CacheNodeId': '0004'
            }]
        }
    }

    results = reboot_cache_clusters(cluster_ids)
    client.describe_cache_clusters.assert_called_with(
        CacheClusterId=cluster_ids[0], ShowCacheNodeInfo=True)
    client.reboot_cache_cluster.assert_called_with(
        CacheClusterId=cluster_ids[0],
        CacheNodeIdsToReboot=['0001', '0002', '0003', '0004'])
    assert results[0]['CacheClusterId'] == cluster_ids[0]
def test_reboot_cache_clusters_invalid():
    with pytest.raises(TypeError) as x:
        reboot_cache_clusters()
    assert ("reboot_cache_clusters() missing 1 required positional "
            "argument: 'cluster_ids'" in str(x.value))