I'm trying to create a dynamoDB in a pytest fixture and use it in other tests to reduce code redundancy, but having some issues.
@pytest.fixture
@mock_dynamodb
def create_test_table(self, mocker):
table_name = "table"
dynamodb = boto3.resource("dynamodb")
table = dynamodb.create_table(
TableName=table_name,
KeySchema=[
{"AttributeName": "name"},
],
AttributeDefinitions=[
{"AttributeName": "name", "AttributeType": "S"},
]
)
return table
def test_get_item_from_table_found(self, mocker, create_test_table):
table = create_test_table
item = dict()
item["name"] = "name"
table.put_item(Item=item)
...
I keep running into a An error occurred (ResourceNotFoundException) when calling the PutItem operation: Requested resource not found
. I've debugged the code and it looks like the context for the table
is correctly passed through