Scenario 5:
Testing the endpoint with years with invalid year
Prod:
import requests prod_url = 'https://wikimedia.org/api/rest_v1/metrics/editors/by-country/en.wikipedia/100..-edits/wrong/12' 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 gives a status of 400 and the json response below:
{'type': 'https://mediawiki.org/wiki/HyperSwitch/errors/invalid_request', 'method': 'get', 'detail': ['Given year/month is invalid date'], 'uri': '/analytics.wikimedia.org/v1/editors/by-country/en.wikipedia/100..-edits/wrong/12'}
Local :
This gives 400 status and the json exception:
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)