40 lines
1.0 KiB
Python
40 lines
1.0 KiB
Python
import json
|
|
import os
|
|
from dataclasses import dataclass
|
|
|
|
import pytest
|
|
|
|
|
|
# https://docs.pytest.org/en/7.1.x/reference/reference.html#pytest.hookspec.pytest_configure
|
|
def pytest_configure():
|
|
os.environ['TZ'] = 'America/Sao_Paulo'
|
|
os.environ['MEILISEARCH_HOST'] = 'http://127.0.0.1:7700'
|
|
os.environ['POSTGRES_DB'] = 'pytest'
|
|
os.environ['POSTGRES_HOST'] = 'localhost'
|
|
os.environ['POSTGRES_PORT'] = '5432'
|
|
os.environ['POSTGRES_USER'] = 'postgres'
|
|
os.environ['POSTGRES_PASSWORD'] = 'pgsql@pwd'
|
|
|
|
|
|
def load_jsonfile(path: str) -> dict:
|
|
with open(path) as fp:
|
|
return json.load(fp)
|
|
|
|
|
|
@dataclass
|
|
class LambdaContext:
|
|
function_name: str = 'test'
|
|
memory_limit_in_mb: int = 128
|
|
invoked_function_arn: str = 'arn:aws:lambda:eu-west-1:809313241:function:test'
|
|
aws_request_id: str = '52fdfc07-2182-154f-163f-5f0f9a621d72'
|
|
|
|
|
|
@pytest.fixture
|
|
def lambda_context() -> LambdaContext:
|
|
return LambdaContext()
|
|
|
|
|
|
@pytest.fixture
|
|
def dynamodb_stream_event():
|
|
return load_jsonfile('tests/samples/dynamodb_stream_event.json')
|