Skip to content
Myr

Added tests for should_bypass_proxies function

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Kumar Varadarajulu · committed by Kumar Varadarajulu · parent 17b6c57 · Browse files · 1 file+37 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+37 added−1 removed

  • tests:+37 added−1 removed

1 file+37 added−1 removed

modified:tests/test_utils.py+37 added-1 removed
9 unmodified lines
10 get_encodings_from_content, get_environ_proxies,11 guess_filename, guess_json_utf, is_ipv4_address,12 is_valid_cidr, iter_slices, parse_dict_header,13 parse_header_links, prepend_scheme_if_needed,14 requote_uri, select_proxy, super_len,14 requote_uri, select_proxy, should_bypass_proxies, super_len,15 to_key_val_list, to_native_string,16 unquote_header_value, unquote_unreserved,17 urldefragauth)18
111 unmodified lines
130 def test_not_bypass(self, url):131 assert get_environ_proxies(url) != {}132133134class TestShouldBypassProxies:135 """136 Tests for should_bypass_proxies function137 """138139 @pytest.mark.parametrize(140 'url, expected', (141 ('http://192.168.0.1:5000/', True),142 ('http://192.168.0.1/', True),143 ('http://172.16.1.1/', True),144 ('http://172.16.1.1:5000/', True),145 ('http://localhost.localdomain:5000/v1.0/', True),146 ))147 def test_should_bypass_proxies(self, url, expected, monkeypatch):148 """149 Test to check if proxy is bypassed150 """151 monkeypatch.setenv('no_proxy', '192.168.0.0/24,127.0.0.1,localhost.localdomain,172.16.1.1')152 monkeypatch.setenv('NO_PROXY', '192.168.0.0/24,127.0.0.1,localhost.localdomain,172.16.1.1')153 assert should_bypass_proxies(url) == expected154155 @pytest.mark.parametrize(156 'url, expected', (157 ('http://172.16.1.12/', False),158 ('http://172.16.1.12:5000/', False),159 ('http://google.com:5000/v1.0/', False),160 ))161 def test_should_bypass_proxies(self, url, expected, monkeypatch):162 """163 Test to check if proxy is not bypassed164 """165 monkeypatch.setenv('no_proxy', '192.168.0.0/24,127.0.0.1,localhost.localdomain,172.16.1.1')166 monkeypatch.setenv('NO_PROXY', '192.168.0.0/24,127.0.0.1,localhost.localdomain,172.16.1.1')167 assert should_bypass_proxies(url) == expected168169170class TestIsIPv4Address:171172 def test_valid(self):173 assert is_ipv4_address('8.8.8.8')
293 unmodified lines