-
- self = <Response [400]>
-
- def raise_for_status(self):
- """Raises stored :class:`HTTPError`, if one occurred."""
-
- http_error_msg = ''
- if isinstance(self.reason, bytes):
- # We attempt to decode utf-8 first because some servers
- # choose to localize their reason strings. If the string
- # isn't utf-8, we fall back to iso-8859-1 for all other
- # encodings. (See PR #3538)
- try:
- reason = self.reason.decode('utf-8')
- except UnicodeDecodeError:
- reason = self.reason.decode('iso-8859-1')
- else:
- reason = self.reason
-
- if 400 <= self.status_code < 500:
- http_error_msg = u'%s Client Error: %s for url: %s' % (self.status_code, reason, self.url)
-
- elif 500 <= self.status_code < 600:
- http_error_msg = u'%s Server Error: %s for url: %s' % (self.status_code, reason, self.url)
-
- if http_error_msg:
- > raise HTTPError(http_error_msg, response=self)
- E requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://cdn.optimizely.com/public/12122523685/s/12236426447_production.json
-
- ../../../.local/share/virtualenvs/docs_validation-uieTOkAZ/lib/python3.7/site-packages/requests/models.py:940: HTTPError
-
- During handling of the above exception, another exception occurred:
-
- settings = {'accountId': 12122523685, 'audience_id_ab_test': 0, 'audience_id_feature_test': 0, 'custom_audience_attribute_ab_test': '', ...}
-
- def test_getting_datafile_via_cdn(settings):
- url = f'https://cdn.optimizely.com/public/{settings["accountId"]}/s' \
- f'/{settings["project_id"]}_production.json'
-
- > cdn_datafile = getrequest(url, build_headers(settings)).text
-
- tests/fs_tests/test_setup.py:38:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
-
- url = 'https://cdn.optimizely.com/public/12122523685/s/12236426447_production.json'
- header = {'Authorization': 'Bearer 2:wPVNqmq8GGJahiU1KscsHalhl9CU30y8-WBMpPI4X4KiuNu7To9A', 'user-agent': 'application/json'}
-
- def getrequest(url, header):
- """
- Returns <requests> object.
- So it can be applied to any format in the client function (text, json,...).
- """
- import sys
- settings = load_settings()
- try:
- r = requests.get(url, headers=header)
- r.raise_for_status()
- return r
- except requests.exceptions.RequestException as e:
- print(e)
- > sys.exit(1)
- E SystemExit: 1
-
- helper_functions/helpers.py:54: SystemExit
- ==================================================================== 1 failed, 22 deselected in 0.58 seconds =====================================================================
-