Skip to content

Add an initial draft for test utilities #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Nov 27, 2024
Merged

Add an initial draft for test utilities #11

merged 7 commits into from
Nov 27, 2024

Conversation

giograno
Copy link
Member

@giograno giograno commented Nov 15, 2024

This PR adds some initial test utilities (fixtures and decorators) to the Python SDK.
In particular, two utilities have been added.

A @cloudpods decorator that can be used as follows:

@cloudpods(name="pod-name")
def test_something():
    # do something with the loaded state
    pass

A cloud pod with a given name is loaded before the test runs and the state of the container is reset at the end of the test execution.

A reset_state fixture that simply resets the state of the container after test execution.

@giograno giograno marked this pull request as ready for review November 15, 2024 17:16
from localstack.sdk.testing import cloudpods

DECORATOR_POD_NAME = "ls-sdk-pod-decorator"
QUEUE_NAME = "ls-decorator-queue"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be a good idea to use names with a random element, or perhaps handle exceptions in fixture teardowns

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My idea was to simply keep pushing on the same pod which simply creates a new version. This way we don't have to think about randomness or exceptions.

@giograno giograno merged commit f19e2f9 into main Nov 27, 2024
1 check passed
@giograno giograno deleted the pytest-plugin branch November 27, 2024 23:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants