test state refresh after branch removal
Python package / build (flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics, 3.12.3) (pull_request) Successful in 39s
Python package / build (flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics, 3.13) (pull_request) Successful in 36s
Python package / build (flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics, 3.14) (pull_request) Successful in 40s
Python package / build (flake8 . --count --select=E9,F63,F7,F82 --ignore=F824 --show-source --statistics, 3.12.3) (pull_request) Successful in 34s
Python package / build (flake8 . --count --select=E9,F63,F7,F82 --ignore=F824 --show-source --statistics, 3.14) (pull_request) Canceled after 0s
Python package / build (mypy --no-incremental --config-file mypy.ini backend tests, 3.12.3) (pull_request) Canceled after 0s
Python package / build (flake8 . --count --select=E9,F63,F7,F82 --ignore=F824 --show-source --statistics, 3.13) (pull_request) Canceled after 7s
Python package / build (mypy --no-incremental --config-file mypy.ini backend tests, 3.13) (pull_request) Canceled after 0s
Python package / build (mypy --no-incremental --config-file mypy.ini backend tests, 3.14) (pull_request) Canceled after 0s
Python package / build (pip list, 3.12.3) (pull_request) Canceled after 0s
Python package / build (pip list, 3.13) (pull_request) Canceled after 0s
Python package / build (pip list, 3.14) (pull_request) Canceled after 0s
Python package / build (python -c "import sys; print(f'Python {sys.version}'); print(f'Build: {sys.version_info}'); print(f'Implementation: {sys.implementation}')", 3.12.3) (pull_request) Canceled after 0s
Python package / build (python -c "import sys; print(f'Python {sys.version}'); print(f'Build: {sys.version_info}'); print(f'Implementation: {sys.implementation}')", 3.13) (pull_request) Canceled after 0s
Python package / build (python -c "import sys; print(f'Python {sys.version}'); print(f'Build: {sys.version_info}'); print(f'Implementation: {sys.implementation}')", 3.14) (pull_request) Canceled after 0s
Python package / tests (pytest, 3.12.3) (pull_request) Canceled after 0s
Python package / tests (pytest, 3.13) (pull_request) Canceled after 0s
Python package / tests (pytest, 3.14) (pull_request) Canceled after 0s

This commit is contained in:
2026-08-25 19:53:32 +02:00
parent e5331745be
commit 0190fc7474
2 changed files with 27 additions and 0 deletions
+19
View File
@@ -1,5 +1,6 @@
import pytest
from enironment import wrap_in_cached, SharedStateConflictError
from steps.shared_state import SharedStateHolderInMemory
from tests.test_remote_repo import RemoteRepoHelper
@@ -7,6 +8,24 @@ from tests.test_remote_repo import RemoteRepoHelper
class TestCachedEnv:
"""Tests for the CachedEnv wrapper around GitEnv."""
def test_inmemory_state_refreshes_removed_branch(self, repo_helper: RemoteRepoHelper) -> None:
repo_helper.create_commit(repo_helper.repo, "master", "master", "file1.txt", "content1", "Initial commit")
commit1 = repo_helper.create_commit(repo_helper.repo, "master", "branch1", "file2.txt", "content2", "Branch1 commit")
commit2 = repo_helper.create_commit(repo_helper.repo, "master", "branch2", "file3.txt", "content3", "Branch2 commit")
repo_helper.set_desired_branches([("branch1", "HEAD"), ("branch2", "HEAD")])
_ = repo_helper.checkout_merged.progress()
setattr(repo_helper.mock_check, "version", lambda: f"auto-{commit1.hexsha[:8]}-{commit2.hexsha[:8]}")
state = SharedStateHolderInMemory(repo_helper.git_unmerge)
assert state.progress().branches == [("branch1", commit1.hexsha), ("branch2", commit2.hexsha)]
repo_helper.delete_branch("branch2")
repo_helper.git_clone.progress()
assert repo_helper.git_unmerge.progress().branches == [("branch1", commit1.hexsha)]
assert state.progress().branches == [("branch1", commit1.hexsha)]
def test_checkout_merged_empty_branches(self, repo_helper: RemoteRepoHelper) -> None:
"""Test CheckoutMerged with empty branches list - should fail"""
+8
View File
@@ -144,6 +144,14 @@ class RemoteRepoHelper:
repo.index.add([filename])
return repo.index.commit(message)
def delete_branch(self, branch_name: str) -> None:
if not self.repo.head.is_detached and self.repo.active_branch.name == branch_name:
remaining_heads = [head for head in self.repo.heads if head.name != branch_name]
if not remaining_heads:
raise ValueError(f"Cannot delete the only branch: {branch_name}")
remaining_heads[0].checkout()
self.repo.delete_head(branch_name, force=True)
def verify_working_directory_files(self, expected_files: List[Tuple[str, str]]) -> None:
"""Verify that working directory contains exactly the expected files with correct content.