def test_add_message(): applogger = LogHandler('mystream') stubber = Stubber(applogger._log_client) stubber.add_response( 'create_log_stream', {}, ) stubber.add_response( 'put_log_events', { 'nextSequenceToken': 'string', 'rejectedLogEventsInfo': { 'tooNewLogEventStartIndex': 123, 'tooOldLogEventEndIndex': 123, 'expiredLogEventEndIndex': 123 } }, { 'logGroupName': 'SO0111-SHARR', 'logStreamName': 'MYSTREAM-' + str(date.today()), 'logEvents': ANY, 'sequenceToken': '0' } ) stubber.activate() assert applogger.log_group == 'SO0111-SHARR' applogger.add_message('A door is ajar') assert len(applogger._buffer) == 1 assert applogger._buffer_size == 40 applogger.flush()
def test_create_logstream(): applogger = LogHandler('mystream') stubber = Stubber(applogger._log_client) stubber.add_response('create_log_stream', {}, { 'logGroupName': 'SO0111-SHARR', 'logStreamName': 'MYSTREAM-' + str(date.today()) }) stubber.activate() assert applogger.log_group == 'SO0111-SHARR' applogger.add_message('A door is ajar')