def test_fetch_license(self):
""" Fetch a license from the URL found in the status doc, then validates it """
try:
license = next((l for l in self.lsd['links'] if l['rel'] == 'license'))
except StopIteration as err:
raise TestSuiteRunningError(
"Missing a 'license' link in the status document")
license_url = license['href']
LOGGER.debug("Fetch license at url %s:", license_url)
# fetch the license
r = requests.get(license_url)
try:
self.lcpl = r.json()
except ValueError as err:
LOGGER.debug(r.text)
raise TestSuiteRunningError("Malformed JSON License Document")
LOGGER.debug("The License is available")
# validate the license
lcpl_json_schema_path = os.path.join(
JSON_SCHEMA_DIR_PATH, 'lcpl_schema.json')
with open(lcpl_json_schema_path) as schema_file:
lcpl_json_schema = json.loads(schema_file.read())
try:
jsonschema.validate(self.lcpl, lcpl_json_schema, format_checker=jsonschema.FormatChecker())
except jsonschema.ValidationError as err:
raise TestSuiteRunningError(err)
LOGGER.debug("The up to date License is available and valid")
# display some license values
LOGGER.info("date issued {}, updated {}".format(
self.lcpl['issued'], self.lcpl['updated'] if "updated" in self.lcpl else "never"))
LOGGER.info("rights print {}, copy {}".format(
self.lcpl['rights']['print'], self.lcpl['rights']['copy']))
LOGGER.info("rights start {}, end {}".format(
self.lcpl['rights']['start'] if "start" in self.lcpl['rights'] else "none",
self.lcpl['rights']['end'] if "end" in self.lcpl['rights'] else "none"))
评论列表
文章目录