コード例 #1
0
    def test_handle_notification(self):
        with open(TEST_FILES_DIR + 'rss.xml') as f:
            raw = f.read()

        feed = FeedFactory()
        db.session.commit()

        entryhandler = EntryHandler()
        try:
            data = entryhandler.parse_rss_data(raw)
            entryhandler.handle_notification(feed, data)
        except Exception as e:
            self.fail(e)

        self.assertEqual(feed.title, 'David Beath')
        self.assertEqual(len(feed.entries), 10)
        self.assertEqual(feed.entries[0].title, 'Express.js 4.0 BasicAuth')
        self.assertEqual(feed.entries[0].authors[0].name, 'David Beath')
        self.assertEqual(feed.entries[0].wordcount, 263)

        author = Author.query.filter_by(name='David Beath').first()
        self.assertEqual(author.name, 'David Beath')

        self.assertEqual(len(entryhandler.entries), 10)
        self.assertEqual(len(entryhandler.authors), 1)
コード例 #2
0
    def test_notification_adds_rss_entry(self):
        with open(TEST_FILES_DIR + 'rss.xml') as f:
            raw = f.read()

        feed = FeedFactory()

        entryhandler = EntryHandler()
        data = entryhandler.parse_rss_data(raw)
        entryhandler.handle_notification(feed, data)

        entryCount = Entry.query.count()
        self.assertEqual(entryCount, 10)
        guid = 'https://davidbeath.com/posts/expressjs-40-basicauth.html'
        entry1 = Entry.query.filter_by(guid=guid).first()
        self.assertEqual(entry1.link, guid)
        self.assertEqual(entry1.title, "Express.js 4.0 BasicAuth")
        self.assertIsNotNone(entry1.published)
        self.assertEqual(entry1.authors[0].name, 'David Beath')

        self.assertEqual(feed.title, 'David Beath')