Skip to content

Commit 405a891

Browse files
committed
Update internal projects list when appending one
1 parent 43a901a commit 405a891

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

dfetch/manifest/manifest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,7 @@ def append_project_entry(self, project_entry: "ProjectEntry") -> None:
433433
None,
434434
None,
435435
]
436+
self._projects[project_entry.name] = ProjectEntry.copy(project_entry)
436437

437438
def update_project_version(self, project: ProjectEntry) -> None:
438439
"""Update a project's version in the manifest in-place, preserving layout, comments, and line endings."""

tests/test_manifest.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,3 +421,30 @@ def test_update_dump_writes_version_as_quoted_string(manifest_text: str) -> None
421421
result = manifest._doc.as_yaml()
422422
# The version value must appear quoted so that YAML parsers read it as a string.
423423
assert f"version: '{manifest.version}'" in result
424+
425+
426+
# ---------------------------------------------------------------------------
427+
# append_project_entry: in-memory cache must stay in sync
428+
# ---------------------------------------------------------------------------
429+
430+
431+
def test_append_project_entry_visible_in_projects() -> None:
432+
"""manifest.projects must include the new entry immediately after append_project_entry."""
433+
manifest = Manifest.from_yaml(_SIMPLE_MANIFEST)
434+
new_project = _make_project("newproject", url="https://example.com/new")
435+
436+
manifest.append_project_entry(new_project)
437+
438+
names = [p.name for p in manifest.projects]
439+
assert "newproject" in names
440+
441+
442+
def test_append_project_entry_check_name_uniqueness_sees_new_entry() -> None:
443+
"""check_name_uniqueness must raise for a name added via append_project_entry."""
444+
manifest = Manifest.from_yaml(_SIMPLE_MANIFEST)
445+
new_project = _make_project("newproject", url="https://example.com/new")
446+
447+
manifest.append_project_entry(new_project)
448+
449+
with pytest.raises(ValueError, match="newproject"):
450+
manifest.check_name_uniqueness("newproject")

0 commit comments

Comments
 (0)