-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2a6d5e6
commit faacbdc
Showing
12 changed files
with
132 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import pytest | ||
from api4jenkins.item import snake | ||
|
||
|
||
class TestSystem: | ||
|
||
@pytest.mark.parametrize('action', ['restart', 'safeRestart', 'quietDown', 'cancelQuietDown']) | ||
def test_enable_disable(self, jenkins, mock_resp, action): | ||
req_url = f'{jenkins.system.url}{action}' | ||
mock_resp.add('POST', req_url) | ||
getattr(jenkins.system, snake(action))() | ||
assert mock_resp.calls[0].request.url == req_url |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,32 @@ | ||
# encoding: utf-8 | ||
import pytest | ||
from api4jenkins.view import AllView | ||
class TestViews: | ||
pass | ||
|
||
def test_get(self, jenkins): | ||
view = jenkins.views.get('all') | ||
assert isinstance(view, AllView) | ||
assert view.url == jenkins.url + 'view/all/' | ||
assert jenkins.views.get('not exist') is None | ||
|
||
def test_views(self, jenkins): | ||
assert len(list(jenkins.views)) == 1 | ||
|
||
|
||
class TestView: | ||
|
||
def test_get_job(self, view): | ||
job_in_view = view.get_job('Level1_Folder1') | ||
job = view.jenkins.get_job('Level1_Folder1') | ||
assert job_in_view == job | ||
assert view.get_job('not exist') is None | ||
|
||
def test_iter(self, view): | ||
assert len(list(view)) == 2 | ||
|
||
@pytest.mark.parametrize('action, entry', [('include', 'addJobToView'), ('exclude', 'removeJobFromView')]) | ||
def test_include_exclude(self, view, mock_resp, action, entry): | ||
req_url = f'{view.url}{entry}?name=folder1' | ||
mock_resp.add('POST', req_url, json={'name': 'folder1'}) | ||
getattr(view, action)('folder1') | ||
assert mock_resp.calls[0].request.url == req_url |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"_class": "hudson.model.AllView", | ||
"description": null, | ||
"jobs": [ | ||
{ | ||
"_class": "org.jenkinsci.plugins.workflow.job.WorkflowJob", | ||
"name": "Level1_WorkflowJob1", | ||
"url": "http://0.0.0.0:8080/job/Level1_WorkflowJob1/", | ||
"color": "red" | ||
}, | ||
{ | ||
"_class": "com.cloudbees.hudson.plugins.folder.Folder", | ||
"name": "Level1_Folder1", | ||
"url": "http://0.0.0.0:8080/job/Level1_Folder1/" | ||
} | ||
], | ||
"name": "all", | ||
"property": [], | ||
"url": "http://http://0.0.0.0:8080/" | ||
} |