add fix
This commit is contained in:
52
http-api/tests/routes/test_enrollments.py
Normal file
52
http-api/tests/routes/test_enrollments.py
Normal file
@@ -0,0 +1,52 @@
|
||||
from http import HTTPMethod, HTTPStatus
|
||||
|
||||
from layercake.dynamodb import (
|
||||
ComposeKey,
|
||||
DynamoDBCollection,
|
||||
DynamoDBPersistenceLayer,
|
||||
KeyPair,
|
||||
PartitionKey,
|
||||
)
|
||||
|
||||
from ..conftest import HttpApiProxy, LambdaContext
|
||||
|
||||
|
||||
def test_cancel_enrollment(
|
||||
mock_app,
|
||||
dynamodb_seeds,
|
||||
dynamodb_persistence_layer: DynamoDBPersistenceLayer,
|
||||
http_api_proxy: HttpApiProxy,
|
||||
lambda_context: LambdaContext,
|
||||
):
|
||||
r = mock_app.lambda_handler(
|
||||
http_api_proxy(
|
||||
raw_path='/enrollments/43ea4475-c369-4f90-b576-135b7df5106b/cancel',
|
||||
method=HTTPMethod.PATCH,
|
||||
headers={'X-Tenant': '*'},
|
||||
body={
|
||||
'id': '43ea4475-c369-4f90-b576-135b7df5106b',
|
||||
'lock_hash': 'f8f7996aa99d50eb85266be5a9fca1db',
|
||||
'course': {
|
||||
'id': '123',
|
||||
'name': 'NR-10',
|
||||
'time_in_days': 720,
|
||||
},
|
||||
'vacancy': {
|
||||
'sk': 'QV4sXY3DvSTUMGJ4QqsrwJ#43ea4475-c369-4f90-b576-135b7df5106b',
|
||||
'id': 'vacancies#cJtK9SsnJhKPyxESe7g3DG',
|
||||
},
|
||||
},
|
||||
),
|
||||
lambda_context,
|
||||
)
|
||||
|
||||
assert r['statusCode'] == HTTPStatus.OK
|
||||
|
||||
collect = DynamoDBCollection(dynamodb_persistence_layer)
|
||||
enrollment = collect.get_item(KeyPair('43ea4475-c369-4f90-b576-135b7df5106b', '0'))
|
||||
assert enrollment['status'] == 'CANCELED'
|
||||
|
||||
vacancies = collect.query(
|
||||
PartitionKey(ComposeKey('cJtK9SsnJhKPyxESe7g3DG', 'vacancies'))
|
||||
)
|
||||
assert len(vacancies['items']) == 1
|
||||
Reference in New Issue
Block a user