コード例 #1
0
ファイル: testxoxo.py プロジェクト: microformats/xoxo
 def testAttentionRoundTrip(self):
     '''check nested <a> and <dl> and <a> are preserved'''
     kmattn='''<ol class="xoxo"><li><a href="http://www.boingboing.net/" title="Boing Boing Blog" >Boing Boing Blog</a><dl><dt>alturls</dt><dd><ol><li><a href="http://boingboing.net/rss.xml" >xmlurl</a></li></ol></dd><dt>description</dt><dd>Boing Boing Blog</dd></dl></li><li><a href="http://www.financialcryptography.com/" title="Financial Cryptography" >Financial Cryptography</a><dl><dt>alturls</dt><dd><ol><li><a href="http://www.financialcryptography.com/mt/index.rdf" >xmlurl</a></li></ol></dd><dt>description</dt><dd>Financial Cryptography</dd></dl></li><li><a href="http://hublog.hubmed.org/" title="HubLog" >HubLog</a><dl><dt>alturls</dt><dd><ol><li><a href="http://hublog.hubmed.org/index.xml" >xmlurl</a></li><li><a href="http://hublog.hubmed.org/foaf.rdf" >foafurl</a></li></ol></dd><dt>description</dt><dd>HubLog</dd></dl></li></ol>''';
     d = xoxo.fromXOXO(kmattn)
     newattn = xoxo.toXOXO(d)
     d2 = xoxo.fromXOXO(newattn)
     self.assertEqual(newattn,xoxo.toXOXO(d2))
     self.assertEqual(d,d2)
     self.assertEqual(kmattn,newattn)
コード例 #2
0
ファイル: testxoxo.py プロジェクト: yyolk/xoxo
 def testAttentionRoundTrip(self):
     '''check nested <a> and <dl> and <a> are preserved'''
     kmattn = '''<ol class="xoxo"><li><a href="http://www.boingboing.net/" title="Boing Boing Blog" >Boing Boing Blog</a><dl><dt>alturls</dt><dd><ol><li><a href="http://boingboing.net/rss.xml" >xmlurl</a></li></ol></dd><dt>description</dt><dd>Boing Boing Blog</dd></dl></li><li><a href="http://www.financialcryptography.com/" title="Financial Cryptography" >Financial Cryptography</a><dl><dt>alturls</dt><dd><ol><li><a href="http://www.financialcryptography.com/mt/index.rdf" >xmlurl</a></li></ol></dd><dt>description</dt><dd>Financial Cryptography</dd></dl></li><li><a href="http://hublog.hubmed.org/" title="HubLog" >HubLog</a><dl><dt>alturls</dt><dd><ol><li><a href="http://hublog.hubmed.org/index.xml" >xmlurl</a></li><li><a href="http://hublog.hubmed.org/foaf.rdf" >foafurl</a></li></ol></dd><dt>description</dt><dd>HubLog</dd></dl></li></ol>'''
     d = xoxo.fromXOXO(kmattn)
     newattn = xoxo.toXOXO(d)
     d2 = xoxo.fromXOXO(newattn)
     self.assertEqual(newattn, xoxo.toXOXO(d2))
     self.assertEqual(d, d2)
     self.assertEqual(kmattn, newattn)
コード例 #3
0
ファイル: testxoxo.py プロジェクト: yyolk/xoxo
    def testXOXOWithSpacesAndNewlines(self):
        '''unmung some xoxo with spaces in and check result is right'''
        xoxoSample = '''<ol class='xoxo'> 
  <li>
    <dl>
        <dt>text</dt>
        <dd>item 1</dd>
        <dt>description</dt>
        <dd> This item represents the main point we're trying to make.</dd>
        <dt>url</dt>
        <dd>http://example.com/more.xoxo</dd>
        <dt>title</dt>
        <dd>title of item 1</dd>
        <dt>type</dt>
        <dd>text/xml</dd>
        <dt>rel</dt>
        <dd>help</dd>
    </dl>
  </li>
</ol>'''
        d = xoxo.fromXOXO(xoxoSample)
        d2 = {
            'text': 'item 1',
            'description':
            " This item represents the main point we're trying to make.",
            'url': 'http://example.com/more.xoxo',
            'title': 'title of item 1',
            'type': 'text/xml',
            'rel': 'help'
        }
        xoxoAgain = xoxo.toXOXO(d)
        self.assertEqual(d, d2)
コード例 #4
0
ファイル: testxoxo.py プロジェクト: microformats/xoxo
    def testXOXOWithSpacesAndNewlines(self):
        '''unmung some xoxo with spaces in and check result is right'''
        xoxoSample= '''<ol class='xoxo'> 
  <li>
    <dl>
        <dt>text</dt>
        <dd>item 1</dd>
        <dt>description</dt>
        <dd> This item represents the main point we're trying to make.</dd>
        <dt>url</dt>
        <dd>http://example.com/more.xoxo</dd>
        <dt>title</dt>
        <dd>title of item 1</dd>
        <dt>type</dt>
        <dd>text/xml</dd>
        <dt>rel</dt>
        <dd>help</dd>
    </dl>
  </li>
</ol>'''
        d = xoxo.fromXOXO(xoxoSample)
        d2={'text':'item 1',
            'description':" This item represents the main point we're trying to make.",
            'url':'http://example.com/more.xoxo',
            'title':'title of item 1',
            'type':'text/xml',
            'rel':'help'
            }
        xoxoAgain = xoxo.toXOXO(d)
        self.assertEqual(d,d2)
コード例 #5
0
ファイル: testxoxo.py プロジェクト: microformats/xoxo
    def testWrapItemWithCSS(self):
        '''make a wrapped xoxo file from a string'''
        l = "test"
        html = xoxo.toXOXO(l,addHTMLWrapper=True,cssUrl='reaptest.css')
        self.assertEqual(html,'''<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head profile=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><style type="text/css" >@import "reaptest.css";</style></head><body><ol class="xoxo"><li>test</li></ol></body></html>''')
コード例 #6
0
ファイル: testxoxo.py プロジェクト: yyolk/xoxo
 def testNestedList(self):
     '''make a xoxo file from a list with a list in'''
     l = ['1', ['2', '3']]
     html = xoxo.toXOXO(l)
     self.assertEqual(
         html,
         '<ol class="xoxo"><li>1</li><li><ol><li>2</li><li>3</li></ol></li></ol>'
     )
コード例 #7
0
ファイル: testxoxo.py プロジェクト: yyolk/xoxo
 def testDictionary(self):
     '''make a xoxo file from a dictionary'''
     d = {'test': '1', 'name': 'Kevin'}
     html = xoxo.toXOXO(d)
     self.assertEqual(
         html,
         '<ol class="xoxo"><li><dl><dt>test</dt><dd>1</dd><dt>name</dt><dd>Kevin</dd></dl></li></ol>'
     )
コード例 #8
0
ファイル: testxoxo.py プロジェクト: yyolk/xoxo
 def testUrlList(self):
     '''handle the mf2 case where url is a list'''
     d = {'url': ['http://example.com/']}
     html = xoxo.toXOXO(d)
     self.assertEqual(
         html,
         '<ol class="xoxo"><li><dl><dt>url</dt><dd><ol><li>http://example.com/</li></ol></dd></dl></li></ol>'
     )
コード例 #9
0
ファイル: testxoxo.py プロジェクト: microformats/xoxo
 def testDictofListsRoundTrip(self):
     ''' make a dict with lists in into a xoxo file and back again; check it is the same'''
     d = {'test':['1','2'],
     'name':'Kevin',
     'nestlist':['a',['b','c']],
     'nestdict':{'e':'6','f':'7'}}
     html = xoxo.toXOXO(d)
     newd = xoxo.fromXOXO(html)
     self.assertEqual(d,newd)
コード例 #10
0
ファイル: testxoxo.py プロジェクト: yyolk/xoxo
    def testWrapItemWithCSS(self):
        '''make a wrapped xoxo file from a string'''
        l = "test"
        html = xoxo.toXOXO(l, addHTMLWrapper=True, cssUrl='reaptest.css')
        self.assertEqual(
            html,
            '''<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head profile=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><style type="text/css" >@import "reaptest.css";</style></head><body><ol class="xoxo"><li>test</li></ol></body></html>'''
        )
コード例 #11
0
 def get(self):
     url = fixurl(self.request.get('url'))
     values={"url":url}
     result = urlfetch.fetch(url)
     if result.status_code == 200:
         data= json.loads(result.content)
         html= xoxo.toXOXO(data,True,'/styles/hfeed.css')
     else:
         html= "Error %i %s" % (result.status_code,result.content)
     self.response.write(html)
