Debian Codegraph @

test/units/module_utils/urls/test_generic_urlparse.py

raw
1 # -*- coding: utf-8 -*-
2 # (c) 2018 Matt Martz <[email protected]>
3 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
4
5 from __future__ import annotations
6
7 from ansible.module_utils.urls import generic_urlparse
8 from urllib.parse import urlparse, urlunparse
9
10
11 def test_generic_urlparse():
12 url = 'https://ansible.com/blog'
13 parts = urlparse(url)
14 generic_parts = generic_urlparse(parts)
15 assert generic_parts.as_list() == list(parts)
16
17 assert urlunparse(generic_parts.as_list()) == url
18
19
20 def test_generic_urlparse_netloc():
21 url = 'https://ansible.com:443/blog'
22 parts = urlparse(url)
23 generic_parts = generic_urlparse(parts)
24 assert generic_parts.hostname == parts.hostname
25 assert generic_parts.hostname == 'ansible.com'
26 assert generic_parts.port == 443
27 assert urlunparse(generic_parts.as_list()) == url