update conftest
This commit is contained in:
@@ -1,25 +1,29 @@
|
||||
import os
|
||||
|
||||
import boto3
|
||||
import pytest
|
||||
|
||||
import layercake.jsonl as jsonl
|
||||
from layercake.dynamodb import DynamoDBPersistenceLayer
|
||||
|
||||
table_name = 'pytest'
|
||||
dynamodb_endpoint_url = 'http://127.0.0.1:8000'
|
||||
PYTEST_TABLE_NAME = os.getenv('PYTEST_TABLE_NAME', 'pytest')
|
||||
DYNAMODB_ENDPOINT_URL = os.getenv('DYNAMODB_ENDPOINT_URL')
|
||||
PK = os.getenv('DYNAMODB_PARTITION_KEY', 'pk')
|
||||
SK = os.getenv('DYNAMODB_SORT_KEY', 'sk')
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def dynamodb_client():
|
||||
client = boto3.client('dynamodb', endpoint_url=dynamodb_endpoint_url)
|
||||
client = boto3.client('dynamodb', endpoint_url=DYNAMODB_ENDPOINT_URL)
|
||||
client.create_table(
|
||||
AttributeDefinitions=[
|
||||
{'AttributeName': 'id', 'AttributeType': 'S'},
|
||||
{'AttributeName': 'sk', 'AttributeType': 'S'},
|
||||
{'AttributeName': PK, 'AttributeType': 'S'},
|
||||
{'AttributeName': SK, 'AttributeType': 'S'},
|
||||
],
|
||||
TableName=table_name,
|
||||
TableName=PYTEST_TABLE_NAME,
|
||||
KeySchema=[
|
||||
{'AttributeName': 'id', 'KeyType': 'HASH'},
|
||||
{'AttributeName': 'sk', 'KeyType': 'RANGE'},
|
||||
{'AttributeName': PK, 'KeyType': 'HASH'},
|
||||
{'AttributeName': SK, 'KeyType': 'RANGE'},
|
||||
],
|
||||
ProvisionedThroughput={
|
||||
'ReadCapacityUnits': 123,
|
||||
@@ -29,16 +33,16 @@ def dynamodb_client():
|
||||
|
||||
yield client
|
||||
|
||||
client.delete_table(TableName=table_name)
|
||||
client.delete_table(TableName=PYTEST_TABLE_NAME)
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def dynamodb_persistence_layer(dynamodb_client) -> DynamoDBPersistenceLayer:
|
||||
return DynamoDBPersistenceLayer(table_name, dynamodb_client)
|
||||
return DynamoDBPersistenceLayer(PYTEST_TABLE_NAME, dynamodb_client)
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def dynamodb_seeds(dynamodb_client):
|
||||
with jsonl.readlines('tests/seeds.jsonl') as lines:
|
||||
for line in lines:
|
||||
dynamodb_client.put_item(TableName=table_name, Item=line)
|
||||
dynamodb_client.put_item(TableName=PYTEST_TABLE_NAME, Item=line)
|
||||
|
||||
Reference in New Issue
Block a user