summaryrefslogtreecommitdiffstats
path: root/tests/test_extensions/test_syndication.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel@debian.org>2024-12-12 12:17:53 +0100
committerDaniel Baumann <daniel@debian.org>2024-12-12 12:17:53 +0100
commit11cb8088832071b55bba2aff046d1542dda46fed (patch)
treed3f24cca0040ee5587df8c9e10371d05f206f94a /tests/test_extensions/test_syndication.py
parentInitial commit. (diff)
downloadpython-feedgen-11cb8088832071b55bba2aff046d1542dda46fed.tar.xz
python-feedgen-11cb8088832071b55bba2aff046d1542dda46fed.zip
Adding upstream version 1.0.0.upstream/1.0.0upstream
Signed-off-by: Daniel Baumann <daniel@debian.org>
Diffstat (limited to 'tests/test_extensions/test_syndication.py')
-rw-r--r--tests/test_extensions/test_syndication.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/test_extensions/test_syndication.py b/tests/test_extensions/test_syndication.py
new file mode 100644
index 0000000..029e100
--- /dev/null
+++ b/tests/test_extensions/test_syndication.py
@@ -0,0 +1,40 @@
+import unittest
+
+from lxml import etree
+
+from feedgen.feed import FeedGenerator
+
+
+class TestExtensionSyndication(unittest.TestCase):
+
+ SYN_NS = {'sy': 'http://purl.org/rss/1.0/modules/syndication/'}
+
+ def setUp(self):
+ self.fg = FeedGenerator()
+ self.fg.load_extension('syndication')
+ self.fg.title('title')
+ self.fg.link(href='http://example.com', rel='self')
+ self.fg.description('description')
+
+ def test_update_period(self):
+ for period_type in ('hourly', 'daily', 'weekly', 'monthly', 'yearly'):
+ self.fg.syndication.update_period(period_type)
+ root = etree.fromstring(self.fg.rss_str())
+ a = root.xpath('/rss/channel/sy:UpdatePeriod',
+ namespaces=self.SYN_NS)
+ self.assertEqual(a[0].text, period_type)
+
+ def test_update_frequency(self):
+ for frequency in (1, 100, 2000, 100000):
+ self.fg.syndication.update_frequency(frequency)
+ root = etree.fromstring(self.fg.rss_str())
+ a = root.xpath('/rss/channel/sy:UpdateFrequency',
+ namespaces=self.SYN_NS)
+ self.assertEqual(a[0].text, str(frequency))
+
+ def test_update_base(self):
+ base = '2000-01-01T12:00+00:00'
+ self.fg.syndication.update_base(base)
+ root = etree.fromstring(self.fg.rss_str())
+ a = root.xpath('/rss/channel/sy:UpdateBase', namespaces=self.SYN_NS)
+ self.assertEqual(a[0].text, base)