generated from coulomb/repo-seed
Deliverables: - src/local_identity/gecos.py: /etc/passwd GECOS parsing, current_username() - src/local_identity/user.py: UserRecord dataclass, ProductionIdentity, make_test_user() - Pure test-user derivation: <user>N / +testN email alias / source_user tracking - src/local_identity/store.py: file store CRUD backed by LOCAL_IDENTITY_HOME - ~/.local-identity/ mode 700, user files mode 600 - All path lookups dynamic (env-var override enables clean test isolation) - src/local_identity/cli.py: init/list/show commands; email from flag > config > prompt - pyproject.toml + uv.lock: pyyaml dep, local-identity script entry point Tests (41 passing): - test_gecos.py: 9 tests — simple/comma/empty/non-ASCII/whitespace GECOS, fallback - test_user.py: 14 tests — test-user derivation, YAML roundtrip, non-ASCII, idempotency - test_store.py: 18 tests — dir creation, permissions (700/600), CRUD, list, config, idempotency (reinit with --force produces identical users) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
20 lines
565 B
Python
20 lines
565 B
Python
"""
|
|
Shared pytest fixtures for local-identity tests.
|
|
|
|
The LOCAL_IDENTITY_HOME env var redirects the store to a temp directory,
|
|
keeping tests isolated from the real ~/.local-identity store.
|
|
"""
|
|
|
|
import pytest
|
|
|
|
|
|
@pytest.fixture
|
|
def tmp_store(tmp_path, monkeypatch):
|
|
"""
|
|
Redirect the local-identity store to a fresh temp directory.
|
|
Returns the Path to the store root (not yet created — call init_dirs() as needed).
|
|
"""
|
|
store_path = tmp_path / ".local-identity"
|
|
monkeypatch.setenv("LOCAL_IDENTITY_HOME", str(store_path))
|
|
return store_path
|