Fix : Logs - Add start_query functionality (#3985)

* Added start_query functionality

* fix tests
This commit is contained in:
usmangani1 2021-06-07 15:07:11 +05:30 committed by GitHub
commit 9836985473
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 72 additions and 0 deletions

View file

@ -611,3 +611,35 @@ def test_describe_log_streams_paging():
)
resp["logStreams"].should.have.length_of(0)
resp.should_not.have.key("nextToken")
@mock_logs
def test_start_query():
client = boto3.client("logs", "us-east-1")
log_group_name = "/aws/codebuild/lowercase-dev"
client.create_log_group(logGroupName=log_group_name)
response = client.start_query(
logGroupName=log_group_name,
startTime=int(time.time()),
endTime=int(time.time()) + 300,
queryString="test",
)
assert "queryId" in response
with pytest.raises(ClientError) as e:
client.start_query(
logGroupName="/aws/codebuild/lowercase-dev-invalid",
startTime=int(time.time()),
endTime=int(time.time()) + 300,
queryString="test",
)
# then
ex = e.value
ex.response["Error"]["Code"].should.contain("ResourceNotFoundException")
ex.response["Error"]["Message"].should.equal(
"The specified log group does not exist"
)