Implement describe_log_groups() method for CloudWatchLogs

This patch teaches `LogsResponse` class how to handle the DescribeLogGroups
request, so that we can mock out the `boto.describe_log_groups()` call.

With this change in place, we can write as below:

    @mock_logs
    def test_log_group():
        conn = boto3.client('logs', 'us-west-2')

        some_method_to_init_log_groups()

        resp = conn.describe_log_groups(logGroupNamePrefix='myapp')
        assert ...

This should be fairly useful for a number of programs which handles
CloudWatchLogs.

Signed-off-by: Fujimoto Seiji <fujimoto@clear-code.com>
This commit is contained in:
Fujimoto Seiji 2018-04-24 11:12:17 +09:00
commit ac016a7bb3
3 changed files with 44 additions and 0 deletions

View file

@ -13,6 +13,10 @@ def test_log_group_create():
conn = boto3.client('logs', 'us-west-2')
log_group_name = 'dummy'
response = conn.create_log_group(logGroupName=log_group_name)
response = conn.describe_log_groups(logGroupNamePrefix=log_group_name)
assert len(response['logGroups']) == 1
response = conn.delete_log_group(logGroupName=log_group_name)