Skip to content

Commit 553c471

Browse files
committed
Make args fixture customizable it tests
1 parent ac39915 commit 553c471

2 files changed

Lines changed: 76 additions & 13 deletions

File tree

tests/conftest.py

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import pytest
2+
3+
from autogit.data_types import CliArguments
4+
5+
6+
@pytest.fixture
7+
def action_id() -> str:
8+
return 'test_action_id'
9+
10+
11+
@pytest.fixture
12+
def repos() -> list[str]:
13+
return (['https://gitlab.com/myuser/myreponame.git'],)
14+
15+
16+
@pytest.fixture
17+
def clone_to() -> str:
18+
return 'tmp'
19+
20+
21+
@pytest.fixture
22+
def commands() -> list[str] | str:
23+
return ['echo', "'Hello'"]
24+
25+
26+
@pytest.fixture
27+
def commit_message() -> str:
28+
return 'Test commit message'
29+
30+
31+
@pytest.fixture
32+
def verbose() -> bool:
33+
return False
34+
35+
36+
@pytest.fixture
37+
def source_branch() -> str:
38+
return 'test_source_branch'
39+
40+
41+
@pytest.fixture
42+
def target_branch() -> str:
43+
return 'test_target_branch'
44+
45+
46+
@pytest.fixture
47+
def branch() -> str:
48+
return 'test_branch'
49+
50+
51+
@pytest.fixture
52+
def args(
53+
action_id,
54+
repos,
55+
clone_to,
56+
commands,
57+
commit_message,
58+
verbose,
59+
source_branch,
60+
branch,
61+
target_branch,
62+
) -> CliArguments:
63+
return CliArguments(
64+
action_id=action_id,
65+
repos=repos,
66+
clone_to=clone_to,
67+
commands=commands,
68+
commit_message=commit_message,
69+
verbose=verbose,
70+
source_branch=source_branch,
71+
branch=branch,
72+
target_branch=target_branch,
73+
)

tests/test_4_clone_repositories.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,14 @@
88
> API changes so I should better have real repositories to test.
99
1010
"""
11+
1112
import os
1213
from unittest.mock import patch
1314

1415
import pytest
1516

1617
from autogit.actions._4_clone_repositories import (
17-
clone_repositories,
18-
clone_repository,
1918
get_repo_access_url,
20-
print_cloned_repositories,
2119
)
2220

2321
## Methods to test:
@@ -27,7 +25,6 @@
2725
# def clone_repositories(repos: dict[str, RepoState], executor: ThrottledTasksExecutor) -> None:
2826

2927

30-
3128
@pytest.mark.parametrize(
3229
('repo_url', 'expected_access_url'),
3330
[
@@ -40,11 +37,7 @@
4037
'https://gitlab.com/mygroup/myuser/myreponame.git',
4138
'https://api:<GITLAB_ACCESS_TOKEN>@gitlab.com/mygroup/myuser/myreponame.git',
4239
),
43-
(
44-
'git@gitlab.com:niekas/jsonstate.git',
45-
'git@gitlab.com:niekas/jsonstate.git'
46-
),
47-
40+
('git@gitlab.com:myusername/myreponame.git', 'git@gitlab.com:myusername/myreponame.git'),
4841
# Managed repos
4942
(
5043
'https://managedgit.com/myuser/myreponame',
@@ -62,7 +55,6 @@
6255
'https://managedgit.com/mygroup/mysubgroup/mynamespace/myreponame.git',
6356
'https://api:<GIT_TOKEN>@managedgit.com/mygroup/mysubgroup/mynamespace/myreponame.git',
6457
),
65-
6658
# Github repos
6759
(
6860
'https://github.com/myuser/reponame.git',
@@ -81,11 +73,9 @@ def test_get_repo_access_url(repo_url, expected_access_url):
8173
'GITLAB_ACCESS_TOKEN': '<GITLAB_ACCESS_TOKEN>',
8274
'GITLAB_OAUTH_TOKEN': '<GITLAB_OAUTH_TOKEN>',
8375
'GITLAB_TOKEN': '<GITLAB_TOKEN>',
84-
8576
'GITHUB_OAUTH_TOKEN': '<GITHUB_OAUTH_TOKEN>',
8677
'GITHUB_ACCESS_TOKEN': '<GITHUB_ACCESS_TOKEN>',
8778
'GITHUB_TOKEN': '<GITHUB_TOKEN>',
88-
8979
'GIT_TOKEN': '<GIT_TOKEN>',
9080
'GIT_ACCESS_TOKEN': '<GIT_ACCESS_TOKEN>',
9181
'GIT_OAUTH_TOKEN': '<GIT_OAUTH_TOKEN>',
@@ -95,7 +85,7 @@ def test_get_repo_access_url(repo_url, expected_access_url):
9585
assert access_url == expected_access_url
9686

9787

98-
async def test_clone_repository():
88+
async def test_clone_repository(args):
9989
pass
10090

10191

0 commit comments

Comments
 (0)