コード例 #12
0
ファイル: testxoxo.py プロジェクト: yyolk/xoxo
 def testSpecialAttributeRoundTripNoText(self):
     '''check it makes an <a href with a url parameter and no text attribute'''
     d = {
         'url': 'http://example.com/more.xoxo',
         'title': 'sample url',
         'type': "text/xml",
         'rel': 'help'
     }
     html = xoxo.toXOXO(d)
     self.assertEqual(d, xoxo.fromXOXO(html))
コード例 #13
0
ファイル: testxoxo.py プロジェクト: yyolk/xoxo
 def testSpecialAttributeEncode(self):
     '''check it makes an <a href with a url parameter'''
     d = {
         'url': 'http://example.com/more.xoxo',
         'title': 'sample url',
         'type': "text/xml",
         'rel': 'help',
         'text': 'an example'
     }
     html = xoxo.toXOXO(d)
     expectedHTML = '<ol class="xoxo"><li><a href="http://example.com/more.xoxo" title="sample url" rel="help" type="text/xml" >an example</a></li></ol>'
     self.assertEqual(html, expectedHTML)
コード例 #14
0
ファイル: testxoxo.py プロジェクト: yyolk/xoxo
 def testNestedDictionariesWithURLsRoundTrip(self):
     ''' make a dictionary with an url and a dict with an url into a xoxo file and back again; check it is the same'''
     d = {
         'url': 'http://example.com',
         'inner': {
             'name': 'Kevin',
             'url': 'http://slashdot.org'
         }
     }
     html = xoxo.toXOXO(d)
     newd = xoxo.fromXOXO(html)
     self.assertEqual(d, newd)
コード例 #15
0
ファイル: testxoxo.py プロジェクト: yyolk/xoxo
 def testDictofListsRoundTrip(self):
     ''' make a dict with lists in into a xoxo file and back again; check it is the same'''
     d = {
         'test': ['1', '2'],
         'name': 'Kevin',
         'nestlist': ['a', ['b', 'c']],
         'nestdict': {
             'e': '6',
             'f': '7'
         }
     }
     html = xoxo.toXOXO(d)
     newd = xoxo.fromXOXO(html)
     self.assertEqual(d, newd)
コード例 #16
0
ファイル: testxoxo.py プロジェクト: microformats/xoxo
 def testSingleItem(self):
     '''make a xoxo file from a string'''
     l = "test"
     html = xoxo.toXOXO(l)
     self.assertEqual(html,'<ol class="xoxo"><li>test</li></ol>')
コード例 #17
0
ファイル: testxoxo.py プロジェクト: microformats/xoxo
 def testSpecialAttributeRoundTripNoTextOrTitle(self):
     '''check it makes an <a href with a url parameter and no text or title attribute'''
     d={'url':'http://example.com/more.xoxo'}
     html=xoxo.toXOXO(d)
     self.assertEqual(d,xoxo.fromXOXO(html))
コード例 #18
0
ファイル: testxoxo.py プロジェクト: microformats/xoxo
 def testSpecialAttributeRoundTripNoText(self):
     '''check it makes an <a href with a url parameter and no text attribute'''
     d={'url':'http://example.com/more.xoxo','title':'sample url','type':"text/xml",'rel':'help'}
     html=xoxo.toXOXO(d)
     self.assertEqual(d,xoxo.fromXOXO(html))
コード例 #19
0
ファイル: testxoxo.py プロジェクト: microformats/xoxo
 def testWindows1252Roundtrip(self):
     '''check 1252 characters can go to xoxo and back'''
     src='This is an evil\xa0space'
     html = xoxo.toXOXO(src)
     self.assertEqual(src,xoxo.fromXOXO(html).encode('windows-1252'))
コード例 #20
0
ファイル: testxoxo.py プロジェクト: yyolk/xoxo
 def testSimpleList(self):
     '''make a xoxo file from a list'''
     l = ['1', '2', '3']
     html = xoxo.toXOXO(l)
     self.assertEqual(
         html, '<ol class="xoxo"><li>1</li><li>2</li><li>3</li></ol>')
コード例 #21
0
ファイル: testxoxo.py プロジェクト: microformats/xoxo
 def testUtf8Roundtrip(self):
     '''check utf8 characters can go to xoxo and back'''
     src='Tantek \xc3\x87elik and a snowman \xe2\x98\x83'
     html = xoxo.toXOXO(src)
     self.assertEqual(src,xoxo.fromXOXO(html).encode('utf-8'))
