Example #1
0
 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)
Example #2
0
 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)
Example #3
0
    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)
Example #4
0
    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)
Example #5
0
    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>''')
Example #6
0
 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>'
     )
Example #7
0
 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>'
     )
Example #8
0
 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>'
     )
Example #9
0
 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)
Example #10
0
    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>'''
        )
Example #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)
Example #12
0
 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))
Example #13
0
 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)
Example #14
0
 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)
Example #15
0
 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)
Example #16
0
 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>')
Example #17
0
 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))
Example #18
0
 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))
Example #19
0
 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'))
Example #20
0
 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>')
Example #21
0
 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'))
Example #22
0
 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)
Example #23
0
 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)
Example #24
0
 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'))
Example #25
0
 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)
Example #26
0
 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)
Example #27
0
 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)
Example #28
0
 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)
Example #29
0
 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)    
Example #30
0
 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>')
Example #31
0
 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>')
Example #32
0
 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))
Example #33
0
 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)
Example #34
0
 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>')
Example #35
0
 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)
Example #36
0
 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'))
Example #37
0
 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)
Example #38
0
 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>')
Example #39
0
 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)
Example #40
0
 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)
Example #41
0
 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>')
Example #42
0
 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)
Example #43
0
 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)