Skip to content

Commit 5e5c1cd

Browse files
authored
feat: add examples directory
2 parents 548e936 + 36f6ce3 commit 5e5c1cd

File tree

6 files changed

+40
-0
lines changed

6 files changed

+40
-0
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,7 @@ jobs:
3838
run: hatch run types:check
3939
- name: Run tests + coverage
4040
run: hatch run test:cov
41+
- name: Run example tests
42+
run: hatch run test:examples
4143
- name: Build distribution
4244
run: hatch build

examples/src/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"""AWS Durable Functions Python Examples."""
2+
3+
__version__ = "0.1.0"

examples/src/hello_world.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from typing import Any
2+
3+
from aws_durable_execution_sdk_python.context import DurableContext
4+
from aws_durable_execution_sdk_python.execution import durable_handler
5+
6+
7+
@durable_handler
8+
def handler(_event: Any, _context: DurableContext) -> str:
9+
"""Simple hello world durable function."""
10+
return "Hello World!"

examples/test/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Integration tests for AWS Durable Functions Python Examples."""

examples/test/test_hello_world.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"""Integration tests for example durable functions."""
2+
3+
from aws_durable_execution_sdk_python.execution import InvocationStatus
4+
5+
from aws_durable_execution_sdk_python_testing.runner import (
6+
DurableFunctionTestResult,
7+
DurableFunctionTestRunner,
8+
)
9+
from src import hello_world
10+
11+
12+
class TestExamples:
13+
"""Integration tests for examples."""
14+
15+
def test_hello_world(self):
16+
"""Test hello world example."""
17+
with DurableFunctionTestRunner(handler=hello_world.handler) as runner:
18+
result: DurableFunctionTestResult = runner.run(input="test", timeout=10)
19+
20+
assert result.status is InvocationStatus.SUCCEEDED # noqa: S101
21+
assert result.result == '"Hello World!"' # noqa: S101

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,12 @@ dependencies = [
5353
"coverage[toml]",
5454
"pytest",
5555
"pytest-cov",
56+
"aws_durable_execution_sdk_python @ git+ssh://git@github.com/aws/aws-durable-execution-sdk-python.git"
5657
]
5758

5859
[tool.hatch.envs.test.scripts]
60+
test = "pytest tests/ -v"
61+
examples = "pytest examples/test/ -v"
5962
cov="pytest --cov-report=term-missing --cov-config=pyproject.toml --cov=src/aws_durable_execution_sdk_python_testing --cov=tests --cov-fail-under=99"
6063

6164
[tool.hatch.envs.types]

0 commit comments

Comments
 (0)