コード例 #22
0
ファイル: testxoxo.py プロジェクト: yyolk/xoxo
 def testWrapDiffers(self):
     '''make a xoxo file from a string with and without html wrapper and check they are different'''
     l = "test"
     html = xoxo.toXOXO(l)
     htmlwrap = xoxo.toXOXO(l, addHTMLWrapper=True)
     self.failIfEqual(html, htmlwrap)
コード例 #23
0
ファイル: testxoxo.py プロジェクト: microformats/xoxo
 def testSpecialAttributeEncode(self):
     '''check it makes an <a href with a url parameter'''
     d={'url':'http://example.com/more.xoxo','title':'sample url','type':"text/xml",'rel':'help','text':'an example'}
     html=xoxo.toXOXO(d)
     expectedHTML= '<ol class="xoxo"><li><a href="http://example.com/more.xoxo" title="sample url" rel="help" type="text/xml" >an example</a></li></ol>' 
     self.assertEqual(html,expectedHTML)
コード例 #24
0
ファイル: testxoxo.py プロジェクト: yyolk/xoxo
 def testUtf8Roundtrip(self):
     '''check utf8 characters can go to xoxo and back'''
     src = 'Tantek \xc3\x87elik and a snowman \xe2\x98\x83'
     html = xoxo.toXOXO(src)
     self.assertEqual(src, xoxo.fromXOXO(html).encode('utf-8'))
コード例 #25
0
ファイル: testxoxo.py プロジェクト: yyolk/xoxo
 def testDictionaryWithURLRoundTrip(self):
     ''' make a dictionary wiht an url in into a xoxo file and back again; check it is the same'''
     d = {'url': 'http://example.com', 'name': 'Kevin'}
     html = xoxo.toXOXO(d)
     newd = xoxo.fromXOXO(html)
     self.assertEqual(d, newd)
コード例 #26
0
ファイル: testxoxo.py プロジェクト: microformats/xoxo
 def testListofListsRoundTrip(self):
     ''' make a list of Lists into a xoxo file and back again; check it is the same'''
     l = ['3',['a','2'],['b',['1',['c','4']]]]
     html = xoxo.toXOXO(l)
     newdl= xoxo.fromXOXO(html)
     self.assertEqual(l,newdl)
コード例 #27
0
ファイル: testxoxo.py プロジェクト: microformats/xoxo
 def testNestedDictionariesWithURLsRoundTrip(self):
     ''' make a dictionary with an url and a dict with an url into a xoxo file and back again; check it is the same'''
     d = {'url':'http://example.com','inner':{'name':'Kevin','url':'http://slashdot.org'}}
     html = xoxo.toXOXO(d)
     newd = xoxo.fromXOXO(html)
     self.assertEqual(d,newd)
コード例 #28
0
ファイル: testxoxo.py プロジェクト: microformats/xoxo
 def testNestedDictionaryRoundTrip(self):
     ''' make a dictionary with a dict in into a xoxo file and back again; check it is the same'''
     d = {'test':'1','inner':{'name':'Kevin'}}
     html = xoxo.toXOXO(d)
     newd = xoxo.fromXOXO(html)
     self.assertEqual(d,newd)
コード例 #29
0
ファイル: testxoxo.py プロジェクト: microformats/xoxo
 def testDictionaryWithURLRoundTrip(self):
     ''' make a dictionary wiht an url in into a xoxo file and back again; check it is the same'''
     d = {'url':'http://example.com','name':'Kevin'}
     html = xoxo.toXOXO(d)
     newd = xoxo.fromXOXO(html)
     self.assertEqual(d,newd)    
コード例 #30
0
ファイル: testxoxo.py プロジェクト: microformats/xoxo
 def testUrlList(self):
     '''handle the mf2 case where url is a list'''
     d={'url':['http://example.com/']}
     html = xoxo.toXOXO(d)
     self.assertEqual(html,'<ol class="xoxo"><li><dl><dt>url</dt><dd><ol><li>http://example.com/</li></ol></dd></dl></li></ol>')
コード例 #31
0
ファイル: testxoxo.py プロジェクト: microformats/xoxo
 def testSimpleList(self):
     '''make a xoxo file from a list'''
     l = ['1','2','3']
     html = xoxo.toXOXO(l)
     self.assertEqual(html,'<ol class="xoxo"><li>1</li><li>2</li><li>3</li></ol>')
コード例 #32
0
ファイル: testxoxo.py プロジェクト: yyolk/xoxo
 def testSpecialAttributeRoundTripNoTextOrTitle(self):
     '''check it makes an <a href with a url parameter and no text or title attribute'''
     d = {'url': 'http://example.com/more.xoxo'}
     html = xoxo.toXOXO(d)
     self.assertEqual(d, xoxo.fromXOXO(html))
