Skip to content

Commit d1fad97

Browse files
committed
Validate notebook tags directly so tests run without executed outputs
1 parent 78368d7 commit d1fad97

1 file changed

Lines changed: 14 additions & 5 deletions

File tree

‎tests/test_plots.py‎

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import render
1+
import json
2+
from collections import defaultdict
23

34
defined_plots = {
45
"bar-counts": ["pandas", "plotnine", "ggplot", "plotly", "altair",],
@@ -32,7 +33,15 @@
3233

3334

3435
def test_exist():
35-
plots = render.extract_cells("Examples.ipynb")
36-
for name, slug in plots:
37-
names = [d["package-slug"] for d in plots[(name, slug)]]
38-
assert set(names) == set(defined_plots[slug])
36+
with open("Examples.ipynb") as f:
37+
nb = json.load(f)
38+
39+
found = defaultdict(set)
40+
for cell in nb["cells"]:
41+
tags = set(cell["metadata"].get("tags") or [])
42+
if "ex" not in tags:
43+
continue
44+
parsed = {t.split(":")[0]: t.split(":")[1] for t in tags if ":" in t}
45+
found[parsed["name"]].add(parsed["package"])
46+
47+
assert {k: set(v) for k, v in defined_plots.items()} == dict(found)

0 commit comments

Comments
 (0)