(datadir: Path)
| 9 | |
| 10 | |
| 11 | def test_markdown_format(datadir: Path): |
| 12 | text = """ |
| 13 | # My wicked markdown |
| 14 | |
| 15 | {{plot}} |
| 16 | |
| 17 | As above we do ... |
| 18 | |
| 19 | {{select}} |
| 20 | |
| 21 | Here's the dataset used... |
| 22 | |
| 23 | {{}} |
| 24 | """ |
| 25 | |
| 26 | table_asset = gen_df() |
| 27 | plot_asset = dp.Plot(data=gen_plot(), caption="Plot Asset") |
| 28 | select_asset = dp.Select(dp.Text("Hello"), "World") |
| 29 | |
| 30 | # missing context |
| 31 | with pytest.raises(dp.DPClientError): |
| 32 | dp.Text(text).format(table_asset, plot=plot_asset, select1=select_asset) |
| 33 | with pytest.raises(dp.DPClientError): |
| 34 | dp.Text(text).format(plot=plot_asset, select=select_asset) |
| 35 | |
| 36 | # test string |
| 37 | group = dp.Text(text).format(table_asset, plot=plot_asset, select=select_asset) |
| 38 | assert isinstance(group, dp.Group) |
| 39 | assert glom(group, ("blocks", ["_tag"])) == ["Text", "Plot", "Text", "Select", "Text", "Table"] |
| 40 | |
| 41 | # test file |
| 42 | group = dp.Text(file=datadir / "report.md").format(table_asset, plot=plot_asset, select=select_asset) |
| 43 | assert isinstance(group, dp.Group) |
| 44 | assert glom(group, ("blocks", ["_tag"])) == ["Text", "Plot", "Text", "Select", "Text", "Table"] |
| 45 | assert "file-input" in dp.Blocks(group).get_dom_str() |
| 46 | assert "file-input" in glom(group, "blocks.0.content") |
nothing calls this directly
no test coverage detected