pytest tests/ # all tests
pytest tests/ -v # verbose output
pytest tests/test_graph.py # single file
pytest -k "filter" # keyword match (e.g., -k "engine or graph")- Location: Test files go in
tests/, mirroring thesrc/structure (e.g.,tests/test_graph.pytestssrc/polaris_studio/core/graph.py). - Naming: Test functions start with
test_. Test files start withtest_. - Fixtures: Use
@pytest.fixturefor shared setup. Reusable fixtures (likeengine,sample_graph) are defined in each test module. - Mocking Qt/PySide6: UI tests can use
pytest-qtor manually instantiate widgets withQApplication([])in a fixture. Core logic (graph, engine, agent) is pure Python and needs no mocking.
Example fixture pattern:
@pytest.fixture
def engine() -> Engine:
return Engine()
@pytest.fixture
def sample_graph() -> WorkflowGraph:
g = WorkflowGraph()
src = Node("src", "manual_entry", NodeCategory.SOURCE,
params={"data": '[{"a": 1, "b": "x"}]'})
g.add_node(src)
return gmypy . # full project
mypy src/polaris_studio/core/ # single directoryThe project uses a relaxed mypy config (strict = false). Key overrides ignore libraries without stubs (openpyxl, pyqtgraph).
- ruff for linting and formatting (line length: 100, target: py311):
ruff check src/ ruff format src/
- Coverage with pytest-cov:
pip install pytest-cov pytest tests/ --cov=src/polaris_studio
A GitHub Actions workflow runs on every push/PR:
- Lint with
ruff check src/ - Type-check with
mypy src/ - Test with
pytest tests/ --cov=src/polaris_studio
- Node CRUD:
test_add_node,test_remove_node- verify node insertion/removal and automatic edge cleanup. - Edge CRUD:
test_add_edge,test_remove_edge- verify edge creation/deletion with port parameters. - Cycle Detection:
test_cycle_detection- verifyCycleErroris raised for cycles. - Topological Sort:
test_topological_order- verify correct ordering. - Dirty Propagation:
test_mark_dirty_cascades- verifymark_dirtycascades to downstream nodes. - Upstream/Downstream:
test_upstream_downstream- verify traversal helpers. - Serialization: Methods
to_dict/from_dictare used in workspace save/load but can be tested directly.
- Execution:
test_execute_source,test_execute_filter,test_execute_add_column- verify individual node types produce correct DataFrames. - Pipeline:
test_pipeline_execution- test a multi-node pipeline (source → filter → add column → sort). - Cache:
test_cache,test_dirty_cache_invalidation- verify caching behavior and node dirty state. - AGgregation:
test_group_by_agg- verify group-by + aggregate execution. - Execute All:
test_execute_all- test the bulk execution path. - Error Handling:
test_unknown_node_type- verify graceful error on unknown types.
- Schema validation for agent commands
- Command pipeline execution
- Roundtrip:
test_csv_roundtrip,test_parquet_roundtrip- write then read, verify shape and data. - Custom Delimiters:
test_csv_custom_delimiter- verify semicolon-delimited read/write. - Edge Cases:
test_empty_csv,test_csv_no_header- verify empty file and no-header scenarios. - Compression:
test_parquet_compression- verify zstd compression roundtrip.
- Drop events: simulate a drag-drop from the node palette and verify
node_create_requestedis emitted with the correct node type and snapped position.
- Create
tests/test_<module>.pyor add to an existing test file. - For a new node type: add an engine test (create graph with the node, execute, assert DataFrame shape/values).
- For UI changes: write unit tests for the underlying logic; use manual QA or screenshot tests for visual changes.