Skip to content

Mock HTTP Request, cover alternative routes #137

Open
@MiklerGM

Description

@MiklerGM

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)

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions