Files
flow/tests/test_domain_dotfiles_models.py
Tomas Mirchev 31d7583b9a feat: add all domain layers (dotfiles, packages, remote, containers)
- Dotfiles: models, module resolution, path resolution, link planning
- Packages: models, catalog parsing, resolution, install/remove planning
- Remote: target parsing, SSH command building
- Containers: image refs, mount resolution, container specs

All domain code is pure functions + frozen dataclasses. 88 tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-16 04:54:06 +02:00

48 lines
1.4 KiB
Python

"""Tests for dotfiles domain models."""
from pathlib import Path
from flow.domain.dotfiles.models import (
LinkOp,
LinkPlan,
LinkTarget,
LinkedState,
ModuleRef,
Package,
PlanSummary,
)
def test_link_op_str_create():
op = LinkOp(type="create_link", target=Path("/home/x/.zshrc"),
source=Path("/dots/zsh/.zshrc"), package="_shared/zsh", needs_sudo=False)
assert "LINK:" in str(op)
assert ".zshrc" in str(op)
def test_link_op_str_sudo():
op = LinkOp(type="create_link", target=Path("/etc/hosts"),
source=Path("/dots/dns/hosts"), package="_shared/dns", needs_sudo=True)
assert "(sudo)" in str(op)
def test_linked_state_roundtrip():
lt = LinkTarget(source=Path("/a"), target=Path("/b"), package="p", from_module=False, needs_sudo=False)
state = LinkedState(links={Path("/b"): lt})
data = state.as_dict()
restored = LinkedState.from_dict(data)
assert Path("/b") in restored.links
assert restored.links[Path("/b")].source == Path("/a")
assert restored.links[Path("/b")].package == "p"
def test_linked_state_empty():
state = LinkedState.from_dict({})
assert state.links == {}
def test_package_has_id():
pkg = Package(name="zsh", layer="_shared", package_id="_shared/zsh",
source_dir=Path("/dots/_shared/zsh"), module=None, local_files=())
assert pkg.package_id == "_shared/zsh"