Fixtures for testing code that interacts with AWS
Project description
pytest-moto-fixtures
pytest fixtures for testing code that integrates with AWS using moto as a mock.
Install
Install pytest-moto-fixtures package from PyPI:
pip install pytest-moto-fixtures[pytest]
Examples of Use
Code for test:
class Example:
def __init__(self, sqs_client, queue_url):
self._sqs_client = sqs_client
self._queue_url = queue_url
def run(self, values):
total = 0
for value in values:
total += value
self._sqs_client.send_message(QueueUrl=self._queue_url, MessageBody=f'Value processed: {value}')
return total
Test example using fixture:
from random import randint
def test_example_with_fixture(sqs_queue):
values = [randint(1, 10) for _ in range(randint(3, 10))]
expected = sum(values)
sut = Example(sqs_client=sqs_queue.client, queue_url=sqs_queue.url)
returned = sut.run(values)
assert returned == expected
assert len(sqs_queue) == len(values)
for value, message in zip(values, sqs_queue):
assert message['Body'] == f'Value processed: {value}'
Test example using context:
from random import randint
from pytest_moto_fixtures.services.sqs import sqs_create_queue
def test_example_with_context(sqs_client):
values = [randint(1, 10) for _ in range(randint(3, 10))]
expected = sum(values)
with sqs_create_queue(sqs_client=sqs_client, name='my-queue') as sqs_queue:
sut = Example(sqs_client=sqs_client, queue_url=sqs_queue.url)
returned = sut.run(values)
assert returned == expected
assert len(sqs_queue) == len(values)
for value, message in zip(values, sqs_queue):
assert message['Body'] == f'Value processed: {value}'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytest_moto_fixtures-0.0.1a4.tar.gz.
File metadata
- Download URL: pytest_moto_fixtures-0.0.1a4.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f353cbe16b4fdac37018836a0994fc468a09a5999850977f316b40bd95258453
|
|
| MD5 |
30393d229547a4fbc4ddc305e653fcff
|
|
| BLAKE2b-256 |
bcbfd8f5fafc4742af0a65f63552f50cca00aa3d2161965610abeb9ab770c2dc
|
Provenance
The following attestation bundles were made for pytest_moto_fixtures-0.0.1a4.tar.gz:
Publisher:
release.yml on eduardoklosowski/pytest-moto-fixtures
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytest_moto_fixtures-0.0.1a4.tar.gz -
Subject digest:
f353cbe16b4fdac37018836a0994fc468a09a5999850977f316b40bd95258453 - Sigstore transparency entry: 704332499
- Sigstore integration time:
-
Permalink:
eduardoklosowski/pytest-moto-fixtures@4c1ada35d7cb6b687dda0aff51392e55fe1d826f -
Branch / Tag:
refs/tags/v0.0.1a4 - Owner: https://github.com/eduardoklosowski
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4c1ada35d7cb6b687dda0aff51392e55fe1d826f -
Trigger Event:
push
-
Statement type:
File details
Details for the file pytest_moto_fixtures-0.0.1a4-py3-none-any.whl.
File metadata
- Download URL: pytest_moto_fixtures-0.0.1a4-py3-none-any.whl
- Upload date:
- Size: 12.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
227b696417492878a7c0395ddc760656ae9f59efbf239fca05050425b01ad0ac
|
|
| MD5 |
79ede51c34b94b4c4f2fc16a5e125e72
|
|
| BLAKE2b-256 |
89395973a1869007a2e2bea1eb34b670d03bf757a7cdd980f7cfdc89552e9592
|
Provenance
The following attestation bundles were made for pytest_moto_fixtures-0.0.1a4-py3-none-any.whl:
Publisher:
release.yml on eduardoklosowski/pytest-moto-fixtures
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytest_moto_fixtures-0.0.1a4-py3-none-any.whl -
Subject digest:
227b696417492878a7c0395ddc760656ae9f59efbf239fca05050425b01ad0ac - Sigstore transparency entry: 704332520
- Sigstore integration time:
-
Permalink:
eduardoklosowski/pytest-moto-fixtures@4c1ada35d7cb6b687dda0aff51392e55fe1d826f -
Branch / Tag:
refs/tags/v0.0.1a4 - Owner: https://github.com/eduardoklosowski
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@4c1ada35d7cb6b687dda0aff51392e55fe1d826f -
Trigger Event:
push
-
Statement type: