|
5 | 5 | importtime |
6 | 6 | importuuid |
7 | 7 | fromsubprocessimportcheck_output |
| 8 | +fromtypingimportOptional |
8 | 9 |
|
9 | 10 | importpytest |
10 | 11 | importrequests |
@@ -66,7 +67,7 @@ def gitlab_url(docker_ip: str, gitlab_docker_port: int) -> str: |
66 | 67 | defreset_gitlab(gl:gitlab.Gitlab)->None: |
67 | 68 | """Delete resources (such as projects, groups, users) that shouldn't |
68 | 69 | exist.""" |
69 | | -ifis_gitlab_ee(gl): |
| 70 | +ifhelpers.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 | returninstance |
281 | 282 |
|
282 | 283 |
|
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) |
293 | 287 |
|
294 | 288 |
|
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") |
298 | 305 |
|
299 | 306 |
|
300 | 307 | @pytest.fixture(scope="session") |
|