MCPcopy Create free account
hub / github.com/datapane/datapane / test_markdown_format

Function test_markdown_format

python-client/tests/client/views/test_misc.py:11–46  ·  view source on GitHub ↗
(datadir: Path)

Source from the content-addressed store, hash-verified

9
10
11def test_markdown_format(datadir: Path):
12 text = """
13# My wicked markdown
14
15{{plot}}
16
17As above we do ...
18
19{{select}}
20
21Here'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")

Callers

nothing calls this directly

Calls 4

gen_dfFunction · 0.90
gen_plotFunction · 0.90
formatMethod · 0.80
get_dom_strMethod · 0.80

Tested by

no test coverage detected