Add project registration policy and template
This commit is contained in:
@@ -5,6 +5,7 @@ import json
|
||||
import atocore.config as config
|
||||
from atocore.projects.registry import (
|
||||
get_registered_project,
|
||||
get_project_registry_template,
|
||||
list_registered_projects,
|
||||
refresh_registered_project,
|
||||
)
|
||||
@@ -150,3 +151,60 @@ def test_refresh_registered_project_ingests_registered_roots(tmp_path, monkeypat
|
||||
assert calls[0][0].endswith("p06-polisher")
|
||||
assert calls[0][1] is False
|
||||
assert result["roots"][0]["status"] == "ingested"
|
||||
|
||||
|
||||
def test_project_registry_template_has_expected_shape():
|
||||
template = get_project_registry_template()
|
||||
assert "projects" in template
|
||||
assert template["projects"][0]["id"] == "p07-example"
|
||||
assert template["projects"][0]["ingest_roots"][0]["source"] == "vault"
|
||||
|
||||
|
||||
def test_project_registry_rejects_alias_collision(tmp_path, monkeypatch):
|
||||
vault_dir = tmp_path / "vault"
|
||||
drive_dir = tmp_path / "drive"
|
||||
config_dir = tmp_path / "config"
|
||||
vault_dir.mkdir()
|
||||
drive_dir.mkdir()
|
||||
config_dir.mkdir()
|
||||
|
||||
registry_path = config_dir / "project-registry.json"
|
||||
registry_path.write_text(
|
||||
json.dumps(
|
||||
{
|
||||
"projects": [
|
||||
{
|
||||
"id": "p04-gigabit",
|
||||
"aliases": ["shared"],
|
||||
"ingest_roots": [
|
||||
{"source": "vault", "subpath": "incoming/projects/p04-gigabit"}
|
||||
],
|
||||
},
|
||||
{
|
||||
"id": "p05-interferometer",
|
||||
"aliases": ["shared"],
|
||||
"ingest_roots": [
|
||||
{"source": "vault", "subpath": "incoming/projects/p05-interferometer"}
|
||||
],
|
||||
},
|
||||
]
|
||||
}
|
||||
),
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
monkeypatch.setenv("ATOCORE_VAULT_SOURCE_DIR", str(vault_dir))
|
||||
monkeypatch.setenv("ATOCORE_DRIVE_SOURCE_DIR", str(drive_dir))
|
||||
monkeypatch.setenv("ATOCORE_PROJECT_REGISTRY_PATH", str(registry_path))
|
||||
|
||||
original_settings = config.settings
|
||||
try:
|
||||
config.settings = config.Settings()
|
||||
try:
|
||||
list_registered_projects()
|
||||
except ValueError as exc:
|
||||
assert "collision" in str(exc)
|
||||
else:
|
||||
raise AssertionError("Expected project registry collision to raise")
|
||||
finally:
|
||||
config.settings = original_settings
|
||||
|
||||
Reference in New Issue
Block a user