Skip to content

Commit 3f79313

Browse files
committed
feat: add examples directory
1 parent 548e936 commit 3f79313

File tree

6 files changed

+45
-0
lines changed

6 files changed

+45
-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+
from aws_durable_execution_sdk_python.context import DurableContext
3+
from aws_durable_execution_sdk_python.execution import durable_handler
4+
5+
6+
@durable_handler
7+
def handler(event: Any, context: DurableContext) -> str:
8+
"""Simple hello world durable function."""
9+
print("Hello world from a 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: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"""Integration tests for example durable functions."""
2+
3+
import pytest
4+
from aws_durable_execution_sdk_python.execution import InvocationStatus
5+
from aws_durable_execution_sdk_python_testing.runner import (
6+
DurableFunctionTestResult,
7+
DurableFunctionTestRunner,
8+
)
9+
10+
from src import hello_world
11+
12+
13+
class TestExamples:
14+
"""Integration tests for examples."""
15+
16+
def test_hello_world(self):
17+
"""Test hello world example."""
18+
with DurableFunctionTestRunner(handler=hello_world.handler) as runner:
19+
result: DurableFunctionTestResult = runner.run(
20+
input="test", timeout=10
21+
)
22+
23+
assert result.status is InvocationStatus.SUCCEEDED
24+
assert result.result == '"Hello World!"'

pyproject.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ Source = "https://github.com/aws/aws-durable-execution-sdk-python-testing"
3232

3333
[tool.hatch.build.targets.sdist]
3434
packages = ["src/aws_durable_execution_sdk_python_testing"]
35+
include = ["examples/"]
3536

3637
[tool.hatch.build.targets.wheel]
3738
packages = ["src/aws_durable_execution_sdk_python_testing"]
39+
include = ["examples/"]
3840

3941
[tool.hatch.metadata]
4042
allow-direct-references = true
@@ -53,9 +55,12 @@ dependencies = [
5355
"coverage[toml]",
5456
"pytest",
5557
"pytest-cov",
58+
"aws_durable_execution_sdk_python @ git+ssh://git@github.com/aws/aws-durable-execution-sdk-python.git"
5659
]
5760

5861
[tool.hatch.envs.test.scripts]
62+
test = "pytest tests/ -v"
63+
examples = "pytest examples/test/ -v"
5964
cov="pytest --cov-report=term-missing --cov-config=pyproject.toml --cov=src/aws_durable_execution_sdk_python_testing --cov=tests --cov-fail-under=99"
6065

6166
[tool.hatch.envs.types]

0 commit comments

Comments
 (0)