Files
flow/tests/test_domain_packages_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

44 lines
1.3 KiB
Python

"""Tests for packages domain models."""
from pathlib import Path
import pytest
from flow.core.errors import ConfigError
from flow.domain.packages.models import InstalledPackage, InstalledState, PackageDef
def test_installed_state_roundtrip():
state = InstalledState(packages={
"neovim": InstalledPackage(
name="neovim", version="0.10.4", type="binary",
files=[Path("/home/x/.local/bin/nvim")],
),
})
data = state.as_dict()
restored = InstalledState.from_dict(data)
assert "neovim" in restored.packages
assert restored.packages["neovim"].version == "0.10.4"
assert restored.packages["neovim"].files == [Path("/home/x/.local/bin/nvim")]
def test_installed_state_empty():
state = InstalledState.from_dict({})
assert state.packages == {}
def test_installed_state_version_mismatch():
with pytest.raises(ConfigError):
InstalledState.from_dict({"version": 99, "packages": {}})
def test_package_def_fields():
pkg = PackageDef(
name="fd", type="pkg", sources={"apt": "fd-find"},
source=None, version=None, asset_pattern=None,
platform_map={}, extract_dir=None, install={},
post_install=None, allow_sudo=False,
)
assert pkg.name == "fd"
assert pkg.type == "pkg"