def test_for_object(self): out = templates.ld_for_object(self.person) self.assertEqual( out, self.script({ '@context': 'http://schema.org', '@id': 'http://localhost/alex-citizen/', '@type': 'Person', 'birthDate': '1970-01-01', 'description': '', 'image': image_ld(self.image, base_url='http://localhost'), # tested separately 'name': 'Alex Citizen', 'organisation': { '@id': 'http://localhost', '@type': '@id', }, 'url': 'http://localhost/alex-citizen/', }))
def test_ld_for_object_named(self): context = {'item': self.person} out = self.render_for_object_named(context) self.assertEqual(out, templates.ld_for_object(self.person))
def test_ld_for_object_implicit(self): context = {'page': self.person} out = self.render_for_object_implicit(context) self.assertEqual(out, templates.ld_for_object(self.person))
def ld_for_object(context, obj=None): if obj is None: obj = context["page"] return templates.ld_for_object(obj)