When ripe.db is corrupted and no valid backup exists, a new empty database is created with a db_recreated.json marker; /addresses and /addresses/diff answer 503 until the collector gathers data again, /health reports db_recreated. Tests now isolate all state files via conftest. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
19 lines
906 B
Python
19 lines
906 B
Python
import os
|
|
import sys
|
|
|
|
import pytest
|
|
|
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
|
|
import cidr_collector as cc
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def isolated_state(tmp_path, monkeypatch):
|
|
"""Файлы состояния всех тестов - во временном каталоге: ни один тест не трогает каталог проекта и не видит чужие метки."""
|
|
for attr, name in (("CONFIG_FILE", "config.json"), ("DB_FILE", "ripe.db"), ("DATA_FILE", "data.json"),
|
|
("FQDN_DATA_FILE", "fqdn_data.json"), ("STATUS_FILE", "status.json"),
|
|
("COLLECT_REQUEST_FILE", "collect_request.json"), ("RESTORE_FILE", "last_restore.json"),
|
|
("RECREATED_FILE", "db_recreated.json"), ("BACKUP_DIR", "backups")):
|
|
monkeypatch.setattr(cc, attr, str(tmp_path / name))
|