Scenario 3:
Testing the endpoint with years with no editors by country data
Hint: From 2017 and earlier years there is not data for editors by country. Data began in the year 2018
Prod:
import requests prod_url = 'https://wikimedia.org/api/rest_v1/metrics/editors/by-country/en.wikipedia/en.wikipedia/5..99-edits/2000/06' header = {"accept": "application/json", "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"} response = requests.get(prod_url, headers=header) print(response.status_code) print(response.json())
This returns status code 404 and json response:
{'type': 'https://mediawiki.org/wiki/HyperSwitch/errors/not_found#route', 'title': 'Not found.', 'method': 'get', 'uri': '/wikimedia.org/v1/metrics/editors/by-country/en.wikipedia/en.wikipedia/5..99-edits/2000/06'}
Local:
This returns wrong status code 400 and wrong jsonn response:
Traceback (most recent call last): File "/Users/emekachukwukere/PycharmProjects/pythonProject1/venv/lib/python3.9/site-packages/requests/models.py", line 971, in json return complexjson.loads(self.text, **kwargs) File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/json/__init__.py", line 346, in loads return _default_decoder.decode(s) File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Users/emekachukwukere/PycharmProjects/pythonProject1/editors/test_local_editors_by_country.py", line 14, in <module> print(response.json()) File "/Users/emekachukwukere/PycharmProjects/pythonProject1/venv/lib/python3.9/site-packages/requests/models.py", line 975, in json raise RequestsJSONDecodeError(e.msg, e.doc, e.pos) requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)