Skip to content

refactor: split framework tests into own directory - #165

Merged
mkoura merged 2 commits into
mainfrom
refactor/framework-tests-directory
Jul 30, 2026
Merged

refactor: split framework tests into own directory#165
mkoura merged 2 commits into
mainfrom
refactor/framework-tests-directory

Conversation

@OlufemiAdeOlusile

@OlufemiAdeOlusile OlufemiAdeOlusile commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Summary

Moves our framework/helper unit tests into a top-level
framework_tests/ directory, matching cardano-node-tests.
sync_tests/tests/ keeps the real node/db-sync tests.

Moved:

  • test_ci_step_emit.py
  • test_config_downloads.py
  • test_disk_cleanup.py
  • test_request_with_retry.py
  • test_start_node.py

Updated pyproject.toml (testpaths, ruff ignores, pyrefly includes,
package excludes) to match.

Fixed a bug the move exposed: one test had a hardcoded path depth
that broke once the file moved up a level.

Test plan

  • ruff, ruff format, mypy all pass
  • Full suite passes (39 collected, standalone and combined runs)
  • Reinstalled the package and reran tests against it

Martin proposed separating our own framework/helper unit tests
from the real product tests (node_sync, db_sync, mainnet_tx_count)
so the two are not mixed together in one directory, mirroring how
Cardano itself keeps this distinction.

Moved the five tests that only exercise our own utility code, with
no live node or db-sync dependency, into a new
sync_tests/framework_tests/ package:
- test_ci_step_emit.py
- test_config_downloads.py
- test_disk_cleanup.py
- test_request_with_retry.py
- test_start_node.py

sync_tests/tests/ keeps conftest.py and the real product tests
that need a live node/db-sync session.

pyproject.toml testpaths and the ANN per-file-ignore now cover
both directories. No CI workflow changes needed: node_sync_test
and db_sync_full_sync target files/markers that did not move.

Pure file move, no behavior change. Verified with ruff, ruff
format, mypy, and pytest (39 collected, both dirs run standalone
and together).
Checked cardano-node-tests directly instead of guessing: its
framework_tests/ is a top-level directory, sibling to
cardano_node_tests/, not nested inside the product package. The
previous commit nested it under sync_tests/ instead, which does
not match that structure.

Moved framework_tests/ up to repo root to match. Updated
pyproject.toml accordingly: testpaths, the ANN per-file-ignore,
pyrefly project_includes, and added an explicit setuptools
packages.find include so framework_tests is not swept into the
installable package, mirroring cardano-node-tests exactly.

Also fixed a real bug this move exposed: test_ci_step_emit.py
computed _REPO_ROOT as parents[2], which assumed the old two
levels of nesting (sync_tests/tests/). At one level deep it must
be parents[1]. Without this fix the e2e subprocess test fails
because PYTHONPATH points one directory too high.

Verified: ruff, ruff format, and mypy pass; pytest framework_tests
standalone (20 passed, matching how node-tests runs it in
code_checks.yaml) and the combined run (20 passed, 19 deselected)
both pass.
@mkoura
mkoura merged commit e9fc7a0 into main Jul 30, 2026
4 checks passed
@mkoura
mkoura deleted the refactor/framework-tests-directory branch July 30, 2026 10:26
OlufemiAdeOlusile added a commit that referenced this pull request Jul 30, 2026
Framework tests moved to a top-level framework_tests/ directory
in #165. This workflow still targeted sync_tests/tests/ with a
marker-exclusion filter, which after that move would just select
zero tests, silently.

Now runs pytest framework_tests directly, no filter needed, same
as how cardano-node-tests invokes its equivalent in
code_checks.yaml.

Verified by simulating the exact CI steps in a fresh venv: fresh
install via pip install -e ., then pytest framework_tests -v,
20 passed.
OlufemiAdeOlusile added a commit that referenced this pull request Jul 30, 2026
Addresses both review comments:

Martin: differentiate framework tests from actual sync tests.
These four files are pure unit tests of our own code (log
parsing, metrics extraction, graph generation) with no live
node/db-sync dependency, so they belong in framework_tests/
(added in #165), not sync_tests/tests/:
- test_log_analyzer.py
- test_metrics_extractor_dbsync.py
- test_metrics_extractor_node.py
- test_sync_static_graphs.py

Copilot: the comment explaining why epoch 3 is kept in
test_epoch_timings_keeps_entries_with_valid_duration_or_blocks
was contradictory. Reworded to state directly that
has_valid_blocks treats any blocks_count >= 0, including 0, as
valid, which is why epoch 3 survives despite duration_sec=0.

Verified: ruff, ruff format, and mypy pass (47 source files);
full suite collects 72 tests, 53 passed, 8 skipped (unrelated
snapshot tests missing CLI args), 11 deselected (live-infra
markers).
OlufemiAdeOlusile added a commit that referenced this pull request Aug 3, 2026
Self-contained unit tests belong alongside the other framework tests
(no conftest fixtures, no CLI options), matching the layout PR #165
already established for this category of test.
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