Tests: Verify Athena QueryResults work in ProxyMode (#7395)

This commit is contained in:
Bert Blommers 2024-02-26 23:32:33 +00:00 committed by GitHub
parent b331628603
commit 3064a28202
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 23 additions and 3 deletions

View File

@ -41,7 +41,7 @@ jobs:
env:
TEST_PROXY_MODE: ${{ true }}
run: |
pytest -sv tests/test_acmpca tests/test_awslambda tests/test_apigateway tests/test_core/test_proxy.py tests/test_s3
pytest -sv tests/test_acmpca tests/test_athena tests/test_awslambda tests/test_apigateway tests/test_core/test_proxy.py tests/test_s3
- name: "Stop MotoProxy"
if: always()
run: |

View File

@ -287,7 +287,7 @@ def test_get_query_results():
assert result["ResultSet"]["Rows"] == []
assert result["ResultSet"]["ResultSetMetadata"]["ColumnInfo"] == []
if not settings.TEST_SERVER_MODE:
if settings.TEST_DECORATOR_MODE:
backend = athena_backends[DEFAULT_ACCOUNT_ID]["us-east-1"]
rows = [{"Data": [{"VarCharValue": ".."}]}]
column_info = [

View File

@ -1,7 +1,7 @@
import boto3
import requests
from moto import mock_aws, settings
from moto import mock_aws, moto_proxy, settings
DEFAULT_COLUMN_INFO = [
{
@ -35,9 +35,13 @@ def test_set_athena_result():
}
]
}
kwargs = {}
if settings.is_test_proxy_mode():
add_proxy_details(kwargs)
resp = requests.post(
f"http://{base_url}/moto-api/static/athena/query-results",
json=athena_result,
**kwargs,
)
assert resp.status_code == 201
@ -60,6 +64,9 @@ def test_set_multiple_athena_result():
base_url = (
"localhost:5000" if settings.TEST_SERVER_MODE else "motoapi.amazonaws.com"
)
kwargs = {}
if settings.is_test_proxy_mode():
add_proxy_details(kwargs)
athena_result = {
"results": [
@ -71,6 +78,7 @@ def test_set_multiple_athena_result():
resp = requests.post(
f"http://{base_url}/moto-api/static/athena/query-results",
json=athena_result,
**kwargs,
)
assert resp.status_code == 201
@ -100,6 +108,9 @@ def test_set_athena_result_with_custom_region_account():
base_url = (
"localhost:5000" if settings.TEST_SERVER_MODE else "motoapi.amazonaws.com"
)
kwargs = {}
if settings.is_test_proxy_mode():
add_proxy_details(kwargs)
athena_result = {
"account_id": "222233334444",
@ -116,6 +127,7 @@ def test_set_athena_result_with_custom_region_account():
resp = requests.post(
f"http://{base_url}/moto-api/static/athena/query-results",
json=athena_result,
**kwargs,
)
assert resp.status_code == 201
@ -157,3 +169,11 @@ def test_set_athena_result_with_custom_region_account():
client = boto3.client("athena", region_name="eu-west-1")
details = client.get_query_results(QueryExecutionId="anyid")["ResultSet"]
assert details["Rows"] == []
def add_proxy_details(kwargs):
kwargs["proxies"] = {
"http": "http://localhost:5005",
"https": "http://localhost:5005",
}
kwargs["verify"] = moto_proxy.__file__.replace("__init__.py", "ca.crt")