Skip to content

Commit 7e7988f

Browse files
committed
test: add test for invalid property_id in contract_exists_checker_function
1 parent 9ce6e98 commit 7e7988f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

unicorn_properties/tests/unit/test_contract_exists_checker_function.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,20 @@ def test_existing_contract_exists_checker_function(dynamodb, mocker):
2424

2525
assert ret['property_id'] == stepfunctions_event['Input']['property_id']
2626
assert ret['address']['country'] == stepfunctions_event['Input']['country']
27+
28+
29+
@mock.patch.dict(os.environ, return_env_vars_dict(), clear=True)
30+
def test_missing_contract_exists_checker_function(dynamodb, mocker):
31+
stepfunctions_event = load_event('tests/events/lambda/contract_status_checker.json')
32+
stepfunctions_event['Input']['property_id'] = 'NOT/a/valid/CONTRACT'
33+
34+
from properties_service import contract_exists_checker_function
35+
from properties_service.exceptions import ContractStatusNotFoundException
36+
reload(contract_exists_checker_function)
37+
38+
create_ddb_table_contracts_with_entry(dynamodb)
39+
40+
with pytest.raises(ContractStatusNotFoundException) as errinfo:
41+
contract_exists_checker_function.lambda_handler(stepfunctions_event, LambdaContext())
42+
43+
assert errinfo.value.message == 'No contract found for specified Property ID'

0 commit comments

Comments
 (0)