mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-30 06:11:26 -07:00
Add unit tests for ansible.module_utils.urls (#38059)
* Start of tests for ansible.module_utils.urls * Start adding file for generic functions throughout urls * Add tests for maybe_add_ssl_handler * Remove commented out line * Improve coverage of maybe_add_ssl_handler, test basic_auth_header * Start tests for open_url * pep8 and ignore urlopen in test_url_open.py tests * Extend auth tests, add test for validate_certs=False * Finish tests for open_url * Add tests for fetch_url * Add fetch_url tests to replace-urlopen ignore * dummy instead of _ * Add BadStatusLine test * Reorganize/rename tests * Add tests for RedirectHandlerFactory * Add POST test to confirm behavior is to convert to GET * Update tests to handle recent changes to RedirectHandlerFactory * Special test, just to confirm that aliasing http_error_308 to http_error_307 does not cause issues with urllib2 type redirects
This commit is contained in:
parent
eccccfe77f
commit
6332beef65
13 changed files with 936 additions and 1 deletions
22
test/units/module_utils/urls/test_RequestWithMethod.py
Normal file
22
test/units/module_utils/urls/test_RequestWithMethod.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# (c) 2018 Matt Martz <matt@sivel.net>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
from __future__ import absolute_import, division, print_function
|
||||
__metaclass__ = type
|
||||
|
||||
from ansible.module_utils.urls import RequestWithMethod
|
||||
|
||||
|
||||
def test_RequestWithMethod():
|
||||
get = RequestWithMethod('https://ansible.com/', 'GET')
|
||||
assert get.get_method() == 'GET'
|
||||
|
||||
post = RequestWithMethod('https://ansible.com/', 'POST', data='foo', headers={'Bar': 'baz'})
|
||||
assert post.get_method() == 'POST'
|
||||
assert post.get_full_url() == 'https://ansible.com/'
|
||||
assert post.data == 'foo'
|
||||
assert post.headers == {'Bar': 'baz'}
|
||||
|
||||
none = RequestWithMethod('https://ansible.com/', '')
|
||||
assert none.get_method() == 'GET'
|
Loading…
Add table
Add a link
Reference in a new issue