forked from Kludex/mangum
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_adapter.py
More file actions
33 lines (25 loc) · 856 Bytes
/
test_adapter.py
File metadata and controls
33 lines (25 loc) · 856 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import pytest
from mangum import Mangum
from mangum.adapter import DEFAULT_TEXT_MIME_TYPES
from mangum.exceptions import ConfigurationError
async def app(scope, receive, send):
...
def test_default_settings():
handler = Mangum(app)
assert handler.lifespan == "auto"
assert handler.config["api_gateway_base_path"] == "/"
assert sorted(handler.config["text_mime_types"]) == sorted(DEFAULT_TEXT_MIME_TYPES)
assert handler.config["exclude_headers"] == []
@pytest.mark.parametrize(
"arguments,message",
[
(
{"lifespan": "unknown"},
"Invalid argument supplied for `lifespan`. Choices are: auto|on|off",
),
],
)
def test_invalid_options(arguments, message):
with pytest.raises(ConfigurationError) as exc:
Mangum(app, **arguments)
assert str(exc.value) == message