:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
from django.test import SimpleTestCase, override_settings
from parameterized import parameterized
from ee.api.agentic_provisioning.regions import region_to_host as agentic_region_to_host
from ee.partners.stripe.api.provisioning.core import region_to_host
SITE_URL = "https://app.example.test"
KNOWN_REGIONS = ["US", "us", "EU", "eu", "DEV", "dev"]
class TestRegions(SimpleTestCase):
@parameterized.expand(
[
("US", "https://us.posthog.com"),
("us", "https://us.posthog.com"),
("EU", "https://eu.posthog.com"),
("eu", "https://eu.posthog.com"),
("DEV", "https://app.dev.posthog.dev"),
("dev", "https://app.dev.posthog.dev"),
]
)
def test_region_to_host(self, region: str, expected: str) -> None:
self.assertEqual(region_to_host(region), expected)
@override_settings(SITE_URL=SITE_URL)
def test_region_to_host_falls_back_to_site_url_for_an_unknown_region(self) -> None:
self.assertEqual(region_to_host("MARS"), SITE_URL)
@parameterized.expand([(region,) for region in KNOWN_REGIONS])
@override_settings(SITE_URL=SITE_URL)
def test_matches_the_agentic_provisioning_mapping(self, region: str) -> None:
self.assertEqual(region_to_host(region), agentic_region_to_host(region))