def test_landing_page_is_missing_jsonld(self): """ SCENARIO: A landing page does not have a JSON-LD <SCRIPT> element. EXPECTED RESULT: A SkipError is raised. Many CUAHSI documents don't have JSON-LD, and we don't want that counting against the failure count. """ package = 'tests.data.cuahsi.81e947faccf04de59392dddaac77bc75' contents = ir.read_text(package, 'landing_page.no_json_ld.html') doc = lxml.etree.HTML(contents) obj = CUAHSIHarvester() with self.assertLogs(logger=obj.logger, level='DEBUG'): with self.assertRaises(JsonLdError): obj.get_jsonld(doc)
def test_landing_page_jsonld(self): """ SCENARIO: A landing page does have a JSON-LD <SCRIPT> element. EXPECTED RESULT: The JSON-LD is loaded. """ package = 'tests.data.cuahsi.81e947faccf04de59392dddaac77bc75' contents = ir.read_text(package, 'landing_page.html') doc = lxml.etree.HTML(contents) obj = CUAHSIHarvester() with self.assertLogs(logger=obj.logger, level='DEBUG'): j = obj.get_jsonld(doc) # To make sure we have JSON, feed it to something that expects it. json.dumps(j)