Esempio n. 1
0
    def test_entry_multiple_same_authors(self):
        entry = EntryFactory()
        author = AuthorFactory()
        author2 = AuthorFactory()
        entry.add_authors([author, author2])
        entry.save()
        self.assertEqual(len(entry.authors), 2)

        entry.add_authors(author)
        entry.save()
        self.assertEqual(len(entry.authors), 2)
Esempio n. 2
0
    def test_entry_create_author_string_unicode(self):
        entry = EntryFactory()
        author = AuthorFactory()
        entry.authors.append(author)

        authorstring = entry.create_author_string()

        self.assertEqual(authorstring, author.name)

        author2 = AuthorFactory(name=u"Tĕstá ĀũʈĥőŘ")
        entry.authors.append(author2)

        authorstring = entry.create_author_string()

        self.assertEqual(authorstring, u'{0}, {1}'.format(author.name,
                                                          author2.name))
Esempio n. 3
0
    def test_entry_create_author_string(self):
        entry = EntryFactory()
        author = AuthorFactory()
        entry.authors.append(author)

        authorstring = entry.create_author_string()

        self.assertEqual(authorstring, author.name)

        author2 = AuthorFactory()
        entry.authors.append(author2)

        authorstring = entry.create_author_string()

        self.assertEqual(authorstring, '{0}, {1}'.format(author.name,
                                                         author2.name))
Esempio n. 4
0
    def test_entry_wordcount(self):
        entry = EntryFactory()

        with open(TEST_FILES_DIR + 'rss.xml') as f:
            raw = f.read()

        d = feedparser.parse(raw)

        entry.content = d.entries[0].summary
        entry.get_wordcount()

        self.assertEqual(entry.wordcount, 263)

        entry.content = d.entries[5].summary
        entry.get_wordcount()

        self.assertEqual(entry.wordcount, 675)