MCPcopy
hub / github.com/coderamp-labs/gitingest / test_process_notebook_empty_cells

Function test_process_notebook_empty_cells

tests/test_notebook_utils.py:183–203  ·  view source on GitHub ↗

Test that cells with an empty ``source`` are skipped. Given a notebook with 4 cells, 3 of which have empty ``source``: When ``process_notebook`` is called, Then only the non-empty cell should appear in the output (1 block => 2 triple quotes).

(write_notebook: WriteNotebookFunc)

Source from the content-addressed store, hash-verified

181
182
183def test_process_notebook_empty_cells(write_notebook: WriteNotebookFunc) -> None:
184 """Test that cells with an empty ``source`` are skipped.
185
186 Given a notebook with 4 cells, 3 of which have empty ``source``:
187 When ``process_notebook`` is called,
188 Then only the non-empty cell should appear in the output (1 block => 2 triple quotes).
189 """
190 expected_count = 2
191 notebook_content = {
192 "cells": [
193 {"cell_type": "markdown", "source": []},
194 {"cell_type": "code", "source": []},
195 {"cell_type": "raw", "source": []},
196 {"cell_type": "markdown", "source": ["# Non-empty markdown"]},
197 ],
198 }
199 nb_path = write_notebook("empty_cells.ipynb", notebook_content)
200 result = process_notebook(nb_path)
201
202 assert result.count('"""') == expected_count, "Only one non-empty cell => 1 block => 2 triple quotes"
203 assert "# Non-empty markdown" in result
204
205
206def test_process_notebook_invalid_cell_type(write_notebook: WriteNotebookFunc) -> None:

Callers

nothing calls this directly

Calls 2

process_notebookFunction · 0.90
write_notebookFunction · 0.85

Tested by

no test coverage detected