@@ -60,8 +60,17 @@ def proxy_configuration() -> ProxyConfiguration:
60
60
({'APIFY_PROXY_SETTINGS' : {'useApifyProxy' : None }}, NotConfigured ),
61
61
({'APIFY_PROXY_SETTINGS' : {'useApifyProxy' : False }}, NotConfigured ),
62
62
],
63
+ ids = [
64
+ 'valid_proxy_settings_enabled' ,
65
+ 'valid_proxy_settings_with_groups' ,
66
+ 'no_settings' ,
67
+ 'irrelevant_setting' ,
68
+ 'empty_proxy_settings' ,
69
+ 'use_apify_proxy_none' ,
70
+ 'use_apify_proxy_false' ,
71
+ ],
63
72
)
64
- def test__from_crawler (
73
+ def test_middleware_initialization_from_crawler (
65
74
crawler : Crawler ,
66
75
monkeypatch : pytest .MonkeyPatch ,
67
76
settings : dict ,
@@ -81,8 +90,9 @@ def test__from_crawler(
81
90
@pytest .mark .parametrize (
82
91
'expected_proxy_url' ,
83
92
['http://username:[email protected] :8080' , 'http://hsdfgds:[email protected] :5748' ],
93
+ ids = ['example_proxy' , 'apify_proxy' ],
84
94
)
85
- async def test__get_new_proxy_url (
95
+ async def test_middleware_retrieves_new_proxy_url (
86
96
monkeypatch : pytest .MonkeyPatch ,
87
97
middleware : ApifyHttpProxyMiddleware ,
88
98
proxy_configuration : ProxyConfiguration ,
@@ -104,8 +114,9 @@ async def mock_new_url() -> str:
104
114
('http://user123:[email protected] :5748' , None , b'Basic dXNlcjEyMzpwYXNzNDU2' ),
105
115
('http://@proxy.example.com:2943' , ValueError , b'' ),
106
116
],
117
+ ids = ['valid_example_proxy' , 'valid_apify_proxy' , 'invalid_proxy_missing_credentials' ],
107
118
)
108
- async def test__process_request (
119
+ async def test_middleware_process_request_with_proxy (
109
120
monkeypatch : pytest .MonkeyPatch ,
110
121
middleware : ApifyHttpProxyMiddleware ,
111
122
spider : DummySpider ,
@@ -131,8 +142,9 @@ async def mock_get_new_proxy_url() -> ParseResult:
131
142
@pytest .mark .parametrize (
132
143
'exception' ,
133
144
[TunnelError (), ValueError ()],
145
+ ids = ['tunnel_error' , 'value_error' ],
134
146
)
135
- def test__process_exception (
147
+ def test_middleware_handles_exceptions (
136
148
middleware : ApifyHttpProxyMiddleware ,
137
149
spider : DummySpider ,
138
150
dummy_request : Request ,
0 commit comments