def test_renderers(content): r = Report() r.widget(content[0]) assert isinstance(r.get_configuration().elements[0].content, content[1]) with tempfile.TemporaryDirectory() as tmpdir: r.render(os.path.join(tmpdir, "index.html"))
def test_basic_report(): r = Report() r.widget(None) with pytest.raises(pydantic.error_wrappers.ValidationError): r.header(None) r.header("Some header") r.header("Some header", description="Some description") with pytest.raises(pydantic.error_wrappers.ValidationError): r.text(None) r.text("Some text") r.text("Some header", description="Some description") assert len(r.elements) == 5 config = r.get_configuration() assert isinstance(config, ReportConfiguration) assert len(config.elements) == 5
def f(value: Optional[str] = None): r = Report() r.text("# Report served with the API") if value is None: r.text( """ No value provided. Try to add a value in the search string. For example [like this](http://localhost:8000?value="with a value") """, name="Result here", ) else: r.text(f"The value was {value}", name="Result here") return r.get_configuration()