Test for _get_url_data in jenkins_plugin.py (#24905)
* Test for _get_url_data in jenkins_plugin.py * PEP8 fix
This commit is contained in:
parent
43fc97cad3
commit
3b45a9eb58
1 changed files with 31 additions and 0 deletions
31
test/units/modules/web_infrastructure/test_jenkins_plugin.py
Normal file
31
test/units/modules/web_infrastructure/test_jenkins_plugin.py
Normal file
|
@ -0,0 +1,31 @@
|
|||
import collections
|
||||
import mock
|
||||
|
||||
from ansible.modules.web_infrastructure.jenkins_plugin import JenkinsPlugin
|
||||
|
||||
|
||||
def pass_function(*args, **kwargs):
|
||||
pass
|
||||
|
||||
|
||||
def test__get_json_data(mocker):
|
||||
"test the json conversion of _get_url_data"
|
||||
|
||||
url = 'https://api.github.com/repos/ansible/ansible'
|
||||
timeout = 30
|
||||
params = {
|
||||
'url': url,
|
||||
'timeout': timeout
|
||||
}
|
||||
module = mock.Mock()
|
||||
module.params = params
|
||||
|
||||
JenkinsPlugin._csrf_enabled = pass_function
|
||||
JenkinsPlugin._get_installed_plugins = pass_function
|
||||
jenkins_plugin = JenkinsPlugin(module)
|
||||
|
||||
json_data = jenkins_plugin._get_json_data(
|
||||
"{url}".format(url=url),
|
||||
'CSRF')
|
||||
|
||||
assert isinstance(json_data, collections.Mapping)
|
Loading…
Reference in a new issue