-
Notifications
You must be signed in to change notification settings - Fork 636
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proxies can be sent as a string #300
Changes from 7 commits
392ed80
5b4582a
ca18e9b
06f60fe
0b180e5
bd18569
e63a625
7da916c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,3 +76,21 @@ def test_ssl_context_with_proxy_is_respected(self): | |
geocoder_dummy.geocode(self.remote_website_https) | ||
self.assertIn('SSL', str(cm.exception)) | ||
self.assertEqual(1, len(self.proxy_server.requests)) | ||
|
||
def test_geocoder_constructor_uses_str_proxy(self): | ||
base_http = urlopen(self.remote_website_http, timeout=self.timeout) | ||
base_html = base_http.read() | ||
geocoder_dummy = DummyGeocoder(proxies=self.proxy_url, scheme='http', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, I don't think we need to test two schemes in two almost identical integration tests, which aren't cheap with regards to time. It would be better to keep the previous single test, and add a new unit test here. Something like this:
That should be enough. We already tested that the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure if I get this right, but this will assert error:
So I added 2 DummyGeocoders to check if both schemes are respected. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have you by chance missed this comment? #300 (comment) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also it would've been better if it was in a separate There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh yeah, I did miss this comment, pardon my inattention. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any reason to set the |
||
timeout=self.timeout) | ||
print(geocoder_dummy.scheme, geocoder_dummy.proxies, 'proxy') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🙃 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. whoops 😅 |
||
self.assertEqual(0, len(self.proxy_server.requests)) | ||
self.assertEqual( | ||
base_html, | ||
geocoder_dummy.geocode(self.remote_website_http) | ||
) | ||
self.assertEqual(1, len(self.proxy_server.requests)) | ||
|
||
def test_geocoder_constructor_have_both_schemes_proxy(self): | ||
g = DummyGeocoder(proxies=self.proxy_url, scheme='http') | ||
self.assertDictEqual(g.proxies, {'http': self.proxy_url, | ||
'https': self.proxy_url}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be honest, I don't like it 🤔. But I'm not ready to propose a better phrasing for now as well.
Let's just keep it, but I'll get to this later after merging.