Default feed author name to the name specified in the config file

This commit is contained in:
Sam Ruby 2006-09-07 17:56:32 -04:00
parent 7b13eece4d
commit e02f57233a
2 changed files with 13 additions and 7 deletions

View File

@ -160,7 +160,10 @@ def source(xsource, source, bozo):
createTextElement(xsource, 'icon', source.get('icon', None))
createTextElement(xsource, 'logo', source.get('logo', None))
author(xsource, 'author', source.get('author_detail',None))
author_detail = source.get('author_detail',{})
if not author_detail.has_key('name') and source.has_key('planet_name'):
author_detail['name'] = source['planet_name']
author(xsource, 'author', author_detail)
for contributor in source.get('contributors',[]):
author(xsource, 'contributor', contributor)

View File

@ -45,6 +45,7 @@ class SpiderTest(unittest.TestCase):
config.load(configfile)
spiderFeed(testfeed % '1b')
files = glob.glob(workdir+"/*")
files.sort()
# verify that exactly four files + one sources dir were produced
self.assertEqual(5, len(files))
@ -54,12 +55,10 @@ class SpiderTest(unittest.TestCase):
'/planet.intertwingly.net,2006,testfeed1,1' in files)
# verify that the file timestamps match atom:updated
for file in files:
if file.endswith('/sources'): continue
data = feedparser.parse(file)
self.assertTrue(data.entries[0].source.planet_name)
self.assertEqual(os.stat(file).st_mtime,
calendar.timegm(data.entries[0].updated_parsed))
data = feedparser.parse(files[2])
self.assertEqual('one', data.entries[0].source.planet_name)
self.assertEqual(os.stat(files[2]).st_mtime,
calendar.timegm(data.entries[0].updated_parsed))
def test_spiderUpdate(self):
spiderFeed(testfeed % '1a')
@ -79,3 +78,7 @@ class SpiderTest(unittest.TestCase):
self.assertTrue(workdir +
'/planet.intertwingly.net,2006,testfeed2,1' in files)
data = feedparser.parse(workdir +
'/planet.intertwingly.net,2006,testfeed3,1')
self.assertEqual('three', data.entries[0].source.author_detail.name)