| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 88c2505 commit 01d5f68
8 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -74,6 +74,10 @@ disable = [ | |||
| 74 | 74 | ||
| 75 | 75 | [tool.pytest.ini_options] | |
| 76 | 76 | xfail_strict = true | |
| 77 | + markers = [ | ||
| 78 | + "gitlab_premium: marks tests that require GitLab Premium", | ||
| 79 | + "gitlab_ultimate: marks tests that require GitLab Ultimate", | ||
| 80 | + ] | ||
| 77 | 81 | ||
| 78 | 82 | # If 'log_cli=True' the following apply | |
| 79 | 83 | # NOTE: If set 'log_cli_level' to 'DEBUG' will show a log of all of the HTTP requests | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,7 @@ | |||
| 1 | 1 | import pytest | |
| 2 | 2 | ||
| 3 | + pytestmark = pytest.mark.gitlab_premium | ||
| 4 | + | ||
| 3 | 5 | ||
| 4 | 6 | def test_epics(group): | |
| 5 | 7 | epic = group.epics.create({"title": "Test epic"}) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -82,6 +82,7 @@ def test_sidekiq_compound_metrics(gl): | |||
| 82 | 82 | assert "queues" in out | |
| 83 | 83 | ||
| 84 | 84 | ||
| 85 | + @pytest.mark.gitlab_premium | ||
| 85 | 86 | def test_geo_nodes(gl): | |
| 86 | 87 | # Very basic geo nodes tests because we only have 1 node. | |
| 87 | 88 | nodes = gl.geonodes.list() | |
@@ -91,6 +92,7 @@ def test_geo_nodes(gl): | |||
| 91 | 92 | assert isinstance(status, list) | |
| 92 | 93 | ||
| 93 | 94 | ||
| 95 | + @pytest.mark.gitlab_premium | ||
| 94 | 96 | def test_gitlab_license(gl): | |
| 95 | 97 | license = gl.get_license() | |
| 96 | 98 | assert "user_limit" in license | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -138,6 +138,7 @@ def test_group_labels(group): | |||
| 138 | 138 | assert label not in group.labels.list() | |
| 139 | 139 | ||
| 140 | 140 | ||
| 141 | + @pytest.mark.gitlab_premium | ||
| 141 | 142 | @pytest.mark.xfail(reason="/ldap/groups endpoint is gone") | |
| 142 | 143 | def test_group_ldap_links(gl, group): | |
| 143 | 144 | ldap_cn = "common-name" | |
@@ -234,9 +235,8 @@ def test_group_subgroups_projects(gl, user): | |||
| 234 | 235 | group4.delete() | |
| 235 | 236 | ||
| 236 | 237 | ||
| 237 | - def test_group_wiki(gitlab_ee, group): | ||
| 238 | - if not gitlab_ee: | ||
| 239 | - pytest.skip("Requires GitLab EE to run") | ||
| 238 | + @pytest.mark.gitlab_premium | ||
| 239 | + def test_group_wiki(group): | ||
| 240 | 240 | content = "Group Wiki page content" | |
| 241 | 241 | wiki = group.wikis.create({"title": "groupwikipage", "content": content}) | |
| 242 | 242 | assert wiki in group.wikis.list() | |
@@ -251,9 +251,8 @@ def test_group_wiki(gitlab_ee, group): | |||
| 251 | 251 | assert wiki not in group.wikis.list() | |
| 252 | 252 | ||
| 253 | 253 | ||
| 254 | - def test_group_hooks(gitlab_ee, group): | ||
| 255 | - if not gitlab_ee: | ||
| 256 | - pytest.skip("Requires GitLab EE to run") | ||
| 254 | + @pytest.mark.gitlab_premium | ||
| 255 | + def test_group_hooks(group): | ||
| 257 | 256 | hook = group.hooks.create({"url": "http://hook.url"}) | |
| 258 | 257 | assert hook in group.hooks.list() | |
| 259 | 258 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -41,11 +41,10 @@ def test_merge_requests_get(project, merge_request): | |||
| 41 | 41 | assert mr.iid == mr_iid | |
| 42 | 42 | ||
| 43 | 43 | ||
| 44 | - def test_merge_requests_list_approver_ids(project, gitlab_ee): | ||
| 44 | + @pytest.mark.gitlab_premium | ||
| 45 | + def test_merge_requests_list_approver_ids(project): | ||
| 45 | 46 | # show https://github.com/python-gitlab/python-gitlab/issues/1698 is now | |
| 46 | 47 | # fixed | |
| 47 | - if not gitlab_ee: | ||
| 48 | - pytest.skip("Requires GitLab EE to run") | ||
| 49 | 48 | project.mergerequests.list( | |
| 50 | 49 | all=True, | |
| 51 | 50 | state="opened", | |
@@ -117,6 +116,7 @@ def test_merge_request_rebase(project): | |||
| 117 | 116 | assert mr.rebase() | |
| 118 | 117 | ||
| 119 | 118 | ||
| 119 | + @pytest.mark.gitlab_premium | ||
| 120 | 120 | @pytest.mark.xfail(reason="project /approvers endpoint is gone") | |
| 121 | 121 | def test_project_approvals(project): | |
| 122 | 122 | mr = project.mergerequests.list()[0] | |
@@ -149,6 +149,7 @@ def test_project_approvals(project): | |||
| 149 | 149 | assert approval.approvers[0]["user"]["id"] == 1 | |
| 150 | 150 | ||
| 151 | 151 | ||
| 152 | + @pytest.mark.gitlab_premium | ||
| 152 | 153 | def test_project_merge_request_approval_rules(group, project): | |
| 153 | 154 | approval_rules = project.approvalrules.list(get_all=True) | |
| 154 | 155 | assert not approval_rules | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,7 @@ | |||
| 1 | 1 | import pytest | |
| 2 | 2 | ||
| 3 | 3 | ||
| 4 | + @pytest.mark.gitlab_premium | ||
| 4 | 5 | @pytest.mark.xfail(reason="need to relax RESTObject init for non-dict responses") | |
| 5 | 6 | def test_project_push_rules(project): | |
| 6 | 7 | push_rules = project.pushrules.get() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,6 +5,7 @@ | |||
| 5 | 5 | import time | |
| 6 | 6 | import uuid | |
| 7 | 7 | from subprocess import check_output | |
| 8 | + from typing import Optional | ||
| 8 | 9 | ||
| 9 | 10 | import pytest | |
| 10 | 11 | import requests | |
@@ -66,7 +67,7 @@ def gitlab_url(docker_ip: str, gitlab_docker_port: int) -> str: | |||
| 66 | 67 | def reset_gitlab(gl: gitlab.Gitlab) -> None: | |
| 67 | 68 | """Delete resources (such as projects, groups, users) that shouldn't | |
| 68 | 69 | exist.""" | |
| 69 | - if is_gitlab_ee(gl): | ||
| 70 | + if helpers.get_gitlab_plan(gl): | ||
| 70 | 71 | logging.info("GitLab EE detected") | |
| 71 | 72 | # NOTE(jlvillal): By default in GitLab EE it will wait 7 days before | |
| 72 | 73 | # deleting a group. Disable delayed group/project deletion. | |
@@ -280,21 +281,27 @@ def gl(gitlab_config): | |||
| 280 | 281 | return instance | |
| 281 | 282 | ||
| 282 | 283 | ||
| 283 | - def is_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 | - except gitlab.exceptions.GitlabLicenseError: | ||
| 288 | - license = None | ||
| 289 | - # If we have a license then we assume we are running on GitLab EE | ||
| 290 | - if license: | ||
| 291 | - return True | ||
| 292 | - return False | ||
| 284 | + @pytest.fixture(scope="session") | ||
| 285 | + def gitlab_plan(gl: gitlab.Gitlab) -> Optional[str]: | ||
| 286 | + return helpers.get_gitlab_plan(gl) | ||
| 293 | 287 | ||
| 294 | 288 | ||
| 295 | - @pytest.fixture(scope="session") | ||
| 296 | - def gitlab_ee(gl) -> bool: | ||
| 297 | - return is_gitlab_ee(gl=gl) | ||
| 289 | + @pytest.fixture(autouse=True) | ||
| 290 | + def gitlab_premium(gitlab_plan, request) -> None: | ||
| 291 | + if gitlab_plan in ("premium", "ultimate"): | ||
| 292 | + return | ||
| 293 | + | ||
| 294 | + if request.node.get_closest_marker("gitlab_ultimate"): | ||
| 295 | + pytest.skip("Test requires GitLab Premium plan") | ||
| 296 | + | ||
| 297 | + | ||
| 298 | + @pytest.fixture(autouse=True) | ||
| 299 | + def gitlab_ultimate(gitlab_plan, request) -> None: | ||
| 300 | + if gitlab_plan == "ultimate": | ||
| 301 | + return | ||
| 302 | + | ||
| 303 | + if request.node.get_closest_marker("gitlab_ultimate"): | ||
| 304 | + pytest.skip("Test requires GitLab Ultimate plan") | ||
| 298 | 305 | ||
| 299 | 306 | ||
| 300 | 307 | @pytest.fixture(scope="session") | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,15 +1,29 @@ | |||
| 1 | 1 | import logging | |
| 2 | 2 | import time | |
| 3 | + from typing import Optional | ||
| 3 | 4 | ||
| 4 | 5 | import pytest | |
| 5 | 6 | ||
| 7 | + import gitlab | ||
| 6 | 8 | import gitlab.base | |
| 9 | + import gitlab.exceptions | ||
| 7 | 10 | ||
| 8 | 11 | SLEEP_INTERVAL = 0.5 | |
| 9 | 12 | TIMEOUT = 60 # seconds before timeout will occur | |
| 10 | 13 | MAX_ITERATIONS = int(TIMEOUT / SLEEP_INTERVAL) | |
| 11 | 14 | ||
| 12 | 15 | ||
| 16 | + def get_gitlab_plan(gl: gitlab.Gitlab) -> Optional[str]: | ||
| 17 | + """Determine the license available on the GitLab instance""" | ||
| 18 | + try: | ||
| 19 | + license = gl.get_license() | ||
| 20 | + except gitlab.exceptions.GitlabLicenseError: | ||
| 21 | + # Without a license we assume only Free features are available | ||
| 22 | + return | ||
| 23 | + | ||
| 24 | + return license["plan"] | ||
| 25 | + | ||
| 26 | + | ||
| 13 | 27 | def safe_delete( | |
| 14 | 28 | object: gitlab.base.RESTObject, | |
| 15 | 29 | *, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments