mirror of
https://github.com/hanzoai/insights-python.git
synced 2026-10-30 18:33:17 +00:00
- Rename main class Posthog -> Insights (Posthog kept as alias) - Rename PosthogContextMiddleware -> InsightsContextMiddleware (alias kept) - Rename PostHogTracingProcessor -> InsightsTracingProcessor (alias kept) - Add `insights/` re-export package so `from insights import Insights` works - Update all imports from `posthog` to `hanzo_insights` across source and tests - Update docstrings, comments, error messages, user agent string - Update README, example.py, .env.example, Makefile, LLM.md - Django middleware now supports INSIGHTS_MW_* settings (POSTHOG_MW_* still works) - Django middleware accepts X-INSIGHTS-* headers (X-POSTHOG-* still works) - Keep protocol-level values ($lib, ingestion URLs, sentinel strings) for server compat - Keep posthog_* parameter names in AI wrappers for API compat - All 681 tests pass
25 lines
772 B
Python
25 lines
772 B
Python
import unittest
|
|
|
|
from parameterized import parameterized
|
|
|
|
from hanzo_insights import utils
|
|
|
|
|
|
class TestSizeLimitedDict(unittest.TestCase):
|
|
@parameterized.expand([(10, 100), (5, 20), (20, 200)])
|
|
def test_size_limited_dict(self, size: int, iterations: int) -> None:
|
|
values = utils.SizeLimitedDict(size, lambda _: -1)
|
|
|
|
for i in range(iterations):
|
|
values[i] = i
|
|
|
|
assert values[i] == i
|
|
assert len(values) == i % size + 1
|
|
|
|
if i % size == 0:
|
|
# old numbers should've been removed
|
|
self.assertIsNone(values.get(i - 1))
|
|
self.assertIsNone(values.get(i - 3))
|
|
self.assertIsNone(values.get(i - 5))
|
|
self.assertIsNone(values.get(i - 9))
|