|
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 | +} |
85 | 91 |
|
86 | 92 |
|
87 | 93 | @pytest.fixture |
@@ -541,6 +547,32 @@ def resp_artifact(): |
541 | 547 | yield rsps |
542 | 548 |
|
543 | 549 |
|
| 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 | + |
544 | 576 | def test_get_project(gl, resp_get_project): |
545 | 577 | data = gl.projects.get(1) |
546 | 578 | assert isinstance(data, Project) |
@@ -756,3 +788,17 @@ def test_project_pull_mirror(project, resp_start_pull_mirroring_project): |
756 | 788 | def test_project_snapshot(project, resp_snapshot_project): |
757 | 789 | tar_file = project.snapshot() |
758 | 790 | 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 |
0 commit comments