Skip to content

Commit e7af6d8

Browse files
committed
Add support for the reset state operation (#4)
1 parent 68de1c0 commit e7af6d8

File tree

5 files changed

+89
-1
lines changed

5 files changed

+89
-1
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from localstack.sdk.state.client import StateClient
2+
3+
__all__ = ["StateClient"]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from localstack.clients import BaseClient
2+
from localstack.sdk.api import StateApi
3+
4+
5+
class StateClient(BaseClient):
6+
def __init__(self, **args) -> None:
7+
super().__init__(**args)
8+
self._client = StateApi(self._api_client)
9+
10+
def reset_state(self) -> None:
11+
self._client.localstack_state_reset_post_0()

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ readme = { file = ["README.md"], content-type = "text/markdown"}
2626
[tool.uv]
2727
dev-dependencies=[
2828
"pytest",
29-
"ruff"
29+
"ruff",
30+
"boto3"
3031
]
3132

3233
[tool.uv.sources]

tests/integration/test_state.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import boto3
2+
import pytest
3+
4+
from localstack.sdk.state import StateClient
5+
6+
7+
class TestStateClient:
8+
client = StateClient()
9+
10+
def test_reset_state(self):
11+
sqs_client = boto3.client(
12+
"sqs", endpoint_url=self.client.configuration.host, region_name="us-east-1"
13+
)
14+
sqs_client.create_queue(QueueName="test-queue")
15+
url = sqs_client.get_queue_url(QueueName="test-queue")["QueueUrl"]
16+
assert url
17+
18+
self.client.reset_state()
19+
20+
with pytest.raises(Exception) as exc:
21+
sqs_client.get_queue_url(QueueName="test-queue")
22+
assert "AWS.SimpleQueueService.NonExistentQueue" == exc.value.response["Error"]["Code"] # noqa

uv.lock

Lines changed: 51 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)