Exemple #1
0
 def test_html_content_and_summary(self):
     for expected_content, expected_summary, value in (('my html', 'my val',
                                                        {
                                                            'value':
                                                            'my val',
                                                            'html':
                                                            'my html'
                                                        }),
                                                       ('my html', None, {
                                                           'html': 'my html'
                                                       }), ('my val',
                                                            'my val', {
                                                                'value':
                                                                'my val'
                                                            }), ('my str',
                                                                 'my str',
                                                                 'my str'),
                                                       (None, None, {})):
         obj = microformats2.json_to_object(
             {'properties': {
                 'content': value,
                 'summary': value
             }})
         self.assertEquals(expected_content, obj.get('content'))
         self.assertEquals(expected_summary, obj.get('summary'))
  def test_properties_override_h_as_article(self):
    for prop, verb in (('like', 'like'),
                       ('like-of', 'like'),
                       ('repost', 'share'),
                       ('repost-of', 'share')):
      obj = microformats2.json_to_object(
        {'type': ['h-entry', 'h-as-note'],
          'properties': {prop: ['http://foo/bar']}})
      self.assertEquals('activity', obj['objectType'])
      self.assertEquals(verb, obj['verb'])

    obj = microformats2.json_to_object(
      {'type': ['h-entry', 'h-as-article'],
       'properties': {'rsvp': ['no']}})
    self.assertEquals('activity', obj['objectType'])
    self.assertEquals('rsvp-no', obj['verb'])
Exemple #3
0
 def test_photo_property_is_not_url(self):
     """handle the case where someone (incorrectly) marks up the caption
 with p-photo
 """
     mf2 = {
         'properties': {
             'photo': ['the caption', 'http://example.com/image.jpg']
         }
     }
     obj = microformats2.json_to_object(mf2)
     self.assertEquals('http://example.com/image.jpg', obj['image']['url'])
Exemple #4
0
    def test_properties_override_h_as_article(self):
        for prop, verb in (('like', 'like'), ('like-of', 'like'),
                           ('repost', 'share'), ('repost-of', 'share')):
            obj = microformats2.json_to_object({
                'type': ['h-entry', 'h-as-note'],
                'properties': {
                    prop: ['http://foo/bar']
                }
            })
            self.assertEquals('activity', obj['objectType'])
            self.assertEquals(verb, obj['verb'])

        obj = microformats2.json_to_object({
            'type': ['h-entry', 'h-as-article'],
            'properties': {
                'rsvp': ['no']
            }
        })
        self.assertEquals('activity', obj['objectType'])
        self.assertEquals('rsvp-no', obj['verb'])
Exemple #5
0
 def test_photo_property_has_no_url(self):
     """handle the case where the photo property is *only* text, not a url"""
     mf2 = {'properties': {'photo': ['the caption', 'alternate text']}}
     obj = microformats2.json_to_object(mf2)
     self.assertFalse(obj.get('image'))
Exemple #6
0
 def test_h_as_article(self):
     obj = microformats2.json_to_object(
         {'type': ['h-entry', 'h-as-article']})
     self.assertEquals('article', obj['objectType'])
 def test_h_as_article(self):
   obj = microformats2.json_to_object({'type': ['h-entry', 'h-as-article']})
   self.assertEquals('article', obj['objectType'])