Skip to content

Commit 06f3fd1

Browse files
committed
fix: fix tests post migration to uv, format using ruff
1 parent a9c22c6 commit 06f3fd1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+2691
-1184
lines changed

unicorn_contracts/pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ authors = [
66
{name = "Amazon Web Services"}
77
]
88
readme = "README.md"
9-
requires-python = ">=3.13"
9+
requires-python = ">=3.12"
1010

1111
dependencies = [
1212
"aws-lambda-powertools[tracer]>=3.9.0",
1313
"aws-xray-sdk>=2.14.0",
1414
"boto3>=1.37.23",
1515
]
1616

17-
[dependency-groups]
17+
[project.optional-dependencies]
1818
dev = [
1919
"aws-lambda-powertools[all]>=3.9.0",
2020
"requests>=2.32.3",
@@ -24,6 +24,7 @@ dev = [
2424
"arnparse>=0.0.2",
2525
"pytest>=8.3.4",
2626
"ruff>=0.9.7",
27+
"tomli>=2.2.1",
2728
]
2829

2930
[tool.setuptools]

unicorn_contracts/pytest.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[pytest]
2+
pythonpath = src

unicorn_contracts/template.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Globals:
4646
Api:
4747
OpenApiVersion: 3.0.1
4848
Function:
49-
Runtime: python3.13
49+
Runtime: python3.12
5050
MemorySize: 128
5151
Timeout: 3
5252
Tracing: Active

unicorn_contracts/tests/integration/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212

1313
#### CONSTANTS
14-
DEFAULT_SAM_CONFIG_FILE = Path(__file__).parent.parent.parent.resolve() / 'samconfig.toml'
14+
DEFAULT_SAM_CONFIG_FILE = Path(__file__).parent.parent.parent.resolve() / "samconfig.toml"
1515
STACK_OUTPUTS = dict()
1616
EVENTS_DIR = Path(__file__).parent / "events"
1717

@@ -23,9 +23,9 @@
2323

2424

2525
def get_stack_name(samconfig: Path | str = DEFAULT_SAM_CONFIG_FILE) -> str:
26-
with open(samconfig, 'rb') as f:
26+
with open(samconfig, "rb") as f:
2727
conf = tomli.load(f)
28-
stack_name = conf['default']['global']['parameters']['stack_name']
28+
stack_name = conf["default"]["global"]["parameters"]["stack_name"]
2929

3030
return stack_name
3131

unicorn_contracts/uv.lock

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

unicorn_properties/Makefile

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
#### Global Variables
2-
stackName := $(shell yq -ot '.default.global.parameters.stack_name' samconfig.toml)
2+
stackName := $(shell yq -r '.default.global.parameters.stack_name' samconfig.toml)
33

44

55
#### Test Variables
66

77

88
#### Build/Deploy Tasks
99
build:
10+
ruff format
1011
sam validate --lint
1112
cfn-lint template.yaml -a cfn_lint_serverless.rules
1213
poetry export --without-hashes --format=requirements.txt --output=src/requirements.txt
1314
sam build -c $(DOCKER_OPTS)
1415

1516
deps:
16-
poetry install
17+
uv sync
1718

1819
deploy: deps build
1920
sam deploy
@@ -23,7 +24,7 @@ deploy: deps build
2324
test: unit-test
2425

2526
unit-test:
26-
poetry run pytest tests/unit/
27+
uv run pytest tests/unit/
2728

2829

2930
#### Utilities
@@ -43,6 +44,6 @@ delete:
4344

4445
# NOTE: [2023-05-09] This is a fix for installing Poetry dependencies in GitHub Actions
4546
ci_init:
46-
poetry export --without-hashes --format=requirements.txt --output=src/requirements.txt --with dev
47-
poetry run pip install -r src/requirements.txt
48-
poetry install -n
47+
uv export --no-hashes --format=requirements.txt --output-file=src/requirements.txt --extra=dev
48+
uv run pip install -r src/requirements.txt
49+
uv sync

unicorn_properties/pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ authors = [
66
{name = "Amazon Web Services"}
77
]
88
readme = "README.md"
9-
requires-python = ">=3.13"
9+
requires-python = ">=3.12"
1010

1111
dependencies = [
1212
"aws-lambda-powertools[tracer]>=3.9.0",
1313
"aws-xray-sdk>=2.14.0",
1414
"boto3>=1.37.23",
1515
]
1616

17-
[dependency-groups]
17+
[project.optional-dependencies]
1818
dev = [
1919
"aws-lambda-powertools[all]>=3.9.0",
2020
"requests>=2.32.3",

unicorn_properties/pytest.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[pytest]
2+
pythonpath = src

unicorn_properties/src/properties_service/contract_status_changed_event_handler.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ def lambda_handler(event, context):
5252
The same input event file
5353
"""
5454
# Deserialize event into strongly typed object
55-
awsEvent:AWSEvent = Marshaller.unmarshall(event, AWSEvent) # type: ignore
56-
detail:ContractStatusChanged = awsEvent.detail # type: ignore
55+
awsEvent: AWSEvent = Marshaller.unmarshall(event, AWSEvent) # type: ignore
56+
detail: ContractStatusChanged = awsEvent.detail # type: ignore
5757

5858
save_contract_status(detail)
5959

@@ -77,13 +77,11 @@ def save_contract_status(contract_status_changed_event):
7777
logger.info("Saving contract status to contract status table. %s", contract_status_changed_event.contract_id)
7878

7979
return table.update_item(
80-
Key={
81-
'property_id': contract_status_changed_event.property_id
82-
},
83-
UpdateExpression="set contract_status=:t, contract_last_modified_on=:m, contract_id=:c",
84-
ExpressionAttributeValues={
85-
':c': contract_status_changed_event.contract_id,
86-
':t': contract_status_changed_event.contract_status,
87-
':m': contract_status_changed_event.contract_last_modified_on
88-
}
89-
)
80+
Key={"property_id": contract_status_changed_event.property_id},
81+
UpdateExpression="set contract_status=:t, contract_last_modified_on=:m, contract_id=:c",
82+
ExpressionAttributeValues={
83+
":c": contract_status_changed_event.contract_id,
84+
":t": contract_status_changed_event.contract_status,
85+
":m": contract_status_changed_event.contract_last_modified_on,
86+
},
87+
)

unicorn_properties/src/properties_service/exceptions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
# SPDX-License-Identifier: MIT-0
33

4+
45
class ContractStatusNotFoundException(Exception):
56
"""
67
Custom exception for encapsulating exceptions Contract Status for a specified property is not found

0 commit comments

Comments
 (0)