mardi 16 avril 2019

Mocking boto3 Cloudwatch Log client

A Cloudwatch log is an object with Log Group > Log Stream > Log Events on AWS. I am trying to write tests for this, but the moto mocking raises a client error when applied to boto3.client('logs'). I am looking at other ways to mock the behavior of the log. How would you write a test for this function?

For example:

    client = boto3.client('logs')
    def get_recent_log_stream_name(logGroupName):
        response = client.describe_log_streams(
            logGroupName=logGroupName,
            orderBy='LastEventTime',
            descending=True,
            limit=1)
         logStreamName = response['logStreams'][0]['logStreamName']
         return logStreamName

Aucun commentaire:

Enregistrer un commentaire