Pull cache/keys.py (HMAC cache key derivation) and mwt.py (Mizan Web Token) out of backends/mizan-django and into a new cores/mizan-python package. mizan-django re-imports them via the new mizan_core module. Naming: directory cores/mizan-python/, distribution mizan-core, importable module mizan_core. mizan-django keeps its existing 'mizan' distribution slot on PyPI; the two coexist as distinct packages. Wiring: - backends/mizan-django/pyproject.toml gains a 'mizan-core' dep with a [tool.uv.sources] path entry (editable install from ../../cores/mizan-python). - Makefile install target prepends 'cd cores/mizan-python && uv pip install -e .' - 3 import sites in mizan-django updated: cache/__init__.py, jwt/functions.py, client/executor.py — all now import from mizan_core. Test split: - 3 unit-test classes (CacheKeyDerivationTests, MWTCreationTests, PermissionKeyTests) move to cores/mizan-python/tests/, rewritten against unittest.TestCase (no Django dep). The cross-language pin test (pinned HMAC hex digests against mizan-ts) moves with CacheKeyDerivationTests. - Integration tests stay in mizan-django (CacheBackendTests, CachePurgeTests, CacheIntegrationTests, RevParameterTests, MWTAuthIntegrationTests) — they need the Django request flow. Verified: - mizan-core: 15/15 pass (incl. cross-language pin) - mizan-django: 348 pass, 21 skip, 0 fail - mizan-ts: edge-compat 34/34 pass — protocol invariant holds, the moved Python derive_cache_key still produces the exact hex digests TS pins against. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
51 lines
2.4 KiB
Makefile
51 lines
2.4 KiB
Makefile
.PHONY: install test test-django test-react test-integration docker-up docker-down clean
|
|
|
|
DJANGO = backends/mizan-django
|
|
REACT = frontends/mizan-react
|
|
|
|
# ─── Setup ───────────────────────────────────────────────────────────────────
|
|
|
|
install:
|
|
cd cores/mizan-python && uv pip install -e .
|
|
cd $(DJANGO) && uv pip install -e ".[dev,channels]"
|
|
cd $(REACT) && npm install
|
|
|
|
# ─── Unit Tests ──────────────────────────────────────────────────────────────
|
|
|
|
test: test-django test-react
|
|
|
|
test-django:
|
|
cd $(DJANGO) && uv run pytest
|
|
|
|
test-react:
|
|
cd $(REACT) && npm test
|
|
|
|
# ─── Integration Tests ──────────────────────────────────────────────────────
|
|
|
|
test-integration: docker-up
|
|
@echo "Waiting for backend..."
|
|
@timeout 30 sh -c 'until curl -sf http://localhost:8000/api/mizan/session/ > /dev/null 2>&1; do sleep 1; done'
|
|
cd $(REACT) && npm run test:integration
|
|
@$(MAKE) docker-down
|
|
|
|
# ─── Docker ──────────────────────────────────────────────────────────────────
|
|
|
|
docker-up:
|
|
docker compose -f examples/django-react-site/docker-compose.test.yml up -d --build
|
|
@echo "Backend starting at http://localhost:8000"
|
|
|
|
docker-down:
|
|
docker compose -f examples/django-react-site/docker-compose.test.yml down
|
|
|
|
# ─── All ─────────────────────────────────────────────────────────────────────
|
|
|
|
test-all: test test-integration
|
|
|
|
# ─── Cleanup ─────────────────────────────────────────────────────────────────
|
|
|
|
clean:
|
|
docker compose -f examples/django-react-site/docker-compose.test.yml down -v --remove-orphans 2>/dev/null || true
|
|
rm -rf $(DJANGO)/src/mizan.egg-info $(DJANGO)/dist $(DJANGO)/build
|
|
rm -rf $(REACT)/dist $(REACT)/node_modules
|
|
rm -f examples/django-react-site/backend/db.sqlite3
|