Skip to content

Commit

Permalink
Default feed author name to the name specified in the config file
Browse files Browse the repository at this point in the history
  • Loading branch information
rubys committed Sep 7, 2006
1 parent 7b13eec commit e02f572
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
5 changes: 4 additions & 1 deletion planet/reconstitute.py
Expand Up @@ -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)

Expand Down
15 changes: 9 additions & 6 deletions tests/test_spider.py
Expand Up @@ -45,6 +45,7 @@ def test_spiderFeed(self):
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))
Expand All @@ -54,12 +55,10 @@ def test_spiderFeed(self):
'/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')
Expand All @@ -79,3 +78,7 @@ def test_spiderPlanet(self):
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)

0 comments on commit e02f572

Please sign in to comment.