add NotImplementedError when filter_pattern is given to filter_log_events
fix #2419
This commit is contained in:
parent
e7f1ab3290
commit
37877c6fb2
@ -125,6 +125,9 @@ class LogStream:
|
||||
return events_page, get_paging_token_from_index(back_index, True), get_paging_token_from_index(next_index)
|
||||
|
||||
def filter_log_events(self, log_group_name, log_stream_names, start_time, end_time, limit, next_token, filter_pattern, interleaved):
|
||||
if filter_pattern:
|
||||
raise NotImplementedError('filter_pattern is not yet implemented')
|
||||
|
||||
def filter_func(event):
|
||||
if start_time and event.timestamp < start_time:
|
||||
return False
|
||||
|
@ -128,6 +128,34 @@ def test_filter_logs_interleaved():
|
||||
resulting_event['timestamp'].should.equal(original_message['timestamp'])
|
||||
resulting_event['message'].should.equal(original_message['message'])
|
||||
|
||||
|
||||
@mock_logs
|
||||
def test_filter_logs_raises_if_filter_pattern():
|
||||
conn = boto3.client('logs', 'us-west-2')
|
||||
log_group_name = 'dummy'
|
||||
log_stream_name = 'stream'
|
||||
conn.create_log_group(logGroupName=log_group_name)
|
||||
conn.create_log_stream(
|
||||
logGroupName=log_group_name,
|
||||
logStreamName=log_stream_name
|
||||
)
|
||||
messages = [
|
||||
{'timestamp': 0, 'message': 'hello'},
|
||||
{'timestamp': 0, 'message': 'world'}
|
||||
]
|
||||
conn.put_log_events(
|
||||
logGroupName=log_group_name,
|
||||
logStreamName=log_stream_name,
|
||||
logEvents=messages
|
||||
)
|
||||
with assert_raises(NotImplementedError):
|
||||
conn.filter_log_events(
|
||||
logGroupName=log_group_name,
|
||||
logStreamNames=[log_stream_name],
|
||||
filterPattern='{$.message = "hello"}',
|
||||
)
|
||||
|
||||
|
||||
@mock_logs
|
||||
def test_put_retention_policy():
|
||||
conn = boto3.client('logs', 'us-west-2')
|
||||
@ -142,6 +170,7 @@ def test_put_retention_policy():
|
||||
|
||||
response = conn.delete_log_group(logGroupName=log_group_name)
|
||||
|
||||
|
||||
@mock_logs
|
||||
def test_delete_retention_policy():
|
||||
conn = boto3.client('logs', 'us-west-2')
|
||||
|
Loading…
Reference in New Issue
Block a user