Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Commit

Permalink
Incorporate fixture from pytest-dynamodb branch
Browse files Browse the repository at this point in the history
  • Loading branch information
lpsinger committed Mar 12, 2024
1 parent 0e41e5b commit 9d129b1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ dynamic = [ "version" ]
[project.optional-dependencies]
test = [
"pytest",
"pytest-dynamodb @ git+https://github.com/lpsinger/pytest-dynamodb@aioboto3",
"pytest-asyncio",
"pytest-dynamodb",
]

[project.urls]
Expand Down
24 changes: 22 additions & 2 deletions test_dynamodb_autoincrement.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,37 @@
# Administrator of the National Aeronautics and Space Administration.
# All Rights Reserved.

from botocore.exceptions import ClientError
import asyncio

import aioboto3
import pytest
from botocore.exceptions import ClientError
from pytest import FixtureRequest
from pytest_asyncio import fixture as asyncio_fixture
from pytest_dynamodb.factories import get_config

from dynamodb_autoincrement import DynamoDBAutoIncrement, DynamoDBHistoryAutoIncrement


N = 20


@asyncio_fixture
async def asyncio_dynamodb(request: FixtureRequest, dynamodb):
proc_fixture = request.getfixturevalue("dynamodb_proc")
config = get_config(request)

session = aioboto3.Session(
aws_access_key_id=config["aws_access_key"],
aws_secret_access_key=config["aws_secret_key"],
region_name=config["aws_region"],
)

async with session.resource(
"dynamodb", endpoint_url=f"http://{proc_fixture.host}:{proc_fixture.port}"
) as dynamo_db:
yield dynamo_db


@asyncio_fixture
async def create_tables(asyncio_dynamodb):
await asyncio.gather(
Expand Down

0 comments on commit 9d129b1

Please sign in to comment.