| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 1fbfb22 commit 6491f1b
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -25,6 +25,7 @@ | |||
| 25 | 25 | from .boards import * | |
| 26 | 26 | from .branches import * | |
| 27 | 27 | from .broadcast_messages import * | |
| 28 | + from .ci_lint import * | ||
| 28 | 29 | from .clusters import * | |
| 29 | 30 | from .commits import * | |
| 30 | 31 | from .container_registry import * | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,22 @@ | |||
| 1 | + """ | ||
| 2 | + GitLab API: | ||
| 3 | + https://docs.gitlab.com/ee/api/lint.html | ||
| 4 | + """ | ||
| 5 | + | ||
| 6 | + from typing import Any, cast | ||
| 7 | + | ||
| 8 | + from gitlab.base import RESTManager, RESTObject | ||
| 9 | + from gitlab.mixins import CreateMixin, GetWithoutIdMixin | ||
| 10 | + | ||
| 11 | + | ||
| 12 | + class ProjectCiLint(RESTObject): | ||
| 13 | + pass | ||
| 14 | + | ||
| 15 | + | ||
| 16 | + class ProjectCiLintManager(GetWithoutIdMixin, CreateMixin, RESTManager): | ||
| 17 | + _path = "/projects/{project_id}/ci/lint" | ||
| 18 | + _obj_cls = ProjectCiLint | ||
| 19 | + _from_parent_attrs = {"project_id": "id"} | ||
| 20 | + | ||
| 21 | + def get(self, **kwargs: Any) -> ProjectCiLint: | ||
| 22 | + return cast(ProjectCiLint, super().get(**kwargs)) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,7 +1,6 @@ | |||
| 1 | 1 | """ | |
| 2 | 2 | GitLab API: | |
| 3 | 3 | https://docs.gitlab.com/ee/api/projects.html | |
| 4 | - https://docs.gitlab.com/ee/api/lint.html | ||
| 5 | 4 | """ | |
| 6 | 5 | from typing import ( | |
| 7 | 6 | Any, | |
@@ -39,6 +38,7 @@ | |||
| 39 | 38 | from .badges import ProjectBadgeManager # noqa: F401 | |
| 40 | 39 | from .boards import ProjectBoardManager # noqa: F401 | |
| 41 | 40 | from .branches import ProjectBranchManager, ProjectProtectedBranchManager # noqa: F401 | |
| 41 | + from .ci_lint import ProjectCiLint, ProjectCiLintManager # noqa: F401 | ||
| 42 | 42 | from .clusters import ProjectClusterManager # noqa: F401 | |
| 43 | 43 | from .commits import ProjectCommitManager # noqa: F401 | |
| 44 | 44 | from .container_registry import ProjectRegistryRepositoryManager # noqa: F401 | |
@@ -1063,18 +1063,3 @@ class ProjectStorageManager(GetWithoutIdMixin, RESTManager): | |||
| 1063 | 1063 | ||
| 1064 | 1064 | def get(self, **kwargs: Any) -> ProjectStorage: | |
| 1065 | 1065 | return cast(ProjectStorage, super().get(**kwargs)) | |
| 1066 | - | ||
| 1067 | - | ||
| 1068 | - class ProjectCiLint(RESTObject): | ||
| 1069 | - pass | ||
| 1070 | - | ||
| 1071 | - | ||
| 1072 | - class ProjectCiLintManager(GetWithoutIdMixin, CreateMixin, RESTManager): | ||
| 1073 | - """GitLab API: https://docs.gitlab.com/ee/api/lint.html""" | ||
| 1074 | - | ||
| 1075 | - _path = "/projects/{project_id}/ci/lint" | ||
| 1076 | - _obj_cls = ProjectCiLint | ||
| 1077 | - _from_parent_attrs = {"project_id": "id"} | ||
| 1078 | - | ||
| 1079 | - def get(self, **kwargs: Any) -> ProjectCiLint: | ||
| 1080 | - return cast(ProjectCiLint, super().get(**kwargs)) | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,49 @@ | |||
| 1 | + import pytest | ||
| 2 | + import responses | ||
| 3 | + | ||
| 4 | + ci_lint_get_content = { | ||
| 5 | + "valid": True, | ||
| 6 | + "merged_yaml": "---\n:test_job:\n :script: echo 1\n", | ||
| 7 | + "errors": [], | ||
| 8 | + "warnings": [], | ||
| 9 | + } | ||
| 10 | + | ||
| 11 | + | ||
| 12 | + @pytest.fixture | ||
| 13 | + def resp_get_ci_lint(): | ||
| 14 | + with responses.RequestsMock() as rsps: | ||
| 15 | + rsps.add( | ||
| 16 | + method=responses.GET, | ||
| 17 | + url="http://localhost/api/v4/projects/1/ci/lint", | ||
| 18 | + json=ci_lint_get_content, | ||
| 19 | + content_type="application/json", | ||
| 20 | + status=200, | ||
| 21 | + ) | ||
| 22 | + yield rsps | ||
| 23 | + | ||
| 24 | + | ||
| 25 | + @pytest.fixture | ||
| 26 | + def resp_create_ci_lint(): | ||
| 27 | + with responses.RequestsMock() as rsps: | ||
| 28 | + rsps.add( | ||
| 29 | + method=responses.POST, | ||
| 30 | + url="http://localhost/api/v4/projects/1/ci/lint", | ||
| 31 | + json=ci_lint_get_content, | ||
| 32 | + content_type="application/json", | ||
| 33 | + status=200, | ||
| 34 | + ) | ||
| 35 | + yield rsps | ||
| 36 | + | ||
| 37 | + | ||
| 38 | + def test_project_ci_lint_get(project, resp_get_ci_lint): | ||
| 39 | + lint_result = project.ci_lint.get() | ||
| 40 | + assert lint_result.valid is True | ||
| 41 | + | ||
| 42 | + | ||
| 43 | + def test_project_ci_lint_create(project, resp_create_ci_lint): | ||
| 44 | + gitlab_ci_yml = """--- | ||
| 45 | + :test_job: | ||
| 46 | + :script: echo 1 | ||
| 47 | + """ | ||
| 48 | + lint_result = project.ci_lint.create({"content": gitlab_ci_yml}) | ||
| 49 | + assert lint_result.valid is True | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -82,12 +82,6 @@ | |||
| 82 | 82 | "status": "created", | |
| 83 | 83 | "source": "trigger", | |
| 84 | 84 | } | |
| 85 | - ci_lint_get_content = { | ||
| 86 | - "valid": True, | ||
| 87 | - "merged_yaml": "---\n:test_job:\n :script: echo 1\n", | ||
| 88 | - "errors": [], | ||
| 89 | - "warnings": [], | ||
| 90 | - } | ||
| 91 | 85 | ||
| 92 | 86 | ||
| 93 | 87 | @pytest.fixture | |
@@ -547,32 +541,6 @@ def resp_artifact(): | |||
| 547 | 541 | yield rsps | |
| 548 | 542 | ||
| 549 | 543 | ||
| 550 | - @pytest.fixture | ||
| 551 | - def resp_get_ci_lint(): | ||
| 552 | - with responses.RequestsMock() as rsps: | ||
| 553 | - rsps.add( | ||
| 554 | - method=responses.GET, | ||
| 555 | - url="http://localhost/api/v4/projects/1/ci/lint", | ||
| 556 | - json=ci_lint_get_content, | ||
| 557 | - content_type="application/json", | ||
| 558 | - status=200, | ||
| 559 | - ) | ||
| 560 | - yield rsps | ||
| 561 | - | ||
| 562 | - | ||
| 563 | - @pytest.fixture | ||
| 564 | - def resp_create_ci_lint(): | ||
| 565 | - with responses.RequestsMock() as rsps: | ||
| 566 | - rsps.add( | ||
| 567 | - method=responses.POST, | ||
| 568 | - url="http://localhost/api/v4/projects/1/ci/lint", | ||
| 569 | - json=ci_lint_get_content, | ||
| 570 | - content_type="application/json", | ||
| 571 | - status=200, | ||
| 572 | - ) | ||
| 573 | - yield rsps | ||
| 574 | - | ||
| 575 | - | ||
| 576 | 544 | def test_get_project(gl, resp_get_project): | |
| 577 | 545 | data = gl.projects.get(1) | |
| 578 | 546 | assert isinstance(data, Project) | |
@@ -788,17 +756,3 @@ def test_project_pull_mirror(project, resp_start_pull_mirroring_project): | |||
| 788 | 756 | def test_project_snapshot(project, resp_snapshot_project): | |
| 789 | 757 | tar_file = project.snapshot() | |
| 790 | 758 | assert isinstance(tar_file, bytes) | |
| 791 | - | ||
| 792 | - | ||
| 793 | - def test_project_ci_lint_get(project, resp_get_ci_lint): | ||
| 794 | - lint_result = project.ci_lint.get() | ||
| 795 | - assert lint_result.valid is True | ||
| 796 | - | ||
| 797 | - | ||
| 798 | - def test_project_ci_lint_create(project, resp_create_ci_lint): | ||
| 799 | - gitlab_ci_yml = """--- | ||
| 800 | - :test_job: | ||
| 801 | - :script: echo 1 | ||
| 802 | - """ | ||
| 803 | - lint_result = project.ci_lint.create({"content": gitlab_ci_yml}) | ||
| 804 | - assert lint_result.valid is True | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments