medbillcodes-api / app /test_embed_experiment_guard.py
medbillcodes-deploy
Deploy cloud pilot API
1ddeb51
Raw
History Blame Contribute Delete
1.08 kB
"""Safety guards for embed experiment (no OpenSearch)."""
from __future__ import annotations
import pytest
from app import embed_experiment as ee
from app.config import settings
def test_assert_reindex_blocks_aiven_ohip_codes(monkeypatch):
monkeypatch.setattr(settings, "opensearch_url", "https://x.aivencloud.com:15406")
monkeypatch.setattr(settings, "opensearch_index", "ohip_codes")
with pytest.raises(SystemExit) as exc:
ee.assert_reindex_allowed(allow_prod=False)
assert "REFUSING --reindex" in str(exc.value)
def test_assert_reindex_allows_staging_index(monkeypatch):
monkeypatch.setattr(settings, "opensearch_url", "https://x.aivencloud.com:15406")
monkeypatch.setattr(settings, "opensearch_index", "ohip_codes_staging")
ee.assert_reindex_allowed(allow_prod=False)
def test_assert_reindex_allows_prod_with_flag(monkeypatch):
monkeypatch.setattr(settings, "opensearch_url", "https://x.aivencloud.com:15406")
monkeypatch.setattr(settings, "opensearch_index", "ohip_codes")
ee.assert_reindex_allowed(allow_prod=True)