mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
6332beef65
* 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
22 lines
790 B
Python
22 lines
790 B
Python
# -*- 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'
|