Skip to content

Reorganize tests into unit, integration, and support modules - #41

Merged
utkarsh5026 merged 1 commit into
mainfrom
ccr-c7d8f1a8-qdusyh
Oct 21, 2026
Merged

utkarsh5026 merged 1 commit into
mainfrom
ccr-c7d8f1a8-qdusyh

Conversation

@utkarsh5026

Copy link
Copy Markdown
Owner

Restructure the test suite to improve organization and maintainability by separating concerns into distinct test categories.

Summary

The monolithic tests/test_code_node.py (1341 lines) has been split into focused test modules organized by category:

  • Unit tests (tests/unit/) - test individual components in isolation
  • Integration tests (tests/integration/) - test end-to-end workflows
  • Shared fixtures (tests/support.py) - common test data and utilities

Key Changes

Test Organization:

  • Removed tests/test_code_node.py (1341 lines)
  • Created tests/unit/test_reader.py - code mapping and entry point discovery
  • Created tests/unit/test_platforms.py - Lambda, web frameworks, and platform plugins
  • Created tests/unit/test_project.py - folder reading, module names, entry points
  • Created tests/unit/test_libraries.py - library plugins and their clients
  • Created tests/unit/test_deploys.py - SAM and serverless.yml deploy files
  • Created tests/unit/test_graph.py - graph generation and limits
  • Created tests/unit/test_report.py - page rendering, code panels, step-by-step walk
  • Created tests/unit/test_history.py - git blame integration
  • Created tests/unit/test_picker.py - interactive file/entry point picker
  • Created tests/integration/test_cli.py - command-line interface end-to-end
  • Created tests/integration/test_serve.py - live server with hot reload
  • Created tests/integration/test_examples.py - example projects against snapshots

Shared Test Utilities:

  • Created tests/support.py with:
    • write() helper for creating test projects
    • HANDLER - Lambda handler example
    • PACKAGE - console script package example
    • STORES - multi-library example
    • FAN - complex call graph example
    • IMPORTED_FROM_SRC - local import example
    • EXAMPLES and SNAPSHOTS paths

Configuration:

  • Added tests/conftest.py with pytest markers (unit, integration)
  • Updated pyproject.toml:
    • Added pythonpath = ["tests"] for support.py imports
    • Added --strict-markers to pytest options
    • Registered unit and integration markers
  • Updated Makefile and makefile.py with test-unit and test-integration targets
  • Updated CLAUDE.md with new test organization guidance

Benefits

  • Faster feedback: Run pytest -m unit for quick validation without I/O
  • Clearer intent: Test names and locations indicate what they verify
  • Better maintenance: Related tests grouped together, easier to find and modify
  • Reduced duplication: Shared test data in support.py eliminates copy-paste
  • Flexible CI: Can run unit tests on every commit, integration tests less frequently

https://claude.ai/code/session_0135RUJGyhafwLiULmpTn7G4

… none

tests/test_code_node.py (1,341 lines, 55 tests) is now one file per part:
tests/unit/ (project, reader, graph, platforms, libraries, deploys, report,
picker, history) and tests/integration/ (cli, serve, examples), with what
they share in tests/support.py. conftest.py marks each test by its folder,
so `pytest -m unit` and `-m integration` run one kind (make test-unit,
make test-integration, and the same in makefile.py).

New tests (24):
- imports inside a function: followed, startup=False, scoped to that
  function; optional imports, relative and star imports
- partial maps instead of tracebacks: a bad entry, a file that doesn't
  parse, a reader that raises
- entry_file, entries_in_file, functions_matching, project_root
- the deploy helpers: allowed, statement_actions, resolve_handler,
  load_yaml with CloudFormation tags, line_of
- the code read is never run, through main() and python -m code_node
- the command as its own process: -o, the cache folder, --help, bad args
- --list, a missing folder, an entry point that matches no file
- every entry point of each example read to the end; each example's page
  balanced HTML with nothing fetched from elsewhere; the CI smoke lines
- --serve's /events stream over a real connection, through a broken edit

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0135RUJGyhafwLiULmpTn7G4
@utkarsh5026
utkarsh5026 merged commit adaaa6f into main Oct 21, 2026
8 checks passed
@utkarsh5026
utkarsh5026 deleted the ccr-c7d8f1a8-qdusyh branch October 21, 2026 19:36
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