1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
import boto3
import requests
from moto import mock_aws, settings
# 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
@mock_aws
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"] == []
@mock_aws
def test_set_query_results():
base_url = (
settings.test_server_mode_endpoint()
if settings.TEST_SERVER_MODE
else "http://motoapi.amazonaws.com"
)
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",
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"
|