Run backend tests and code quality checks for OPRE OPS. Covers ops_api pytest, data_tools pytest, and nox linting/formatting sessions. Use this skill when the user wants to run backend tests, check code quality, lint Python code, run pytest, or verify their backend changes pass CI checks — even if they just say "run the tests" or "does this pass".
71
88%
Does it follow best practices?
Impact
—
No eval scenarios have been run
Passed
No known issues
You run tests and code quality checks for the two backend Python packages in OPRE OPS: ops_api (the Flask API) and data_tools (the ETL/data loading scripts). Each has its own pipenv environment, test suite, and nox sessions.
Interpret $ARGUMENTS to decide the action:
$ARGUMENTS is api or starts with apiRun the ops_api test suite.
cd backend/ops_api
# Run all API tests
pipenv run pytest
# Run with verbose output and short summary
pipenv run pytest -v --tb=shortIf $ARGUMENTS includes a specific path or test name after api (e.g., api test_agreements):
cd backend/ops_api
# Find matching test files
find tests -name "*<pattern>*" -type f
# Run the matching test file
pipenv run pytest tests/ops/resources/test_agreements.pyTest files mirror the source structure: ops/resources/agreements.py -> tests/ops/resources/test_agreements.py.
Report results:
$ARGUMENTS is data-tools or data or etlRun the data_tools test suite. These tests use pytest-docker to spin up a Postgres instance.
Pre-flight check — Docker must be available:
docker info > /dev/null 2>&1 && echo "Docker: OK" || echo "Docker: NOT RUNNING"cd backend/data_tools
# Run all data tools tests
pipenv run pytest
# Run with verbose output
pipenv run pytest -v --tb=shortIf a specific test path is provided:
cd backend/data_tools
pipenv run pytest tests/load_projects/test_load_projects.pyData tools tests use the loaded_db fixture which:
ops_db_history after each testReport results the same as API tests.
$ARGUMENTS is lintRun linting across both packages:
echo "=== ops_api linting ==="
cd backend/ops_api
pipenv run nox -s lint
echo ""
echo "=== data_tools linting ==="
cd backend/data_tools
pipenv run nox -s lintReport any linting violations with file, line number, and rule code.
$ARGUMENTS is format or format-checkCheck formatting (Black + isort) without modifying files:
echo "=== ops_api format check ==="
cd backend/ops_api
pipenv run nox -s format_check
echo ""
echo "=== data_tools format check ==="
cd backend/data_tools
pipenv run nox -s format_checkIf formatting issues are found, offer to auto-fix:
cd backend/ops_api
pipenv run nox -s black
cd backend/data_tools
pipenv run nox -s black$ARGUMENTS is a file path or test identifierIf the argument looks like a file path or test name (contains /, .py, or ::):
Determine which package it belongs to:
data_tools or load_ -> run in backend/data_tools/backend/ops_api/# For ops_api tests
cd backend/ops_api
pipenv run pytest <test-path> -v --tb=short
# For data_tools tests
cd backend/data_tools
pipenv run pytest <test-path> -v --tb=short$ARGUMENTS is all or ciRun the full backend CI check suite — everything that CI would catch.
echo "=== Step 1/4: ops_api lint + format ==="
cd backend/ops_api
pipenv run nox -s lint
pipenv run nox -s format_check
echo ""
echo "=== Step 2/4: ops_api tests ==="
cd backend/ops_api
pipenv run pytest --tb=short
echo ""
echo "=== Step 3/4: data_tools lint + format ==="
cd backend/data_tools
pipenv run nox -s lint
pipenv run nox -s format_check
echo ""
echo "=== Step 4/4: data_tools tests ==="
cd backend/data_tools
pipenv run pytest --tb=shortNote on data_tools lint: The data_tools package has known pre-existing lint violations (unused imports, f-string placeholders, complexity warnings). These are technical debt, not new failures. Only report lint issues that are in files you or the user have changed.
Report a final summary:
Backend CI Check Summary:
ops_api lint: PASS/FAIL
ops_api format: PASS/FAIL
ops_api tests: X passed, Y failed
data_tools lint: PASS/FAIL
data_tools format: PASS/FAIL
data_tools tests: X passed, Y failed$ARGUMENTS is empty or unrecognizedShow help:
Backend Test Skill - Available Commands:
/backend-tests api Run ops_api test suite
/backend-tests api <pattern> Run matching ops_api tests (e.g., "api agreements")
/backend-tests data-tools Run data_tools test suite (needs Docker)
/backend-tests lint Run flake8 linting on both packages
/backend-tests format Check Black/isort formatting on both packages
/backend-tests all Run full CI check suite (lint + format + tests)
/backend-tests <test-path> Run a specific test file or function
Package locations:
ops_api: backend/ops_api/ (Flask API tests)
data_tools: backend/data_tools/ (ETL tests, needs Docker for Postgres)backend/ops_api/tests/backend/ops_api/tests/conftest.py (fixtures: app, client, auth_client, loaded_db)backend/ops_api/noxfile.pybackend/data_tools/tests/backend/data_tools/tests/conftest.py (fixtures: db_service, loaded_db)backend/data_tools/noxfile.pybackend/models/ (used by both packages)backend/ops_api/, data_tools tests from backend/data_tools/.docker info.loaded_db fixture in ops_api loads test data from data_tools/initial_data/. If seed data has changed, the fixture may need updating.e2a9461
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.