Skip to content
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

Mock HTTP Request, cover alternative routes #137

Open
MiklerGM opened this issue Jun 26, 2019 · 2 comments
Open

Mock HTTP Request, cover alternative routes #137

MiklerGM opened this issue Jun 26, 2019 · 2 comments

Comments

@MiklerGM
Copy link
Contributor

Requests from django can be easily banned by wikidata.

https://github.com/chronhq/backend/blob/master/project/api/models.py#L160-L172

I would propose to mock requests.get in unit tests.
Additionally, I would recommend mimicking browser behavior by adding the user-agent header. Current UA is set to python-requests/2.21.0.
Wikidata can ban all users by UA or network.

I've got next error page from wikidata

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Error 403 You have been banned until 2019-06-26T17:35:05.645Z, please respect throttling and retry-after headers.</title>
</head>
<body><h2>HTTP ERROR 403</h2>
<p>Problem accessing /bigdata/namespace/wdq/sparql. Reason:
<pre>    You have been banned until 2019-06-26T17:35:05.645Z, please respect throttling and retry-after headers.</pre></p><hr><a href="http://eclipse.org/jetty">Powered by Jetty:// 9.4.12.v20180830</a><hr/>

</body>
</html>

Originally posted by @MiklerGM in #127 (comment)

MiklerGM added a commit that referenced this issue Jul 17, 2019
@MiklerGM
Copy link
Contributor Author

MiklerGM commented Jul 21, 2019

This probably should be separated and presented by several issues, but it does not really matter, so I would propose to

  • Mock HTTP requests for unit tests (done in Add Firebase auth and Profile model #112)
  • change User-Agent header for all requests
  • add coverage reports for tests (we have tests only for good conditions)
  • use different routine for integration tests with real requests

Cc @ataalik @whirish

@MiklerGM
Copy link
Contributor Author

As for integration test I would also propose to run the app, to prevent gunicorn20 problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants