# Path: lamvery/clients/logs.py
# class LogsClient(BaseClient):
# 
#     def __init__(self, *args, **kwargs):
#         super(LogsClient, self).__init__(*args, **kwargs)
#         self._logs = self._session.client('logs')
# 
#     def get_log_events(self, function, start, pattern, next_token=None):
#         kwargs = {}
#         kwargs['logGroupName'] = '/aws/lambda/{}'.format(function)
#         kwargs['startTime'] = start
#         kwargs['limit'] = 100
# 
#         if pattern is not None:
#             kwargs['filterPattern'] = pattern
#         if next_token is not None:
#             kwargs['nextToken'] = next_token
# 
#         log_events = self._logs.filter_log_events(**kwargs)
# 
#         ret = log_events['events']
#         if 'NextToken' in log_events:
#             ret.extend(
#                 self.get_log_events(
#                     function, start, pattern, log_events['NextToken']))
#         return ret


from unittest import TestCase
from nose.tools import eq_
from mock import Mock
from lamvery.clients.logs import LogsClient
# -*- coding: utf-8 -*-



class LogsClientTestCase(TestCase):

    def setUp(self):
        self.client = LogsClient(region='us-east-1')
        self.client._logs = Mock()

    def test_get_log_events(self):
        ret1 = {'events': ['foo', 'bar'], 'NextToken': 'foo'}
        ret2 = {'events': ['baz', 'qux']}

# Path: lamvery/clients/logs.py
# class LogsClient(BaseClient):
# 
#     def __init__(self, *args, **kwargs):
#         super(LogsClient, self).__init__(*args, **kwargs)
#         self._logs = self._session.client('logs')
# 
#     def get_log_events(self, function, start, pattern, next_token=None):
#         kwargs = {}
#         kwargs['logGroupName'] = '/aws/lambda/{}'.format(function)
#         kwargs['startTime'] = start
#         kwargs['limit'] = 100
# 
#         if pattern is not None:
#             kwargs['filterPattern'] = pattern
#         if next_token is not None:
#             kwargs['nextToken'] = next_token
# 
#         log_events = self._logs.filter_log_events(**kwargs)
# 
#         ret = log_events['events']
#         if 'NextToken' in log_events:
#             ret.extend(
#                 self.get_log_events(
#                     function, start, pattern, log_events['NextToken']))
#         return ret


# Path: tests/lamvery/clients/logs_test.py
from unittest import TestCase
from nose.tools import eq_
from mock import Mock
from lamvery.clients.logs import LogsClient

# -*- coding: utf-8 -*-



class LogsClientTestCase(TestCase):

    def setUp(self):
        self.client = LogsClient(region='us-east-1')
        self.client._logs = Mock()

    def test_get_log_events(self):
        ret1 = {'events': ['foo', 'bar'], 'NextToken': 'foo'}
        ret2 = {'events': ['baz', 'qux']}

        self.client._logs.filter_log_events = Mock(side_effect=[ret1, ret2])