Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 11 additions & 28 deletions unicorn_contracts/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 5 additions & 10 deletions unicorn_contracts/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,17 @@ name = "contracts_service"
version = "0.2.0"
description = "Unicorn Properties Contact Service"
authors = ["Amazon Web Services"]
packages = [
{ include = "contracts_service", from = "src" },
]
packages = [{ include = "contracts_service", from = "src" }]

[tool.poetry.dependencies]
python = "^3.11"
boto3 = "^1.28.32"
aws-lambda-powertools = {extras = ["aws-sdk"], version = "^2.23.0"}
boto3 = "^1.28"
aws-lambda-powertools = { extras = ["aws-sdk"], version = "^2.23.0" }
aws-xray-sdk = "^2.12.0"

[tool.poetry.group.dev.dependencies]
pytest = "^7.4.0"
pytest-mock = "^3.11.1"
# pytest-mock = "^3.11.1"
requests = "^2.31.0"
moto = "^4.1.13"
importlib-metadata = "^6.8.0"
Expand All @@ -29,10 +27,7 @@ build-backend = "poetry.core.masonry.api"
[tool.pytest.ini_options]
minversion = "7.0"
addopts = "-ra -vv -W ignore::UserWarning"
testpaths = [
"./tests/unit",
"./tests/integration",
]
testpaths = ["tests/unit", "tests/integration"]

[tool.ruff]
line-length = 150
41 changes: 12 additions & 29 deletions unicorn_properties/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 5 additions & 8 deletions unicorn_properties/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "properties_service"
version = "0.1.0"
version = "0.2.0"
description = "Unicorn Properties Property Service"
authors = ["Amazon Web Services"]
packages = [
Expand All @@ -10,13 +10,13 @@ packages = [

[tool.poetry.dependencies]
python = "^3.11"
boto3 = "^1.28.32"
aws-lambda-powertools = {extras = ["tracer"], version = "^2.23.0"}
boto3 = "^1.28"
aws-lambda-powertools = { extras = ["aws-sdk"], version = "^2.23.0" }
aws-xray-sdk = "^2.12.0"

[tool.poetry.group.dev.dependencies]
pytest = "^7.4.0"
pytest-mock = "^3.11.1"
# pytest-mock = "^3.11.1"
requests = "^2.31.0"
moto = "^4.1.13"
importlib-metadata = "^6.8.0"
Expand All @@ -30,10 +30,7 @@ build-backend = "poetry.core.masonry.api"
[tool.pytest.ini_options]
minversion = "7.0"
addopts = "-ra -vv -W ignore::UserWarning"
testpaths = [
"tests/unit",
"tests/integration",
]
testpaths = ["tests/unit", "tests/integration"]

[tool.ruff]
line-length = 150
16 changes: 16 additions & 0 deletions unicorn_properties/tests/unit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os

import boto3
from aws_lambda_powertools.utilities.typing import LambdaContext

import pytest
from moto import mock_dynamodb, mock_events, mock_stepfunctions
Expand Down Expand Up @@ -34,3 +35,18 @@ def eventbridge(aws_credentials):
def stepfunction(aws_credentials):
with mock_stepfunctions():
yield boto3.client("stepfunctions", region_name='ap-southeast-2')


@pytest.fixture(scope='function')
def lambda_context():
context: LambdaContext = LambdaContext()
context._function_name="propertiesService-LambdaFunction-HJsvdah2ubi2"
context._function_version="$LATEST"
context._invoked_function_arn="arn:aws:lambda:ap-southeast-2:424490683636:function:propertiesService-LambdaFunction-HJsvdah2ubi2"
context._memory_limit_in_mb=128
context._aws_request_id="6f970d26-71d6-4c87-a196-9375f85c7b07"
context._log_group_name="/aws/lambda/propertiesService-LambdaFunction-HJsvdah2ubi2"
context._log_stream_name="2022/07/14/[$LATEST]7c71ca59882b4c569dd007c7e41c81e8"
# context._identity=CognitoIdentity([cognito_identity_id=None,cognito_identity_pool_id=None])])
# context._client_context=None
return context
25 changes: 16 additions & 9 deletions unicorn_properties/tests/unit/helper.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0

import json
from pathlib import Path


TABLE_NAME = 'table1'
EVENTBUS_NAME = 'test-eventbridge'
EVENTS_DIR = Path(__file__).parent / 'events'


def load_event(filename):
with open(filename) as f:
data = json.load(f)
return data
return json.load(open(EVENTS_DIR / f'{filename}.json', 'r'))


def return_env_vars_dict(k={}):
d = {
"AWS_DEFAULT_REGION": "ap-southeast-2",
"CONTRACT_STATUS_TABLE": TABLE_NAME,
"EVENT_BUS": "test-eventbridge",
"EVENT_BUS": EVENTBUS_NAME,
"SERVICE_NAMESPACE": "unicorn.properties",
"POWERTOOLS_SERVICE_NAME":"unicorn.properties",
"POWERTOOLS_TRACE_DISABLED":"true",
"POWERTOOLS_LOGGER_LOG_EVENT":"true",
"POWERTOOLS_LOGGER_SAMPLE_RATE":"0.1",
"POWERTOOLS_METRICS_NAMESPACE":"unicorn.contracts",
"POWERTOOLS_SERVICE_NAME":"unicorn.contracts",
"POWERTOOLS_TRACE_DISABLED":"true",
"SERVICE_NAMESPACE": "unicorn.properties",
"POWERTOOLS_METRICS_NAMESPACE":"unicorn.properties",
"LOG_LEVEL": "INFO",
}
d.update(k)
return d
Expand Down Expand Up @@ -89,3 +91,8 @@ def create_ddb_table_contracts_with_entry(dynamodb):
}
table.put_item(Item=contract)
return table


def create_test_eventbridge_bus(eventbridge):
bus = eventbridge.create_event_bus(Name=EVENTBUS_NAME)
return bus
17 changes: 0 additions & 17 deletions unicorn_properties/tests/unit/lambda_context.py

This file was deleted.

Loading