コード例 #33
0
ファイル: testxoxo.py プロジェクト: microformats/xoxo
 def testWrapDiffers(self):
     '''make a xoxo file from a string with and without html wrapper and check they are different'''
     l = "test"
     html = xoxo.toXOXO(l)
     htmlwrap =  xoxo.toXOXO(l,addHTMLWrapper=True)
     self.failIfEqual(html,htmlwrap)
コード例 #34
0
ファイル: testxoxo.py プロジェクト: microformats/xoxo
 def testNestedList(self):
     '''make a xoxo file from a list with a list in'''
     l = ['1',['2','3']]
     html = xoxo.toXOXO(l)
     self.assertEqual(html,'<ol class="xoxo"><li>1</li><li><ol><li>2</li><li>3</li></ol></li></ol>')
コード例 #35
0
ファイル: testxoxo.py プロジェクト: yyolk/xoxo
 def testListRoundTrip(self):
     ''' make a list into a xoxo file and back again; check it is the same'''
     l = ['3', '2', '1']
     html = xoxo.toXOXO(l)
     newdl = xoxo.fromXOXO(html)
     self.assertEqual(l, newdl)
コード例 #36
0
ファイル: testxoxo.py プロジェクト: yyolk/xoxo
 def testWindows1252Roundtrip(self):
     '''check 1252 characters can go to xoxo and back'''
     src = 'This is an evil\xa0space'
     html = xoxo.toXOXO(src)
     self.assertEqual(src, xoxo.fromXOXO(html).encode('windows-1252'))
コード例 #37
0
ファイル: testxoxo.py プロジェクト: yyolk/xoxo
 def testListofDictsRoundTrip(self):
     ''' make a list of Dicts into a xoxo file and back again; check it is the same'''
     l = ['3', {'a': '2'}, {'b': '1', 'c': '4'}]
     html = xoxo.toXOXO(l)
     newdl = xoxo.fromXOXO(html)
     self.assertEqual(l, newdl)
コード例 #38
0
ファイル: testxoxo.py プロジェクト: yyolk/xoxo
 def testSingleItem(self):
     '''make a xoxo file from a string'''
     l = "test"
     html = xoxo.toXOXO(l)
     self.assertEqual(html, '<ol class="xoxo"><li>test</li></ol>')
コード例 #39
0
ファイル: testxoxo.py プロジェクト: yyolk/xoxo
 def testListofListsRoundTrip(self):
     ''' make a list of Lists into a xoxo file and back again; check it is the same'''
     l = ['3', ['a', '2'], ['b', ['1', ['c', '4']]]]
     html = xoxo.toXOXO(l)
     newdl = xoxo.fromXOXO(html)
     self.assertEqual(l, newdl)
コード例 #40
0
ファイル: testxoxo.py プロジェクト: microformats/xoxo
 def testListRoundTrip(self):
     ''' make a list into a xoxo file and back again; check it is the same'''
     l = ['3','2','1']
     html = xoxo.toXOXO(l)
     newdl= xoxo.fromXOXO(html)
     self.assertEqual(l,newdl)
コード例 #41
0
ファイル: testxoxo.py プロジェクト: microformats/xoxo
 def testDictionary(self):
     '''make a xoxo file from a dictionary'''
     d = {'test':'1','name':'Kevin'}
     html = xoxo.toXOXO(d)
     self.assertEqual(html,'<ol class="xoxo"><li><dl><dt>test</dt><dd>1</dd><dt>name</dt><dd>Kevin</dd></dl></li></ol>')
コード例 #42
0
ファイル: testxoxo.py プロジェクト: yyolk/xoxo
 def testNestedDictionaryRoundTrip(self):
     ''' make a dictionary with a dict in into a xoxo file and back again; check it is the same'''
     d = {'test': '1', 'inner': {'name': 'Kevin'}}
     html = xoxo.toXOXO(d)
     newd = xoxo.fromXOXO(html)
     self.assertEqual(d, newd)
コード例 #43
0
ファイル: testxoxo.py プロジェクト: microformats/xoxo
 def testListofDictsRoundTrip(self):
     ''' make a list of Dicts into a xoxo file and back again; check it is the same'''
     l = ['3',{'a':'2'},{'b':'1','c':'4'}]
     html = xoxo.toXOXO(l)
     newdl= xoxo.fromXOXO(html)
     self.assertEqual(l,newdl)