Skip to content

Commit 75062c1

Browse files
solababsdummyuser
authored andcommitted
refactor test
1 parent d8c187b commit 75062c1

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

backend/tests/unit/git/conftest.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,3 +1371,11 @@ async def mock_create_branch_git_repo_01(db: InfrahubDatabase, default_branch: B
13711371
@pytest.fixture
13721372
async def mock_create_branch_git_repo_03(db: InfrahubDatabase, default_branch: Branch) -> None:
13731373
await create_branch(branch_name="branch01", db=db)
1374+
1375+
1376+
def git_user_config():
1377+
config.SETTINGS.git.user_email = "[email protected]"
1378+
config.SETTINGS.git.user_name = "Test User"
1379+
yield
1380+
config.SETTINGS.git.user_email = None
1381+
config.SETTINGS.git.user_name = None

backend/tests/unit/git/test_git_repository.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
from infrahub_sdk.uuidt import UUIDT
1313
from pytest_httpx._httpx_mock import HTTPXMock
1414

15-
from infrahub import config
1615
from infrahub.core.branch import Branch
1716
from infrahub.core.constants import InfrahubKind
1817
from infrahub.core.registry import registry
@@ -1107,10 +1106,7 @@ async def test_get_filtered_remote_branches__no_import_sync_branch_names(git_rep
11071106
assert sorted(filtered_remote_branches.keys()) == ["branch01", "branch02", "clean-branch", "main"]
11081107

11091108

1110-
async def test_new_repo_has_config(git_upstream_repo_01: dict[str, str | Path], git_repos_dir: Path):
1111-
config.SETTINGS.git.user_email = "[email protected]"
1112-
config.SETTINGS.git.user_name = "Test User"
1113-
1109+
async def test_new_repo_has_config(git_upstream_repo_01: dict[str, str | Path], git_repos_dir: Path, git_user_config):
11141110
repo = await InfrahubRepository.new(
11151111
id=UUIDT.new(),
11161112
name=git_upstream_repo_01["name"],
@@ -1127,6 +1123,3 @@ async def test_new_repo_has_config(git_upstream_repo_01: dict[str, str | Path],
11271123
with repo.get_git_repo_main().config_reader() as git_config:
11281124
assert git_config.get_value("user", "name") == "Test User"
11291125
assert git_config.get_value("user", "email") == "[email protected]"
1130-
1131-
config.SETTINGS.git.user_email = None
1132-
config.SETTINGS.git.user_name = None

0 commit comments

Comments
 (0)