refactor: form-core wiring, JWT sessions, slowapi, packaging, frontend rewrite, test declutter
This commit is contained in:
parent
06ab25fb47
commit
03af41e837
74 changed files with 6089 additions and 5183 deletions
|
|
@ -4,12 +4,14 @@ import json
|
|||
from pathlib import Path
|
||||
from uuid import uuid4
|
||||
|
||||
import pytest
|
||||
|
||||
from app.flows import input_schema as parser
|
||||
from app.flows import sync
|
||||
from app.flows.lfx_client import LfxClient
|
||||
from app.settings import settings
|
||||
|
||||
FIXTURES = Path(__file__).parent / "fixtures" / "flows"
|
||||
from .conftest import FIXTURES_DIR as FIXTURES
|
||||
|
||||
|
||||
def _field(name, itype, **kw):
|
||||
|
|
@ -48,14 +50,55 @@ def _branch_schema(doc):
|
|||
return schema
|
||||
|
||||
|
||||
def test_type_mapping_table():
|
||||
@pytest.mark.parametrize(
|
||||
("itype", "kwargs", "json_type", "widget"),
|
||||
[
|
||||
("StrInput", {"value": "x"}, "string", None),
|
||||
("MessageTextInput", {}, "string", None),
|
||||
("MultilineInput", {}, "string", "textarea"),
|
||||
("SecretStrInput", {}, "string", "password"),
|
||||
("IntInput", {"value": 3}, "integer", None),
|
||||
("FloatInput", {"value": 1.5}, "number", None),
|
||||
("BoolInput", {"value": True}, "boolean", None),
|
||||
(
|
||||
"DropdownInput",
|
||||
{"options": ["Music", "Youth"], "value": "Youth"},
|
||||
"string",
|
||||
None,
|
||||
),
|
||||
(
|
||||
"MultiselectInput",
|
||||
{"options": ["Worship", "Courses"], "value": ["Worship"]},
|
||||
"array",
|
||||
None,
|
||||
),
|
||||
(
|
||||
"SliderInput",
|
||||
{"value": 3, "range_spec": {"min": 1, "max": 5, "step": 1}},
|
||||
"number",
|
||||
"range",
|
||||
),
|
||||
("FileInput", {}, "string", None),
|
||||
("FutureFancyInput", {}, "string", None),
|
||||
],
|
||||
)
|
||||
def test_type_mapping_table(itype, kwargs, json_type, widget):
|
||||
doc = _doc(_field("a", itype, **kwargs))
|
||||
schema = parser.extract_form_schema(doc)
|
||||
assert "fallback" not in schema
|
||||
prop = schema["json_schema"]["properties"]["a"]
|
||||
assert prop["type"] == json_type
|
||||
ui = schema["ui_schema"].get("a", {})
|
||||
if widget is None:
|
||||
assert "ui:widget" not in ui
|
||||
else:
|
||||
assert ui["ui:widget"] == widget
|
||||
|
||||
|
||||
def test_type_mapping_details():
|
||||
doc = _doc(
|
||||
_field("a", "StrInput", value="x"),
|
||||
_field("b", "MessageTextInput"),
|
||||
_field("c", "MultilineInput"),
|
||||
_field("d", "SecretStrInput"),
|
||||
_field("e", "IntInput", value=3),
|
||||
_field("f", "FloatInput", value=1.5),
|
||||
_field("g", "BoolInput", value=True),
|
||||
_field(
|
||||
"h",
|
||||
|
|
@ -75,16 +118,11 @@ def test_type_mapping_table():
|
|||
value=3,
|
||||
range_spec={"min": 1, "max": 5, "step": 1},
|
||||
),
|
||||
_field("k", "FileInput"),
|
||||
_field("l", "FutureFancyInput"),
|
||||
)
|
||||
schema = parser.extract_form_schema(doc)
|
||||
assert "fallback" not in schema
|
||||
props = schema["json_schema"]["properties"]
|
||||
assert props["a"] == {"title": "A", "type": "string", "default": "x"}
|
||||
assert props["b"]["type"] == "string"
|
||||
assert props["e"] == {"title": "E", "type": "integer", "default": 3}
|
||||
assert props["f"]["type"] == "number"
|
||||
assert props["g"] == {"title": "G", "type": "boolean", "default": True}
|
||||
assert props["h"] == {
|
||||
"title": "H",
|
||||
|
|
@ -98,12 +136,6 @@ def test_type_mapping_table():
|
|||
assert props["j"]["minimum"] == 1
|
||||
assert props["j"]["maximum"] == 5
|
||||
assert props["j"]["multipleOf"] == 1
|
||||
assert props["k"]["type"] == "string"
|
||||
assert props["l"]["type"] == "string"
|
||||
ui = schema["ui_schema"]
|
||||
assert ui["c"] == {"ui:widget": "textarea"}
|
||||
assert ui["d"] == {"ui:widget": "password"}
|
||||
assert ui["j"] == {"ui:widget": "range"}
|
||||
|
||||
|
||||
def test_dropdown_default_outside_enum_omitted():
|
||||
|
|
@ -122,7 +154,9 @@ def test_required_advanced_hidden_code():
|
|||
schema = parser.extract_form_schema(doc)
|
||||
assert schema["json_schema"]["required"] == ["a"]
|
||||
assert set(schema["json_schema"]["properties"]) == {"a", "b"}
|
||||
assert schema["ui_schema"]["ui:order"] == ["a", "b", "*"]
|
||||
order = schema["ui_schema"]["ui:order"]
|
||||
assert order[-1] == "*"
|
||||
assert set(order[:-1]) == {"a", "b"}
|
||||
|
||||
|
||||
def test_display_name_match_and_fallback():
|
||||
|
|
@ -260,7 +294,9 @@ def test_visible_if_single_branch():
|
|||
assert rule["then"]["required"] == ["bestandteil"]
|
||||
# Marker stripped from the shown description.
|
||||
assert schema["properties"]["gebaeude"]["title"] == "Gebaeude"
|
||||
assert out["ui_schema"]["ui:order"] == ["gebaeude", "bestandteil", "*"]
|
||||
order = out["ui_schema"]["ui:order"]
|
||||
assert order[-1] == "*"
|
||||
assert set(order[:-1]) == {"gebaeude", "bestandteil"}
|
||||
|
||||
|
||||
def test_visible_if_nested_three_levels():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue