mirror of
https://github.com/ipnet-mesh/meshcore-hub.git
synced 2026-08-12 03:42:59 +02:00
chore(tests): speed up pytest from >2min to ~12s
- Default-off coverage in pyproject.toml addopts; opt-in via make test-cov - Add pytest-xdist for parallel execution (make test = pytest -nauto --no-cov) - Promote API test fixtures to session/module scope (engine, app, mocks); per-test isolation via table truncation instead of schema rebuild - Remove Makefile include .env/export that leaked config vars into tests; docker-compose reads .env natively - Add _ignore_dotenv autouse fixture: disables env_file, clears leaked env vars from Settings fields and Click CLI envvars - Patch time.sleep in 3 subscriber scheduler tests (~3s -> ~0.03s) - Fix pytest.raises(Exception, match='') warning -> IntegrityError - Add .venv activation to .envrc - Suppress warn_unused_ignores for tests in mypy config (single-file pre-commit checks lack full-project context)
This commit is contained in:
@@ -1,15 +1,10 @@
|
||||
ifneq (,$(wildcard ./.env))
|
||||
include .env
|
||||
export
|
||||
endif
|
||||
|
||||
COMPOSE_PROJECT_NAME ?= hub
|
||||
PROFILES ?= mqtt core
|
||||
COMPOSE_FILES = -f docker-compose.yml -f docker-compose.dev.yml
|
||||
VOLUMES = $(COMPOSE_PROJECT_NAME)_data $(COMPOSE_PROJECT_NAME)_mqtt_data \
|
||||
$(COMPOSE_PROJECT_NAME)_observer_data
|
||||
|
||||
.PHONY: build up down logs backup restore
|
||||
.PHONY: build up down logs backup restore test test-cov test-unit
|
||||
|
||||
build:
|
||||
docker compose $(COMPOSE_FILES) --profile all build --no-cache
|
||||
@@ -38,3 +33,14 @@ restore:
|
||||
echo "Restoring $$vol from $(FILE)..."; \
|
||||
docker run --rm -v $$vol:/data -v $(PWD)/backup:/backup \
|
||||
alpine sh -c "cd / && tar xzf /backup/$$(basename $(FILE))"
|
||||
|
||||
# --- Tests ---------------------------------------------------------------
|
||||
# Coverage is opt-in (use test-cov). Dev loop runs in parallel across cores.
|
||||
test:
|
||||
pytest -nauto --no-cov
|
||||
|
||||
test-cov:
|
||||
pytest --cov=meshcore_hub --cov-report=term-missing
|
||||
|
||||
test-unit:
|
||||
pytest -nauto --no-cov tests/test_common/ tests/test_api/ tests/test_collector/ tests/test_web/
|
||||
|
||||
Reference in New Issue
Block a user