feat: add test suite, fix backend bugs, remove legacy artifacts 🧪
- Add 73-test suite across conftest, utils, admin API, reconciler, zone parser,
and CoreDNS MySQL backend (all green, ~0.5s)
- Fix zone_exists filter using wrong column name (name → zone_name)
- Fix delete_zone missing dot_fqdn normalization on lookup
- Remove spurious unused `from config import config` in coredns_mysql.py
- Fix config loader to search module-relative path so tests find app.yml
without needing a root-level config/ directory
- Remove legacy v1 Flask prototype (app.py), empty config.json, and
duplicate root config/app.yml
2026-02-18 22:03:04 +13:00
|
|
|
"""Shared test fixtures for directdnsonly test suite."""
|
2026-02-18 22:53:09 +13:00
|
|
|
|
feat: add test suite, fix backend bugs, remove legacy artifacts 🧪
- Add 73-test suite across conftest, utils, admin API, reconciler, zone parser,
and CoreDNS MySQL backend (all green, ~0.5s)
- Fix zone_exists filter using wrong column name (name → zone_name)
- Fix delete_zone missing dot_fqdn normalization on lookup
- Remove spurious unused `from config import config` in coredns_mysql.py
- Fix config loader to search module-relative path so tests find app.yml
without needing a root-level config/ directory
- Remove legacy v1 Flask prototype (app.py), empty config.json, and
duplicate root config/app.yml
2026-02-18 22:03:04 +13:00
|
|
|
import pytest
|
|
|
|
|
from sqlalchemy import create_engine
|
|
|
|
|
from sqlalchemy.orm import sessionmaker
|
|
|
|
|
|
|
|
|
|
from directdnsonly.app.db import Base
|
2026-02-18 22:53:09 +13:00
|
|
|
from directdnsonly.app.db.models import (
|
|
|
|
|
Domain,
|
|
|
|
|
Key,
|
|
|
|
|
) # noqa: F401 — registers models with Base
|
feat: add test suite, fix backend bugs, remove legacy artifacts 🧪
- Add 73-test suite across conftest, utils, admin API, reconciler, zone parser,
and CoreDNS MySQL backend (all green, ~0.5s)
- Fix zone_exists filter using wrong column name (name → zone_name)
- Fix delete_zone missing dot_fqdn normalization on lookup
- Remove spurious unused `from config import config` in coredns_mysql.py
- Fix config loader to search module-relative path so tests find app.yml
without needing a root-level config/ directory
- Remove legacy v1 Flask prototype (app.py), empty config.json, and
duplicate root config/app.yml
2026-02-18 22:03:04 +13:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def engine():
|
|
|
|
|
eng = create_engine("sqlite:///:memory:")
|
|
|
|
|
Base.metadata.create_all(eng)
|
|
|
|
|
yield eng
|
|
|
|
|
eng.dispose()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def db_session(engine):
|
2026-02-19 23:37:15 +13:00
|
|
|
session = sessionmaker(engine)()
|
feat: add test suite, fix backend bugs, remove legacy artifacts 🧪
- Add 73-test suite across conftest, utils, admin API, reconciler, zone parser,
and CoreDNS MySQL backend (all green, ~0.5s)
- Fix zone_exists filter using wrong column name (name → zone_name)
- Fix delete_zone missing dot_fqdn normalization on lookup
- Remove spurious unused `from config import config` in coredns_mysql.py
- Fix config loader to search module-relative path so tests find app.yml
without needing a root-level config/ directory
- Remove legacy v1 Flask prototype (app.py), empty config.json, and
duplicate root config/app.yml
2026-02-18 22:03:04 +13:00
|
|
|
yield session
|
|
|
|
|
session.close()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def patch_connect(db_session, monkeypatch):
|
|
|
|
|
"""Patch connect() at every call-site, returning the shared test session.
|
|
|
|
|
|
|
|
|
|
Modules that import connect() directly (e.g. utils, reconciler) are
|
|
|
|
|
patched at their local name so the in-memory SQLite session is used
|
|
|
|
|
instead of trying to read from vyper config.
|
|
|
|
|
"""
|
|
|
|
|
_factory = lambda: db_session # noqa: E731
|
|
|
|
|
monkeypatch.setattr("directdnsonly.app.utils.connect", _factory)
|
|
|
|
|
monkeypatch.setattr("directdnsonly.app.reconciler.connect", _factory)
|
2026-02-19 22:16:55 +13:00
|
|
|
monkeypatch.setattr("directdnsonly.app.peer_sync.connect", _factory)
|
feat: operational status endpoint + reconciler/peer state tracking 📊
- ReconciliationWorker._last_run stores per-pass stats (da_servers_polled,
zones_in_da/db, orphans_found/queued, hostnames_backfilled/migrated,
zones_healed, duration_seconds, dry_run flag)
- ReconciliationWorker.get_status() exposes state for API/UI consumption
- _heal_backends() now returns healed count
- PeerSyncWorker.get_peer_status() serialises _peer_health to JSON-safe dict
(url, healthy, consecutive_failures, last_seen) with summary totals
- WorkerManager tracks dead-letter count; queue_status() now returns nested
reconciler/peer_sync dicts replacing flat reconciler_alive/peer_syncer_alive
- New GET /status endpoint (StatusAPI) aggregates queue depths, worker liveness,
reconciler last-run, peer health, and live zone count; computes ok/degraded/error
- .gitignore: exclude .claude/, .vscode/, .env (always local)
- app.yml: add documented datastore section (SQLite default + MySQL commented)
- 164 tests passing (23 new tests added)
2026-02-25 18:51:56 +13:00
|
|
|
monkeypatch.setattr("directdnsonly.app.api.status.connect", _factory)
|
feat: add test suite, fix backend bugs, remove legacy artifacts 🧪
- Add 73-test suite across conftest, utils, admin API, reconciler, zone parser,
and CoreDNS MySQL backend (all green, ~0.5s)
- Fix zone_exists filter using wrong column name (name → zone_name)
- Fix delete_zone missing dot_fqdn normalization on lookup
- Remove spurious unused `from config import config` in coredns_mysql.py
- Fix config loader to search module-relative path so tests find app.yml
without needing a root-level config/ directory
- Remove legacy v1 Flask prototype (app.py), empty config.json, and
duplicate root config/app.yml
2026-02-18 22:03:04 +13:00
|
|
|
return db_session
|