Files
zeekay 10e6fec4c0 debrand: the brand token is INSIGHTS_, and a wrong one stops the container
The rule table mapped HOG_ -> FN_ ahead of any POSTHOG rule, so POSTHOG_FOO
split into POST + HOG_ and came out POSTFN_FOO. Nothing sets that. The live
pods set INSIGHTS_SKIP_MIGRATION_CHECKS, which bin/migrate-check reads on the
container entrypoint, so the misspelling does not degrade a feature -- it runs
migrate --check against a database whose history this tree does not share and
the container never starts.

Both replacements are measured against the shipped tree rather than chosen:
every HOG_ name with a counterpart there is spelled INSIGHTS_ (HOG_QL ->
INSIGHTS_QL, HOG_FUNCTION_TEMPLATES -> INSIGHTS_FUNCTION_TEMPLATES, 12 of 12
determinate cases), and FN_ appears in it nowhere. Upstream carries 95 HOG_
tokens and zero FN_ ones, so repairing FN_ back out is exactly the inverse of
the bad rule and cannot collide with an upstream name.

The rule is fixed for the next convergence, and the tree it already produced is
repaired in the same commit -- the codemod is idempotent against its own output,
so it cannot undo this itself.
2026-08-01 17:42:28 -07:00

80 lines
2.6 KiB
Python

"""Pytest fixtures for acceptance tests."""
import os
import logging
import pytest
from .api_client import InsightsTestClient
logger = logging.getLogger(__name__)
@pytest.fixture(scope="class")
def test_client():
"""Create a Insights test client instance for each test class."""
# Get configuration from environment
base_url = os.environ.get("INSIGHTS_TEST_BASE_URL", "http://localhost:8010")
personal_api_key = os.environ.get("INSIGHTS_PERSONAL_API_KEY")
if not personal_api_key:
pytest.skip("INSIGHTS_PERSONAL_API_KEY not set - please set it to run acceptance tests")
logger.info("Creating test client with base_url=%s", base_url)
client = InsightsTestClient(base_url=base_url, personal_api_key=personal_api_key)
yield client
# Cleanup happens in individual tests
@pytest.fixture(scope="function")
def function_test_client():
"""Create a Insights test client instance for each individual test (for auth tests)."""
# Get configuration from environment
base_url = os.environ.get("INSIGHTS_TEST_BASE_URL", "http://localhost:8010")
personal_api_key = os.environ.get("INSIGHTS_PERSONAL_API_KEY")
if not personal_api_key:
pytest.skip("INSIGHTS_PERSONAL_API_KEY not set - please set it to run acceptance tests")
logger.info("Creating function-scoped test client with base_url=%s", base_url)
client = InsightsTestClient(base_url=base_url, personal_api_key=personal_api_key)
yield client
@pytest.fixture(scope="class")
def shared_org_project(test_client):
"""Create a shared organization and project for an entire test class."""
logger.info("Creating shared organization and project for test class")
client = test_client
org = client.create_organization()
project = client.create_project(org["id"])
# Project creation now waits for readiness internally
yield {
"org": org,
"project": project,
"client": client,
"org_id": org["id"],
"project_id": project["id"],
"api_key": project["api_token"],
}
# Cleanup after all tests in class are done
logger.info("Cleaning up shared organization and project")
try:
client.delete_project(project["id"])
logger.info("Successfully deleted project: %s", project["id"])
except Exception as e:
logger.warning("Failed to delete project %s: %s", project["id"], e)
try:
client.delete_organization(org["id"])
logger.info("Successfully deleted organization: %s", org["id"])
except Exception as e:
logger.warning("Failed to delete organization %s: %s", org["id"], e)