52 lines
1.3 KiB
Python
52 lines
1.3 KiB
Python
from http import HTTPMethod, HTTPStatus
|
|
|
|
from requests_toolbelt import MultipartEncoder
|
|
|
|
from ..conftest import HttpApiProxy, LambdaContext
|
|
|
|
|
|
def test_get_course(
|
|
app,
|
|
seeds,
|
|
http_api_proxy: HttpApiProxy,
|
|
lambda_context: LambdaContext,
|
|
):
|
|
r = app.lambda_handler(
|
|
http_api_proxy(
|
|
raw_path='/courses/2a8963fc-4694-4fe2-953a-316d1b10f1f5',
|
|
method=HTTPMethod.GET,
|
|
),
|
|
lambda_context,
|
|
)
|
|
assert r['statusCode'] == HTTPStatus.OK
|
|
|
|
|
|
def test_edit_course(
|
|
app,
|
|
seeds,
|
|
http_api_proxy: HttpApiProxy,
|
|
lambda_context: LambdaContext,
|
|
):
|
|
with open('tests/sample.html', 'rb') as f:
|
|
m = MultipartEncoder(
|
|
fields={
|
|
'given_cert': 'true',
|
|
'name': 'pytest',
|
|
'access_period': '365',
|
|
'cert.exp_interval': '360',
|
|
'cert.rawfile': f,
|
|
}
|
|
)
|
|
r = app.lambda_handler(
|
|
http_api_proxy(
|
|
raw_path='/courses/2a8963fc-4694-4fe2-953a-316d1b10f1f5',
|
|
method=HTTPMethod.POST,
|
|
headers={
|
|
'Content-Type': m.content_type,
|
|
},
|
|
body=m.to_string().decode(),
|
|
is_base64_encoded=True,
|
|
),
|
|
lambda_context,
|
|
)
|