COLAB_HEADER = """import sys
if 'google.colab' in sys.modules:
!pip --quiet install open-atmos-jupyter-utils
from open_atmos_jupyter_utils import pip_install_on_colab
pip_install_on_colab('PySDM-examples')"""
def test_first_cell_contains_three_badges(notebook):
""" checks if all notebooks feature nbviewer, mybinder and Colab badges (in the first cell) """
with open(notebook) as fp:
nb = nbformat.read(fp, nbformat.NO_CONVERT)
assert len(nb.cells) > 0
assert nb.cells[0].cell_type == "markdown"
lines = nb.cells[0].source.split("\n")
assert len(lines) == 3
assert lines[0] == _nbviewer_badge_markdown(notebook)
assert lines[1] == _mybinder_badge_markdown(notebook)
assert lines[2] == _colab_badge_markdown(notebook)
def test_second_cell_contains_colab_header(notebook):
""" checks if all notebooks feature a Colab-magick cell (just below badges) """
with open(notebook) as fp:
nb = nbformat.read(fp, nbformat.NO_CONVERT)
assert len(nb.cells) > 1
assert nb.cells[0].cell_type == "code"
assert nb.cells[1].source == COLAB_HEADER
def test_third_cell_is_a_markdown_cell(notebook):
""" checks if all notebooks have their third cell with some markdown (hopefully clarifying what the example is about) """
with open(notebook) as fp:
nb = nbformat.read(fp, nbformat.NO_CONVERT)
assert len(nb.cells) > 2
assert nb.cells[2].cell_type == "markdown"
something like this?