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

@@ -1,9 +1,9 @@
import os
import boto3
import jsonlines
import pytest
import layercake.jsonl as jsonl
from layercake.dynamodb import DynamoDBPersistenceLayer
PYTEST_TABLE_NAME = os.getenv('PYTEST_TABLE_NAME', 'pytest')
@@ -43,6 +43,6 @@ 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

@@ -32,6 +32,24 @@ def test_serialize():
'ip': {'S': '127.0.0.1'},
}
assert serialize(
{'ids': ('1', '2', '3')},
) == {
'ids': {
'L': [{'S': '1'}, {'S': '2'}, {'S': '3'}],
}
}
assert serialize(
{'ids': ['1', '2', '3']},
) == {
'ids': {
'L': [{'S': '1'}, {'S': '2'}, {'S': '3'}],
}
}
assert serialize({'ids': {'1'}}) == {'ids': {'SS': ['1']}}
def test_composekey():
key = ComposeKey(('122', 'abc'), prefix='schedules', delimiter=':')

View File

@@ -1,19 +0,0 @@
import tempfile
from pathlib import Path
import layercake.jsonl as jsonl
def test_readlines():
with tempfile.NamedTemporaryFile() as fp:
fp.writelines([b'{}\n' for _ in range(4)])
fp.seek(0)
with jsonl.readlines(fp.name) as lines:
assert sum(1 for _ in lines) == 4
with jsonl.readlines(Path('notfound.jsonl')) as lines:
assert sum(1 for _ in lines) == 0
with jsonl.readlines(Path('notfound.jsonl')) as lines:
assert list(lines) == []