Show More
@@ -37,13 +37,37 b' connection_available = pytest.mark.skipi' | |||
|
37 | 37 | not check_connection(), reason="No outside internet connection available") |
|
38 | 38 | |
|
39 | 39 | |
|
40 | @connection_available | |
|
41 | def test_connect_redirection_links(): | |
|
40 | import requests | |
|
41 | from requests.adapters import HTTPAdapter | |
|
42 | from requests.packages.urllib3.util.retry import Retry | |
|
43 | ||
|
42 | 44 | |
|
43 | for link_data in routing_links.link_config: | |
|
44 | response = requests.get(link_data['target']) | |
|
45 | if link_data['name'] == 'enterprise_license_convert_from_old': | |
|
46 | # special case for a page that requires a valid login | |
|
47 | assert response.url == 'https://rhodecode.com/login' | |
|
48 | else: | |
|
49 | assert response.url == link_data['external_target'] | |
|
45 | def requests_retry_session( | |
|
46 | retries=3, | |
|
47 | backoff_factor=0.3, | |
|
48 | status_forcelist=(500, 502, 504), | |
|
49 | session=None, | |
|
50 | ): | |
|
51 | session = session or requests.Session() | |
|
52 | retry = Retry( | |
|
53 | total=retries, | |
|
54 | read=retries, | |
|
55 | connect=retries, | |
|
56 | backoff_factor=backoff_factor, | |
|
57 | status_forcelist=status_forcelist, | |
|
58 | ) | |
|
59 | adapter = HTTPAdapter(max_retries=retry) | |
|
60 | session.mount('http://', adapter) | |
|
61 | session.mount('https://', adapter) | |
|
62 | return session | |
|
63 | ||
|
64 | ||
|
65 | @connection_available | |
|
66 | @pytest.mark.parametrize('link_data', routing_links.link_config) | |
|
67 | def test_connect_redirection_links(link_data): | |
|
68 | response = requests_retry_session().get(link_data['target']) | |
|
69 | if link_data['name'] == 'enterprise_license_convert_from_old': | |
|
70 | # special case for a page that requires a valid login | |
|
71 | assert response.url == 'https://rhodecode.com/login' | |
|
72 | else: | |
|
73 | assert response.url == link_data['external_target'] |
General Comments 0
You need to be logged in to leave comments.
Login now