wip checkout

This commit is contained in:
2026-01-09 11:20:56 -03:00
parent e29e81b253
commit 823134f450
18 changed files with 290 additions and 80 deletions

View File

@@ -1,9 +1,12 @@
import json
from datetime import date, datetime
from http import HTTPMethod, HTTPStatus
from pprint import pprint
from layercake.dynamodb import DynamoDBPersistenceLayer, PartitionKey
from routes.orders.checkout import _calc_due_date
from ...conftest import HttpApiProxy, LambdaContext
@@ -147,3 +150,33 @@ def test_checkout_from_user(
)
print(r)
assert r['statusCode'] == HTTPStatus.CREATED
def test_calc_due_date_skips_weekends_and_holidays():
start_date = datetime(2026, 1, 9, 10, 30) # Friday
business_days = 3
holidays = {
date(2026, 1, 12), # Monday (holiday)
}
result = _calc_due_date(
start_date=start_date,
business_days=business_days,
holidays=holidays,
)
# Mon (12) -> holiday (ignored)
# Tue (13) -> 1
# Wed (14) -> 2
# Thu (15) -> 3 ✅
expected = datetime(2026, 1, 15, 10, 30)
assert result == expected
def test_calc_due_date_only_weekends():
start_date = datetime(2026, 1, 8, 9, 0) # Thursday
result = _calc_due_date(start_date, 1)
assert result == datetime(2026, 1, 9, 9, 0)