moto/tests/test_rdsdata/test_rdsdata.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

57 lines
1.5 KiB
Python
Raw Permalink Normal View History

2023-04-03 16:18:10 +00:00
import boto3
import requests
2024-01-07 12:03:33 +00:00
from moto import mock_aws, settings
2023-04-03 16:18:10 +00:00
# See our Development Tips on writing tests for hints on how to write good tests:
# http://docs.getmoto.org/en/latest/docs/contributing/development_tips/tests.html
2024-01-07 12:03:33 +00:00
@mock_aws
2023-04-03 16:18:10 +00:00
def test_execute_statement():
rdsdata = boto3.client("rds-data", region_name="eu-west-1")
resp = rdsdata.execute_statement(
resourceArn="not applicable",
secretArn="not applicable",
sql="SELECT some FROM thing",
)
assert resp["records"] == []
2024-01-07 12:03:33 +00:00
@mock_aws
2023-04-03 16:18:10 +00:00
def test_set_query_results():
base_url = (
settings.test_server_mode_endpoint()
if settings.TEST_SERVER_MODE
else "http://motoapi.amazonaws.com"
2023-04-03 16:18:10 +00:00
)
sql_result = {
"results": [
{
"records": [[{"isNull": True}], [{"isNull": False}]],
"columnMetadata": [{"name": "a"}],
"formattedRecords": "some json",
}
],
"region": "us-west-1",
}
resp = requests.post(
f"{base_url}/moto-api/static/rds-data/statement-results",
2023-04-03 16:18:10 +00:00
json=sql_result,
)
assert resp.status_code == 201
rdsdata = boto3.client("rds-data", region_name="us-west-1")
resp = rdsdata.execute_statement(
resourceArn="not applicable",
secretArn="not applicable",
sql="SELECT some FROM thing",
)
assert resp["records"] == [[{"isNull": True}], [{"isNull": False}]]
assert resp["formattedRecords"] == "some json"