예제 #1
0
 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/',
         }))
예제 #2
0
 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))
예제 #3
0
 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))
예제 #4
0
def ld_for_object(context, obj=None):
    if obj is None:
        obj = context["page"]
    return templates.ld_for_object(obj)