add integration
This commit is contained in:
@@ -3,6 +3,7 @@ import json
|
||||
import os
|
||||
from dataclasses import dataclass
|
||||
from http import HTTPMethod
|
||||
from urllib.parse import urlencode
|
||||
|
||||
import jsonlines
|
||||
import pytest
|
||||
@@ -37,16 +38,22 @@ class HttpApiProxy:
|
||||
body: dict | str | None = None,
|
||||
*,
|
||||
headers: dict = {},
|
||||
cookies: dict = {},
|
||||
cookies: list[str] = [],
|
||||
query_string_parameters: dict = {},
|
||||
is_base64_encoded: bool = True,
|
||||
**kwargs,
|
||||
) -> dict:
|
||||
if isinstance(body, dict):
|
||||
body = json.dumps(body)
|
||||
|
||||
if is_base64_encoded and body:
|
||||
body = _base64_encode(body)
|
||||
|
||||
return {
|
||||
'version': '2.0',
|
||||
'routeKey': '$default',
|
||||
'rawPath': raw_path,
|
||||
'rawQueryString': 'parameter1=value1¶meter1=value2¶meter2=value',
|
||||
'rawQueryString': urlencode(query_string_parameters),
|
||||
'cookies': cookies,
|
||||
'headers': headers,
|
||||
'queryStringParameters': query_string_parameters,
|
||||
@@ -69,17 +76,17 @@ class HttpApiProxy:
|
||||
'time': '12/Mar/2020:19:03:58 +0000',
|
||||
'timeEpoch': 1583348638390,
|
||||
},
|
||||
'body': _base64_dict(body) if isinstance(body, dict) else body,
|
||||
'body': body,
|
||||
'pathParameters': {'parameter1': 'value1'},
|
||||
'isBase64Encoded': is_base64_encoded,
|
||||
'stageVariables': {'stageVariable1': 'value1', 'stageVariable2': 'value2'},
|
||||
}
|
||||
|
||||
|
||||
def _base64_dict(obj: dict = {}) -> str | None:
|
||||
if not obj:
|
||||
def _base64_encode(s: str) -> str | None:
|
||||
if not s:
|
||||
return None
|
||||
return base64.b64encode(json.dumps(obj).encode()).decode()
|
||||
return base64.b64encode(s.encode()).decode()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@@ -128,7 +135,7 @@ def dynamodb_persistence_layer(dynamodb_client):
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def dynamodb_seeds(dynamodb_client):
|
||||
def seeds(dynamodb_client):
|
||||
from layercake.dynamodb import serialize
|
||||
|
||||
with open('tests/seeds.jsonl', 'rb') as fp:
|
||||
@@ -142,7 +149,7 @@ def dynamodb_seeds(dynamodb_client):
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_app():
|
||||
def app():
|
||||
import app
|
||||
|
||||
return app
|
||||
|
||||
Reference in New Issue
Block a user