Provide user agent string when downloading data#25
Provide user agent string when downloading data#25xrotwang merged 4 commits intoconcepticon:masterfrom
Conversation
|
Re trying stdlib first: I can only imagine that I tried to get rid of the |
|
Okay, I may be stupid. (<_<)" It should have been side_effect instead of sideeffect. The tests work now. (In my defence, the function should have thrown an invalid keyword argument error (<_<)" .) Also, I replaced the download implementation with a stdlib one. So, pynorare has one dependency less now (no changes to setup.cfg though because requests was pulled in as a transitive dependency). And I un-hardcoded the version number in the user agent string. This PR should be good to go now. |
|
Oh right, I keep forgetting that I don't have write access here – someone else has to do the actual merge (and probably release as well – at least I think that's what we did last time iirc). |
|
Just invited you. |
Okay, @MiraAhmedovic reported a case where downloading a data set failed because the server required the request to provide a user agent string (Seems like it doesn't care what the user agent is as long as it gets one).
I just set the user agent to
norare/1.1.0. Seemed resonable enough to me.However, this PR is still incomplete. Fixing the code itself took me only a few minutes if at all but then I got stuck for over an hour trying to get the tests to work. I can't for the life of me figure out how to get
pytestto run my mock implementation of the download function.pynorare/tests/test_cli.py
Lines 40 to 44 in 23d1778
norare downloadseems to succeed and assert_called_once passes, so the function seems to run. But thennorare mapfails because the placeholder file isn't actually there… So, something seems to eat the side effects or something?@xrotwang @LinguList Also, do you remember the reason why the old code tries download the data using the stdlib and then falls back to requests? Are there ever any cases where those yield different results?