Skip to content

test(scripts): add 19 tests for weekly_digest.py classify_notebook_changes (cycle 70)#1880

Merged
jsboige merged 1 commit into
mainfrom
test/weekly-digest-classify
May 30, 2026
Merged

test(scripts): add 19 tests for weekly_digest.py classify_notebook_changes (cycle 70)#1880
jsboige merged 1 commit into
mainfrom
test/weekly-digest-classify

Conversation

@jsboige
Copy link
Copy Markdown
Owner

@jsboige jsboige commented May 30, 2026

Summary

Add 19 unit tests for classify_notebook_changes in weekly_digest.py — the pure function that classifies changed files by notebook series and file type.

Test coverage

Class Tests What it covers
TestClassifySeriesDetection 7 Single/multiple series, name cap at 5, non-notebook files in series, backslash limitation (documented), shallow paths
TestClassifyOtherFiles 6 Python, C#, docs, config, other extensions, mixed file types
TestClassifyNotebookNames 2 Name extraction from paths, ordering
TestClassifyEdgeCases 4 Deeply nested paths, mixed separators, empty filename, set dedup

Notable finding

Windows backslash paths don't match the startswith('MyIA.AI.Notebooks/') check because it runs before the chr(92) normalization. Documented as a known limitation via test (test_backslash_path_not_matched).

Quality check

  • All 19 tests pass (0.08s)
  • 970 total tests in scripts suite (0 failures)
  • Tests the only pure function in weekly_digest.py (rest is subprocess-based)

Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com

…anges (cycle 70)

Tests cover the pure function classify_notebook_changes:
- Series detection (7): single/multiple series, name cap at 5,
  non-notebook files in series, backslash limitation, shallow paths
- Other file types (6): python, csharp, docs, config, other, mixed
- Notebook names (2): extraction and ordering
- Edge cases (4): deeply nested paths, mixed separators, empty filename,
  set dedup semantics

Notable finding: Windows backslash paths don't match startswith check
before normalization — documented as known limitation via test.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@clusterManager-Myia clusterManager-Myia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[NanoClaw]

Solid test coverage for classify_notebook_changes -- 19 tests across 4 classes hit all branches of the pure function. No security concerns.

A few suggestions to strengthen the suite:

1. test_notebook_names_sorted_by_appearance only checks length

assert len(names) == 2  # doesn't verify ordering at all

Either assert names[0] == "aaa" and names[1] == "zzz", or verify the sort property you're documenting. Right now this test passes even if the list is randomly ordered.

2. test_shallow_notebook_path doesn't verify the series name

The comment says series = "standalone.ipynb" but the assertion only checks len == 1. Add:

assert "standalone.ipynb" in result["series"]

3. pytest imported but unused

The file imports pytest but never uses any pytest features (marks, fixtures, parametrize). Either add @pytest.mark.parametrize to the TestClassifyOtherFiles group (which would also reduce the 6 nearly-identical test methods), or drop the import.

4. sys.path.insert import hack

sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "notebook_tools"))

This works but is fragile -- moving the test file or running from a different CWD breaks it. A conftest.py in scripts/tests/ that adds the path once, or a pyproject.toml [tool.pytest.ini_options] pythonpath, would be cleaner.

5. Backslash tests document a bug, not a feature

test_backslash_path_not_matched and test_notebook_path_with_mixed_separators both freeze current broken behavior where startswith("MyIA.AI.Notebooks/") fails on backslash paths even though the code does .replace(chr(92), "/") after the check. If this is intentional "frozen behavior," say so. If not, consider adding a TODO or linking an issue.

Overall: LGTM with minor polish. The coverage is good and the edge cases are thoughtful.

@jsboige jsboige merged commit bf6cb24 into main May 30, 2026
2 checks passed
@jsboige jsboige deleted the test/weekly-digest-classify branch May 30, 2026 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants