From e02f57233af00b41cd03b6bc694e0179ead5cabd Mon Sep 17 00:00:00 2001 From: Sam Ruby Date: Thu, 7 Sep 2006 17:56:32 -0400 Subject: [PATCH] Default feed author name to the name specified in the config file --- planet/reconstitute.py | 5 ++++- tests/test_spider.py | 15 +++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/planet/reconstitute.py b/planet/reconstitute.py index 361a6b4..92ba3da 100644 --- a/planet/reconstitute.py +++ b/planet/reconstitute.py @@ -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) diff --git a/tests/test_spider.py b/tests/test_spider.py index e3e2061..9f819d6 100644 --- a/tests/test_spider.py +++ b/tests/test_spider.py @@ -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) +