コード例 #1
0
ファイル: tests.py プロジェクト: jvanasco/opengraph_writer
 def test_set_and_set_many(self):
     a = OpenGraphItem()
     a.set('og:title', 'MyWebsite')
     a.set('og:type', 'article')
     a.set_many((
         ('og:url', 'http://f.me'),
         ('og:image', 'http://f.me/a.png'),
         ('article:author', 'abc'),
         ('article:published_time', '2012-01-10')
     ))
コード例 #2
0
ファイル: tests.py プロジェクト: jvanasco/opengraph_writer
 def test_validate_fail(self):
     a = OpenGraphItem()
     a.set('og:title', 'MyWebsite')
     # missing og_type, which is required
     a.set_many((
         ('og:url', 'http://f.me'),
         ('og:image', 'http://f.me/a.png'),
         ('article:author', 'abc'),
         ('article:published_timre', '2012-01-10')
     ))
     status = a.validate()
     assert status is False
コード例 #3
0
ファイル: tests.py プロジェクト: jvanasco/opengraph_writer
 def test_validate_pass(self):
     a = OpenGraphItem()
     a.set('og:title', 'MyWebsite')
     a.set('og:type', 'article')
     a.set_many((
         ('og:url', 'http://f.me'),
         ('og:image', 'http://f.me/a.png'),
         ('article:author', 'abc'),
         ('article:published_time', '2012-01-10')
     ))
     status = a.validate()
     assert status is True
コード例 #4
0
ファイル: tests.py プロジェクト: jvanasco/opengraph_writer
 def test_set_multi(self):
     a = OpenGraphItem()
     a.set_many((
         ('og:url', 'http://f.me'),
         ('og:image', 'http://f.me/a.png'),
         ('og:title', 'MyWebsite'),
         ('og:type', 'article'),
     ))
     a.set('og:tag', 'One', append=True)
     a.set('og:tag', 'Two', append=True)
     a.set('og:tag', 'Three', append=True)
     status = a.validate()
     assert status is True
     as_html = a.as_html()
     assert as_html == """<meta property="og:image" content="http://f.me/a.png"/>
コード例 #5
0
ファイル: tests.py プロジェクト: jvanasco/opengraph_writer
 def test_html(self):
     a = OpenGraphItem()
     a.set('og:title', 'MyWebsite')
     a.set('og:type', 'article')
     a.set('og:description', 'one two three four ? <open >close')
     a.set_many((
         ('og:url', 'http://f.me'),
         ('og:image', 'http://f.me/a.png'),
         ('article:author', 'abc'),
         ('article:published_time', '2012-01-10')
     ))
     status = a.validate()
     assert status is True
     as_html = a.as_html()
     assert as_html == """<meta property="article:author" content="abc"/>
コード例 #6
0
ファイル: tests.py プロジェクト: jvanasco/opengraph_writer
 def test_set(self):
     a = OpenGraphItem()
     a.set('og:title', 'MyWebsite')
     a.set('og:type', 'article')