def test_daily_to_rss_feed(self): daily = Daily(url='an url') daily_entry = DailyEntry(date='2015-12-28', type='reading', subject='a book about bonsai') daily.add_entry(daily_entry) daily_entry = DailyEntry(date='2015-12-30', type='studying', subject='a book about trees') daily_entry.add_reference(source='http://somewhere', type='source') daily_entry.add_reference(source='http://somewhere/blog.html', type='blog') daily.add_entry(daily_entry) expected_rss = '''<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"> <channel> <title>Daily Activity Log: an url</title> <link>an url</link> <description>RSS feed generated from: an url</description> <docs>http://www.rssboard.org/rss-specification</docs> <generator>python-feedgen</generator> <language>en</language> <item> <title>studying: a book about trees</title> <description><a href=\'http://somewhere\'>source</a><br/><a href=\'http://somewhere/blog.html\'>blog</a><br/></description> <pubDate>Wed, 30 Dec 2015 00:00:00 +0000</pubDate> </item> <item> <title>reading: a book about bonsai</title> <pubDate>Mon, 28 Dec 2015 00:00:00 +0000</pubDate> </item> </channel> </rss> ''' rss = daily_to_rss(daily) self.assertEqual(expected_rss, exclude_tag('lastBuildDate', rss))
def __daily_entry_from(self, event): action = event.find('action') entry = DailyEntry(date=event.attrib['date'], type=action.attrib['type'], subject=action.text) references = event.find('references') if references is not None: for reference in references: entry.add_reference(source=reference.attrib['src'], type=reference.attrib['type']) return entry
def test_when_daily_is_found_returns_rss(self): daily = Daily(url='an url') daily_entry = DailyEntry(date='2015-12-30', type='reading', subject='a book about trees') daily_entry.add_reference(source='http://somewhere', type='source') daily.add_entry(daily_entry) when(self.repository).find_by('an url').thenReturn(daily) status, message = self.action.execute('an url') self.assertEqual('ok', status) self.assertTrue(message.startswith("<rss "))
def full_daily(self): daily = Daily(url=AN_URL) first_entry = DailyEntry("2015-06-23", "trying", "My daily activity log") first_entry.add_reference("http://somewhere.internet/page.html", "source") second_entry = DailyEntry("2015-06-20", "reading", "A new book") second_entry.add_reference("http://somewhere.internet/page2.html", "source") second_entry.add_reference("http://somewhere.internet/page2.html", "other source") third_entry = DailyEntry("2015-06-18", "watching", "A movie") daily.add_entry(first_entry) daily.add_entry(second_entry) daily.add_entry(third_entry) return daily