summaryrefslogtreecommitdiffstats
path: root/tests/test_extensions/test_dc.py
blob: af7dd94d1b34d2122edd2d2744ac6dfa58fe0cf8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import unittest

from feedgen.feed import FeedGenerator


class TestExtensionDc(unittest.TestCase):

    def setUp(self):
        self.fg = FeedGenerator()
        self.fg.load_extension('dc')
        self.fg.title('title')
        self.fg.link(href='http://example.com', rel='self')
        self.fg.description('description')

    def test_entryLoadExtension(self):
        fe = self.fg.add_item()
        try:
            fe.load_extension('dc')
        except ImportError:
            pass  # Extension already loaded

    def test_elements(self):
        for method in dir(self.fg.dc):
            if method.startswith('dc_'):
                m = getattr(self.fg.dc, method)
                m(method)
                self.assertEqual(m(), [method])

        self.fg.id('123')
        self.assertTrue(self.fg.atom_str())
        self.assertTrue(self.fg.rss_str())