diff options
author | Nejc Habjan <nejc.habjan@siemens.com> | 2022-07-05 12:17:04 +0200 |
---|---|---|
committer | John Villalovos <john@sodarock.com> | 2022-07-05 09:19:34 -0700 |
commit | 3f67c4b0fb0b9a39c8b93529a05b1541fcebcabe (patch) | |
tree | 2d147e85987036e077630512ab68644dc2f9c623 /tests | |
parent | 6e1342fc0b7cf740b25a939942ea02cdd18a9625 (diff) | |
download | gitlab-3f67c4b0fb0b9a39c8b93529a05b1541fcebcabe.tar.gz |
feat(cli): add support for global CI lint
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/objects/test_ci_lint.py | 44 |
1 files changed, 33 insertions, 11 deletions
diff --git a/tests/unit/objects/test_ci_lint.py b/tests/unit/objects/test_ci_lint.py index 6591198..509a5ed 100644 --- a/tests/unit/objects/test_ci_lint.py +++ b/tests/unit/objects/test_ci_lint.py @@ -1,7 +1,15 @@ import pytest import responses -ci_lint_get_content = { +gitlab_ci_yml = """--- +:test_job: + :script: echo 1 +""" + +ci_lint_create_content = {"status": "valid", "errors": [], "warnings": []} + + +project_ci_lint_content = { "valid": True, "merged_yaml": "---\n:test_job:\n :script: echo 1\n", "errors": [], @@ -10,12 +18,25 @@ ci_lint_get_content = { @pytest.fixture -def resp_get_ci_lint(): +def resp_create_ci_lint(): + with responses.RequestsMock() as rsps: + rsps.add( + method=responses.POST, + url="http://localhost/api/v4/ci/lint", + json=ci_lint_create_content, + content_type="application/json", + status=200, + ) + yield rsps + + +@pytest.fixture +def resp_get_project_ci_lint(): with responses.RequestsMock() as rsps: rsps.add( method=responses.GET, url="http://localhost/api/v4/projects/1/ci/lint", - json=ci_lint_get_content, + json=project_ci_lint_content, content_type="application/json", status=200, ) @@ -23,27 +44,28 @@ def resp_get_ci_lint(): @pytest.fixture -def resp_create_ci_lint(): +def resp_create_project_ci_lint(): with responses.RequestsMock() as rsps: rsps.add( method=responses.POST, url="http://localhost/api/v4/projects/1/ci/lint", - json=ci_lint_get_content, + json=project_ci_lint_content, content_type="application/json", status=200, ) yield rsps -def test_project_ci_lint_get(project, resp_get_ci_lint): +def test_ci_lint_create(gl, resp_create_ci_lint): + lint_result = gl.ci_lint.create({"content": gitlab_ci_yml}) + assert lint_result.status == "valid" + + +def test_project_ci_lint_get(project, resp_get_project_ci_lint): lint_result = project.ci_lint.get() assert lint_result.valid is True -def test_project_ci_lint_create(project, resp_create_ci_lint): - gitlab_ci_yml = """--- -:test_job: - :script: echo 1 -""" +def test_project_ci_lint_create(project, resp_create_project_ci_lint): lint_result = project.ci_lint.create({"content": gitlab_ci_yml}) assert lint_result.valid is True |