move seeds dir

This commit is contained in:
2025-04-03 21:08:59 -03:00
parent 34085af4a8
commit 1358088a48
41 changed files with 1950 additions and 108 deletions

View File

@@ -4,7 +4,7 @@ import os
from dataclasses import dataclass
from http import HTTPMethod
import layercake.jsonl as jsonl
import jsonlines
import pytest
from layercake.dynamodb import DynamoDBPersistenceLayer
@@ -137,7 +137,7 @@ def dynamodb_persistence_layer(dynamodb_client) -> DynamoDBPersistenceLayer:
@pytest.fixture()
def dynamodb_seeds(dynamodb_client):
with jsonl.readlines('tests/seeds.jsonl') as lines:
with jsonlines.open('tests/seeds.jsonl') as lines:
for line in lines:
dynamodb_client.put_item(TableName=PYTEST_TABLE_NAME, Item=line)

View File

@@ -1,7 +1,13 @@
import json
from http import HTTPMethod, HTTPStatus
from layercake.dynamodb import ComposeKey, DynamoDBCollection, PartitionKey
from layercake.dynamodb import (
ComposeKey,
DynamoDBCollection,
DynamoDBPersistenceLayer,
KeyPair,
PartitionKey,
)
from ..conftest import HttpApiProxy, LambdaContext
@@ -41,4 +47,34 @@ def test_post_course(
)
)
assert len(logs['items']) == 3
print(logs)
def test_put_course(
mock_app,
dynamodb_seeds,
dynamodb_persistence_layer: DynamoDBPersistenceLayer,
http_api_proxy: HttpApiProxy,
lambda_context: LambdaContext,
):
r = mock_app.lambda_handler(
http_api_proxy(
raw_path='/courses/90d7f0d2-d9a4-4467-a31c-f9a7955964cf',
method=HTTPMethod.PUT,
headers={'X-Tenant': '*'},
body={
'id': '90d7f0d2-d9a4-4467-a31c-f9a7955964cf',
'name': 'pytest',
'access_period': YEAR_DAYS,
'cert': {
'exp_interval': YEAR_DAYS * 2,
},
},
),
lambda_context,
)
collect = DynamoDBCollection(dynamodb_persistence_layer)
course = collect.get_item(KeyPair('90d7f0d2-d9a4-4467-a31c-f9a7955964cf', '0'))
print(course)
assert r['statusCode'] == HTTPStatus.OK

View File

@@ -8,3 +8,4 @@
{"id": {"S": "log:5OxmMjL-ujoR5IMGegQz"}, "sk": {"S": "2024-02-08T16:42:33.776409-03:00"}, "action": {"S": "OPEN_EMAIL"}}
{"id": {"S": "log:5OxmMjL-ujoR5IMGegQz"}, "sk": {"S": "2019-03-25T00:00:00-03:00"}, "action": {"S": "CLICK_EMAIL"}}
{"id": {"S": "cJtK9SsnJhKPyxESe7g3DG"}, "sk": {"S": "0"}, "name": {"S": "EDUSEG"}, "cnpj": {"S": "15608435000190"}}
{"id": {"S": "90d7f0d2-d9a4-4467-a31c-f9a7955964cf"}, "sk": {"S": "0"}, "access_period": {"N": "720"}, "create_date": {"S": "2024-12-30T00:00:33.088916-03:00"},"konviva:class_id": {"N": "266"},"name": {"S": "Reciclagem em NR-18 Básico"},"tenant:org_id": {"SS": ["cJtK9SsnJhKPyxESe7g3DG"]}}