rename params

This commit is contained in:
2025-03-27 21:35:36 -03:00
parent 5756451738
commit f757334899
12 changed files with 53 additions and 41 deletions

View File

@@ -13,6 +13,11 @@ PK = os.getenv('DYNAMODB_PARTITION_KEY', 'pk')
SK = os.getenv('DYNAMODB_SORT_KEY', 'sk')
patch = pytest.MonkeyPatch()
patch.setenv('USER_TABLE', PYTEST_TABLE_NAME)
patch.setenv('COURSE_TABLE', PYTEST_TABLE_NAME)
@dataclass
class LambdaContext:
function_name: str = 'test'
@@ -137,9 +142,6 @@ def dynamodb_seeds(dynamodb_client):
@pytest.fixture
def mock_app(monkeypatch):
for table_name in ['USER_TABLE', 'COURSE_TABLE']:
monkeypatch.setenv(table_name, PYTEST_TABLE_NAME)
import app
return app

View File

@@ -87,6 +87,7 @@ def test_get_logs(
def test_post_user(
mock_app,
dynamodb_client,
http_api_proxy: HttpApiProxy,
lambda_context: LambdaContext,
):

View File

@@ -5,6 +5,8 @@ from .conftest import LambdaContext
def test_bearer_jwt(lambda_context: LambdaContext):
import auth as app
# You should mock the Cognito user to pass the test
app.get_user = lambda *args, **kwargs: {
'sub': '58efed8d-d276-41a8-8502-4ab8b5a6415e',
@@ -30,6 +32,7 @@ def test_bearer_jwt(lambda_context: LambdaContext):
def test_bearer_apikey(
monkeypatch,
dynamodb_seeds,
lambda_context: LambdaContext,
):
@@ -38,6 +41,7 @@ def test_bearer_apikey(
'authorization': 'Bearer sk-MzI1MDQ0NTctZjEzMy00YzAwLTkzNmItNmFhNzEyY2E5ZjQw',
}
}
# This data was added from seeds
assert app.lambda_handler(event, lambda_context) == {
'isAuthorized': True,
@@ -49,7 +53,7 @@ def test_bearer_apikey(
},
}
# This data was added from seeds
# # This data was added from seeds
assert app.lambda_handler(
{
'headers': {