コード例 #1
0
ファイル: test_splice.py プロジェクト: AlexxNica/planet-web
 def test_splice_new_feed_items(self):
     config.load(configfile)
     config.parser.set('Planet', 'new_feed_items', '3')
     doc = splice()
     self.assertEqual(9, len(doc.getElementsByTagName('entry')))
     self.assertEqual(4, len(doc.getElementsByTagName('planet:source')))
     self.assertEqual(13, len(doc.getElementsByTagName('planet:name')))
コード例 #2
0
 def test_splice_new_feed_items(self):
     config.load(configfile)
     config.parser.set('Planet','new_feed_items','3')
     doc = splice()
     self.assertEqual(9,len(doc.getElementsByTagName('entry')))
     self.assertEqual(4,len(doc.getElementsByTagName('planet:source')))
     self.assertEqual(13,len(doc.getElementsByTagName('planet:name')))
コード例 #3
0
ファイル: test_splice.py プロジェクト: AlexxNica/planet-web
 def test_splice_unsub(self):
     config.load(configfile)
     config.parser.remove_section('tests/data/spider/testfeed2.atom')
     doc = splice()
     self.assertEqual(8, len(doc.getElementsByTagName('entry')))
     self.assertEqual(3, len(doc.getElementsByTagName('planet:source')))
     self.assertEqual(11, len(doc.getElementsByTagName('planet:name')))
コード例 #4
0
 def test_splice_unsub(self):
     config.load(configfile)
     config.parser.remove_section('tests/data/spider/testfeed2.atom')
     doc = splice()
     self.assertEqual(8,len(doc.getElementsByTagName('entry')))
     self.assertEqual(3,len(doc.getElementsByTagName('planet:source')))
     self.assertEqual(11,len(doc.getElementsByTagName('planet:name')))
コード例 #5
0
 def test_embedded_license(self):
     config.load(configfile)
     for testfeed in testfeeds:
         doc = splice.splice()
         splice.apply(doc.toxml('utf-8'))
     output = open(os.path.join(workdir, 'index.html')).read()
     self.assertTrue('Attribution 3.0 Unported' in output)
コード例 #6
0
 def test_invalid_default_license(self):
     config.load(configfile)
     for testfeed in testfeeds:
         doc = splice.splice()
         splice.apply(doc.toxml('utf-8'))
     output = open(os.path.join(workdir, 'index.html')).read()
     self.assertTrue('title="License information">License</a>' in output)
コード例 #7
0
    def test_splice(self):
        config.load(configfile)
        doc = splice()
        self.assertEqual(12,len(doc.getElementsByTagName('entry')))
        self.assertEqual(4,len(doc.getElementsByTagName('planet:source')))
        self.assertEqual(16,len(doc.getElementsByTagName('planet:name')))

        self.assertEqual('test planet',
            doc.getElementsByTagName('title')[0].firstChild.nodeValue)
コード例 #8
0
 def test_default_license_lookup(self):
     config.load(configfile)
     expected_text = 'Reconocimiento-No comercial-Compartir bajo la' + \
         ' misma licencia 2.5 Colombia'
     for testfeed in testfeeds:
         doc = splice.splice()
         splice.apply(doc.toxml('utf-8'))
     output = open(os.path.join(workdir, 'index.html')).read()
     self.assertTrue(expected_text in output)
コード例 #9
0
ファイル: test_splice.py プロジェクト: AlexxNica/planet-web
    def test_splice(self):
        config.load(configfile)
        doc = splice()
        self.assertEqual(12, len(doc.getElementsByTagName('entry')))
        self.assertEqual(4, len(doc.getElementsByTagName('planet:source')))
        self.assertEqual(16, len(doc.getElementsByTagName('planet:name')))

        self.assertEqual(
            'test planet',
            doc.getElementsByTagName('title')[0].firstChild.nodeValue)
コード例 #10
0
    def test_index_splice(self):
        import test_splice
        config.load(test_splice.configfile)
        index = idindex.create()

        self.assertEqual(12, len(index))
        self.assertEqual('tag:planet.intertwingly.net,2006:testfeed1', index['planet.intertwingly.net,2006,testfeed1,1'])
        self.assertEqual('http://intertwingly.net/code/venus/tests/data/spider/testfeed3.rss', index['planet.intertwingly.net,2006,testfeed3,1'])

        for key in index.keys():
            value = index[key]
            if value.find('testfeed2')>0: index[key] = value.swapcase()
        index.close()

        from planet.splice import splice
        doc = splice()

        self.assertEqual(8,len(doc.getElementsByTagName('entry')))
        self.assertEqual(4,len(doc.getElementsByTagName('planet:source')))
        self.assertEqual(12,len(doc.getElementsByTagName('planet:name')))
コード例 #11
0
    def test_index_splice(self):
        import test_splice
        config.load(test_splice.configfile)
        index = idindex.create()

        self.assertEqual(12, len(index))
        self.assertEqual('tag:planet.intertwingly.net,2006:testfeed1',
                         index['planet.intertwingly.net,2006,testfeed1,1'])
        self.assertEqual(
            'http://intertwingly.net/code/venus/tests/data/spider/testfeed3.rss',
            index['planet.intertwingly.net,2006,testfeed3,1'])

        for key in index.keys():
            value = index[key]
            if value.find('testfeed2') > 0: index[key] = value.swapcase()
        index.close()

        from planet.splice import splice
        doc = splice()

        self.assertEqual(8, len(doc.getElementsByTagName('entry')))
        self.assertEqual(4, len(doc.getElementsByTagName('planet:source')))
        self.assertEqual(12, len(doc.getElementsByTagName('planet:name')))
コード例 #12
0
    import feedparser
    for source in glob.glob(os.path.join(work, 'sources/*')):
        feed = feedparser.parse(source).feed
        if feed.has_key('title'):
            config.parser.set('Planet','name',feed.title_detail.value)
        if feed.has_key('link'):
            config.parser.set('Planet','link',feed.link)
        if feed.has_key('author_detail'):
            if feed.author_detail.has_key('name'):
                config.parser.set('Planet','owner_name',feed.author_detail.name)
            if feed.author_detail.has_key('email'):
                config.parser.set('Planet','owner_email',feed.author_detail.email)

    from planet import splice
    doc = splice.splice()

    sources = doc.getElementsByTagName('planet:source')
    if hide_planet_ns and len(sources) == 1:
        source = sources[0]
        feed = source.parentNode
        child = feed.firstChild
        while child:
            next = child.nextSibling
            if child.nodeName not in ['planet:source','entry']:
                feed.removeChild(child)
            child = next
        while source.hasChildNodes():
            child = source.firstChild
            source.removeChild(child)
            feed.insertBefore(child, source)
コード例 #13
0
ファイル: capture.py プロジェクト: 3rdandUrban-dev/Nuxleus
source=open('tests/data/spider/config.ini')
dest1=open('tests/data/splice/config.ini', 'w')
dest1.write(source.read().replace('/work/spider/', '/data/splice/'))
dest1.close()

source.seek(0)
dest2=open('tests/work/apply_config.ini', 'w')
dest2.write(source.read().replace('[Planet]', '''[Planet]
output_theme = asf
output_dir = tests/work/apply'''))
dest2.close()
source.close()

# copy splice output to apply input
from planet import splice
file=open('tests/data/apply/feed.xml', 'w')
config.load('tests/data/splice/config.ini')
data=splice.splice().toxml('utf-8')
file.write(data)
file.close()

# copy apply output to config/reading-list input
config.load('tests/work/apply_config.ini')
splice.apply(data)
shutil.move('tests/work/apply/opml.xml', 'tests/data/config')

shutil.rmtree('tests/work')

import runtests
コード例 #14
0
ファイル: planet.py プロジェクト: aviarypl/venus
    from planet import config
    config.load(config_file or 'config.ini')

    if verbose:
        import planet
        planet.getLogger('DEBUG', config.log_format())

    if not offline:
        from planet import spider
        try:
            spider.spiderPlanet(only_if_new=only_if_new)
        except Exception, e:
            print e

    from planet import splice
    doc = splice.splice()

    if debug_splice:
        from planet import logger
        logger.info('writing debug.atom')
        debug = open('debug.atom', 'w')
        try:
            from lxml import etree
            from StringIO import StringIO
            tree = etree.tostring(etree.parse(StringIO(doc.toxml())))
            debug.write(etree.tostring(tree, pretty_print=True))
        except:
            debug.write(doc.toprettyxml(indent='  ', encoding='utf-8'))
        debug.close

    splice.apply(doc.toxml('utf-8'))
コード例 #15
0
dest1 = open('tests/data/splice/config.ini', 'w')
dest1.write(source.read().replace('/work/spider/', '/data/splice/'))
dest1.close()

source.seek(0)
dest2 = open('tests/work/apply_config.ini', 'w')
dest2.write(source.read().replace(
    '[Planet]', '''[Planet]
output_theme = asf
output_dir = tests/work/apply'''))
dest2.close()
source.close()

# copy splice output to apply input
from planet import splice

file = open('tests/data/apply/feed.xml', 'w')
config.load('tests/data/splice/config.ini')
data = splice.splice().toxml('utf-8')
file.write(data)
file.close()

# copy apply output to config/reading-list input
config.load('tests/work/apply_config.ini')
splice.apply(data)
shutil.move('tests/work/apply/opml.xml', 'tests/data/config')

shutil.rmtree('tests/work')

import runtests