X-Git-Url: https://gerrit.onap.org/r/gitweb?p=vvp%2Fvalidation-scripts.git;a=blobdiff_plain;f=ice_validator%2Ftests%2Fconftest.py;h=8650c69ea5ddfb5215602db0fb665c71b654eab3;hp=a08b99adfc1dec681ada477ad7395f538017bbfe;hb=5fe6216becd1d0451d356569de24fd68d49d9982;hpb=60d5ad7d00eadd6395eca186e6fa76a43df3c6cf diff --git a/ice_validator/tests/conftest.py b/ice_validator/tests/conftest.py index a08b99a..8650c69 100644 --- a/ice_validator/tests/conftest.py +++ b/ice_validator/tests/conftest.py @@ -46,6 +46,7 @@ import sys import time import requests import traceback +import warnings import docutils.core import jinja2 @@ -593,10 +594,18 @@ def load_current_requirements(): """Loads dict of current requirements or empty dict if file doesn't exist""" url = 'https://onap.readthedocs.io/en/latest/_downloads/needs.json' - r = requests.get(url) - with open('requirements.json', 'wb') as needs: - needs.write(r.content) - path = "heat_requirements.json" + + try: + r = requests.get(url) + if r.headers.get('content-type') == 'application/json': + with open('requirements.json', 'wb') as needs: + needs.write(r.content) + else: + warnings.warning("Unexpected content-type ({}) encountered downloading requirements.json, using last saved copy".format(r.headers.get('content-type'))) + except requests.exceptions.RequestException as e: + warnings.warn("Error downloading latest JSON, using last saved copy.") + warnings.warn(UserWarning(e)) + path = "requirements.json" if not os.path.exists(path): return {} with io.open(path, encoding="utf8", mode="r") as f: