Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit01d5f68

Browse files
nejchJohnVillalovos
authored andcommitted
test: enable skipping tests per GitLab plan
1 parent88c2505 commit01d5f68

File tree

8 files changed

+53
-23
lines changed

8 files changed

+53
-23
lines changed

‎pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ disable = [
7474

7575
[tool.pytest.ini_options]
7676
xfail_strict =true
77+
markers = [
78+
"gitlab_premium: marks tests that require GitLab Premium",
79+
"gitlab_ultimate: marks tests that require GitLab Ultimate",
80+
]
7781

7882
# If 'log_cli=True' the following apply
7983
# NOTE: If set 'log_cli_level' to 'DEBUG' will show a log of all of the HTTP requests

‎tests/functional/api/test_epics.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
importpytest
22

3+
pytestmark=pytest.mark.gitlab_premium
4+
35

46
deftest_epics(group):
57
epic=group.epics.create({"title":"Test epic"})

‎tests/functional/api/test_gitlab.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ def test_sidekiq_compound_metrics(gl):
8282
assert"queues"inout
8383

8484

85+
@pytest.mark.gitlab_premium
8586
deftest_geo_nodes(gl):
8687
# Very basic geo nodes tests because we only have 1 node.
8788
nodes=gl.geonodes.list()
@@ -91,6 +92,7 @@ def test_geo_nodes(gl):
9192
assertisinstance(status,list)
9293

9394

95+
@pytest.mark.gitlab_premium
9496
deftest_gitlab_license(gl):
9597
license=gl.get_license()
9698
assert"user_limit"inlicense

‎tests/functional/api/test_groups.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ def test_group_labels(group):
138138
assertlabelnotingroup.labels.list()
139139

140140

141+
@pytest.mark.gitlab_premium
141142
@pytest.mark.xfail(reason="/ldap/groups endpoint is gone")
142143
deftest_group_ldap_links(gl,group):
143144
ldap_cn="common-name"
@@ -234,9 +235,8 @@ def test_group_subgroups_projects(gl, user):
234235
group4.delete()
235236

236237

237-
deftest_group_wiki(gitlab_ee,group):
238-
ifnotgitlab_ee:
239-
pytest.skip("Requires GitLab EE to run")
238+
@pytest.mark.gitlab_premium
239+
deftest_group_wiki(group):
240240
content="Group Wiki page content"
241241
wiki=group.wikis.create({"title":"groupwikipage","content":content})
242242
assertwikiingroup.wikis.list()
@@ -251,9 +251,8 @@ def test_group_wiki(gitlab_ee, group):
251251
assertwikinotingroup.wikis.list()
252252

253253

254-
deftest_group_hooks(gitlab_ee,group):
255-
ifnotgitlab_ee:
256-
pytest.skip("Requires GitLab EE to run")
254+
@pytest.mark.gitlab_premium
255+
deftest_group_hooks(group):
257256
hook=group.hooks.create({"url":"http://hook.url"})
258257
asserthookingroup.hooks.list()
259258

‎tests/functional/api/test_merge_requests.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,10 @@ def test_merge_requests_get(project, merge_request):
4141
assertmr.iid==mr_iid
4242

4343

44-
deftest_merge_requests_list_approver_ids(project,gitlab_ee):
44+
@pytest.mark.gitlab_premium
45+
deftest_merge_requests_list_approver_ids(project):
4546
# show https://github.com/python-gitlab/python-gitlab/issues/1698 is now
4647
# fixed
47-
ifnotgitlab_ee:
48-
pytest.skip("Requires GitLab EE to run")
4948
project.mergerequests.list(
5049
all=True,
5150
state="opened",
@@ -117,6 +116,7 @@ def test_merge_request_rebase(project):
117116
assertmr.rebase()
118117

119118

119+
@pytest.mark.gitlab_premium
120120
@pytest.mark.xfail(reason="project /approvers endpoint is gone")
121121
deftest_project_approvals(project):
122122
mr=project.mergerequests.list()[0]
@@ -149,6 +149,7 @@ def test_project_approvals(project):
149149
assertapproval.approvers[0]["user"]["id"]==1
150150

151151

152+
@pytest.mark.gitlab_premium
152153
deftest_project_merge_request_approval_rules(group,project):
153154
approval_rules=project.approvalrules.list(get_all=True)
154155
assertnotapproval_rules

‎tests/functional/api/test_push_rules.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
importpytest
22

33

4+
@pytest.mark.gitlab_premium
45
@pytest.mark.xfail(reason="need to relax RESTObject init for non-dict responses")
56
deftest_project_push_rules(project):
67
push_rules=project.pushrules.get()

‎tests/functional/conftest.py

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
importtime
66
importuuid
77
fromsubprocessimportcheck_output
8+
fromtypingimportOptional
89

910
importpytest
1011
importrequests
@@ -66,7 +67,7 @@ def gitlab_url(docker_ip: str, gitlab_docker_port: int) -> str:
6667
defreset_gitlab(gl:gitlab.Gitlab)->None:
6768
"""Delete resources (such as projects, groups, users) that shouldn't
6869
exist."""
69-
ifis_gitlab_ee(gl):
70+
ifhelpers.get_gitlab_plan(gl):
7071
logging.info("GitLab EE detected")
7172
# NOTE(jlvillal): By default in GitLab EE it will wait 7 days before
7273
# deleting a group. Disable delayed group/project deletion.
@@ -280,21 +281,27 @@ def gl(gitlab_config):
280281
returninstance
281282

282283

283-
defis_gitlab_ee(gl:gitlab.Gitlab)->bool:
284-
"""Determine if we are running with GitLab EE as opposed to GitLab CE"""
285-
try:
286-
license=gl.get_license()
287-
exceptgitlab.exceptions.GitlabLicenseError:
288-
license=None
289-
# If we have a license then we assume we are running on GitLab EE
290-
iflicense:
291-
returnTrue
292-
returnFalse
284+
@pytest.fixture(scope="session")
285+
defgitlab_plan(gl:gitlab.Gitlab)->Optional[str]:
286+
returnhelpers.get_gitlab_plan(gl)
293287

294288

295-
@pytest.fixture(scope="session")
296-
defgitlab_ee(gl)->bool:
297-
returnis_gitlab_ee(gl=gl)
289+
@pytest.fixture(autouse=True)
290+
defgitlab_premium(gitlab_plan,request)->None:
291+
ifgitlab_planin ("premium","ultimate"):
292+
return
293+
294+
ifrequest.node.get_closest_marker("gitlab_ultimate"):
295+
pytest.skip("Test requires GitLab Premium plan")
296+
297+
298+
@pytest.fixture(autouse=True)
299+
defgitlab_ultimate(gitlab_plan,request)->None:
300+
ifgitlab_plan=="ultimate":
301+
return
302+
303+
ifrequest.node.get_closest_marker("gitlab_ultimate"):
304+
pytest.skip("Test requires GitLab Ultimate plan")
298305

299306

300307
@pytest.fixture(scope="session")

‎tests/functional/helpers.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,29 @@
11
importlogging
22
importtime
3+
fromtypingimportOptional
34

45
importpytest
56

7+
importgitlab
68
importgitlab.base
9+
importgitlab.exceptions
710

811
SLEEP_INTERVAL=0.5
912
TIMEOUT=60# seconds before timeout will occur
1013
MAX_ITERATIONS=int(TIMEOUT/SLEEP_INTERVAL)
1114

1215

16+
defget_gitlab_plan(gl:gitlab.Gitlab)->Optional[str]:
17+
"""Determine the license available on the GitLab instance"""
18+
try:
19+
license=gl.get_license()
20+
exceptgitlab.exceptions.GitlabLicenseError:
21+
# Without a license we assume only Free features are available
22+
return
23+
24+
returnlicense["plan"]
25+
26+
1327
defsafe_delete(
1428
object:gitlab.base.RESTObject,
1529
*,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp