REPROCESS_PRODUCTS is not in SYNC_JOB_KINDS, so it fell to the else branch of execute_job and hardcoded company=None for _unified_fiscal - a real gap, not a missing feature: the same deterministic, fail-closed company_context.resolve() every sync job already uses is cheap (no full-table scan, confirmed against the real database) and applies just as well to a one-off reprocess job. Now resolves the real company the same way; falls back to None only when the company genuinely cannot be resolved yet, never a silent guess. Does not touch RTC rule logic. Verified end-to-end against the real production database (dry-run, zero writes) that this was the last domain still carrying the old bug - field_contract's post-NCM fiscal completion already bypassed it entirely by reading Installation.company_uf/crt/company_contribuinte_ipi directly (populated via the 1.3.7 heartbeat fix). 1123 tests passed (tests + central/tests + agent/tests), 0 failed. Version 1.3.8 (single GTI_FISCAL_VERSION).
30 lines
1.2 KiB
Python
30 lines
1.2 KiB
Python
from fastapi.testclient import TestClient
|
|
|
|
from central.app.main import create_app
|
|
|
|
|
|
def test_health_reports_database_dependency():
|
|
client = TestClient(create_app(database_probe=lambda: True))
|
|
|
|
assert client.get("/health").json() == {"status": "ok"}
|
|
|
|
|
|
def test_health_is_unavailable_when_database_is_down():
|
|
client = TestClient(create_app(database_probe=lambda: False))
|
|
|
|
assert client.get("/health").status_code == 503
|
|
|
|
|
|
def test_version_endpoint_reports_release_and_fiscal_versions():
|
|
body = TestClient(create_app(database_probe=lambda: True)).get("/version").json()
|
|
assert body["version"] == "1.3.8" and body["api_compat"] == "1.0" and body["engine_version"] and body["decision_version"]
|
|
|
|
|
|
def test_production_refuses_the_dev_token(monkeypatch):
|
|
import pytest
|
|
from central.app import main as main_module
|
|
monkeypatch.setattr(main_module.settings.__class__, "environment", "production", raising=False) if False else None
|
|
monkeypatch.setattr(main_module, "settings", type("S", (), {"environment": "production", "agent_dev_token": "dev", "log_level": "INFO"})())
|
|
with pytest.raises(RuntimeError):
|
|
create_app(database_probe=lambda: True)
|