add enroll to subscribed
This commit is contained in:
@@ -40,8 +40,8 @@ class DeduplicationConflictError(ConflictError): ...
|
||||
class User(BaseModel):
|
||||
id: str | UUID4
|
||||
name: NameStr
|
||||
cpf: CpfStr
|
||||
email: EmailStr
|
||||
cpf: CpfStr
|
||||
|
||||
|
||||
class Course(BaseModel):
|
||||
@@ -123,9 +123,9 @@ def enroll(
|
||||
Context = TypedDict(
|
||||
'Context',
|
||||
{
|
||||
'created_by': Authenticated,
|
||||
'org': Org,
|
||||
'terms': SubscriptionTerms,
|
||||
'created_by': Authenticated,
|
||||
},
|
||||
)
|
||||
|
||||
@@ -251,14 +251,12 @@ def enroll_later(enrollment: Enrollment, context: Context):
|
||||
'sk': f'{scheduled_for.isoformat()}#{lock_hash}',
|
||||
'user': user.model_dump(),
|
||||
'course': course.model_dump(),
|
||||
'org': org.model_dump(),
|
||||
'org_name': org.name,
|
||||
'created_by': {
|
||||
'id': created_by.id,
|
||||
'name': created_by.name,
|
||||
},
|
||||
'subscription_covered': {
|
||||
'billing_day': subscription_terms.billing_day,
|
||||
},
|
||||
'subscription_billing_day': subscription_terms.billing_day,
|
||||
'ttl': ttl(start_dt=scheduled_for),
|
||||
'created_at': now_,
|
||||
}
|
||||
|
||||
@@ -16,8 +16,7 @@ dyn = DynamoDBPersistenceLayer(ENROLLMENT_TABLE, dynamodb_client)
|
||||
@router.get('/<org_id>/enrollments/scheduled')
|
||||
def scheduled(org_id: str, start_key: Annotated[str | None, Query] = None):
|
||||
return dyn.collection.query(
|
||||
# Post-migration: rename `scheduled_items` to `SCHEDULED#ORG#{org_id}`
|
||||
key=PartitionKey(f'scheduled_items#{org_id}'),
|
||||
key=PartitionKey(f'SCHEDULED#ORG#{org_id}'),
|
||||
start_key=start_key,
|
||||
limit=150,
|
||||
)
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import json
|
||||
import pprint
|
||||
from http import HTTPMethod
|
||||
|
||||
from layercake.dynamodb import DynamoDBPersistenceLayer, PartitionKey
|
||||
@@ -26,14 +24,14 @@ def test_enroll(
|
||||
'user': {
|
||||
'id': '15bacf02-1535-4bee-9022-19d106fd7518',
|
||||
'name': 'Eddie Vedder',
|
||||
'email': 'sergio@somosbeta.com.br',
|
||||
'email': 'eddie@pearljam.band',
|
||||
'cpf': '07879819908',
|
||||
},
|
||||
'course': {
|
||||
'id': 'c27d1b4f-575c-4b6b-82a1-9b91ff369e0b',
|
||||
'name': 'NR-10',
|
||||
'name': 'NR-18 PEMT Plataforma Móvel de Trabalho Aéreo',
|
||||
'access_period': '360',
|
||||
'unit_price': '100.30',
|
||||
'unit_price': '149',
|
||||
},
|
||||
'scheduled_for': '2028-01-01',
|
||||
},
|
||||
@@ -61,11 +59,14 @@ def test_enroll(
|
||||
lambda_context,
|
||||
)
|
||||
|
||||
body = json.loads(r['body'])
|
||||
pprint.pp(body)
|
||||
|
||||
enrolled = dynamodb_persistence_layer.collection.query(
|
||||
PartitionKey('d0349bbe-cef3-44f7-b20e-3cb4476ab4c5')
|
||||
)
|
||||
|
||||
pprint.pp(enrolled)
|
||||
assert len(enrolled['items']) == 7
|
||||
|
||||
scheduled = dynamodb_persistence_layer.collection.query(
|
||||
PartitionKey('SCHEDULED#ORG#2a8963fc-4694-4fe2-953a-316d1b10f1f5')
|
||||
)
|
||||
|
||||
assert len(scheduled['items']) == 1
|
||||
|
||||
Reference in New Issue
Block a user