def test_report(tmp_path: Path): df = gen_df() name = gen_name() description = gen_description() source_url = "https://github.com/datapane/datapane" # create a basic report m = dp.Markdown("hello world!!") # Asset tests lis = [1, 2, 3] json_list: str = json.dumps(lis) plot = alt.Chart(df).mark_line().encode(x="x", y="y") # create the DP fn = tmp_path / "json_list.json" fn.write_text(data=json_list) file_asset = dp.File(file=fn) json_asset = dp.File(data=json_list, is_json=True) plot_asset = dp.Plot(data=plot) list_asset = dp.File(data=lis, is_json=True) df_asset = dp.Table(df=df, caption="Our Dataframe") dp_report = api.Report(m, file_asset, df_asset, json_asset, plot_asset, list_asset) dp_report.publish(name=name, description=description, source_url=source_url) with deletable(dp_report): # are the fields ok check_name(dp_report, name) assert dp_report.description == description assert dp_report.source_url == source_url assert len(dp_report._top_block.blocks[0].blocks) == 6
def test_report(tmp_path: Path): df = gen_df() name = gen_name() headline = gen_headline() # create a basic report m = dp.Markdown("hello world!!") # Asset tests lis = [1, 2, 3] json_list: str = json.dumps(lis) plot = alt.Chart(df).mark_line().encode(x="x", y="y") # create the DP fn = tmp_path / "json_list.json" fn.write_text(data=json_list) file_asset = dp.File(file=fn) json_asset = dp.File(data=json_list, is_json=True) plot_asset = dp.Plot(data=plot) list_asset = dp.File(data=lis, is_json=True) df_asset = dp.Table(df=df, caption="Our Dataframe") dp_report = api.Report(m, file_asset, df_asset, json_asset, plot_asset, list_asset) dp_report.publish(name=name, headline=headline) with deletable(dp_report): # are the fields ok assert dp_report.headline == headline assert len(dp_report.top_block.blocks) == 6
"""test_proj1 script""" __version__ = "0.1" import pandas as pd from datapane.client import api # TODO - enter your code here... df = pd.DataFrame.from_dict({"x": [4, 3, 2, 1], "y": [10.5, 20.5, 30.5, 40.5]}) """Render and return your datapane report components""" api.Report( # api.Markdown(f"Dummy Markdown block - {parameters.val}"), api.Markdown("Dummy Markdown block"), api.Asset.upload_df(df), )