File: test_config.py

package info (click to toggle)
planet-venus 0~git9de2109-4.2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 3,884 kB
  • sloc: python: 4,393; xml: 871; makefile: 39; sed: 3; sh: 2
file content (71 lines) | stat: -rw-r--r-- 2,164 bytes parent folder | download | duplicates (2)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env python

import unittest
from planet import config

class ConfigTest(unittest.TestCase):
    def setUp(self):
        config.load('tests/data/config/basic.ini')

    # administrivia

    def test_template(self):
        self.assertEqual(['index.html.tmpl', 'atom.xml.tmpl'], 
            config.template_files())

    def test_feeds(self):
        feeds = config.subscriptions()
        feeds.sort()
        self.assertEqual(['feed1', 'feed2'], feeds)

    def test_feed(self):
        self.assertEqual('http://example.com/atom.xml', config.feed())
        self.assertEqual('atom', config.feedtype())

    # planet wide configuration

    def test_name(self):
        self.assertEqual('Test Configuration', config.name())

    def test_link(self):
        self.assertEqual('http://example.com/', config.link())

    def test_pubsubhubbub_hub(self):
        self.assertEqual('http://pubsubhubbub.appspot.com', config.pubsubhubbub_hub())

    # per template configuration

    def test_days_per_page(self):
        self.assertEqual(7, config.days_per_page('index.html.tmpl'))
        self.assertEqual(0, config.days_per_page('atom.xml.tmpl'))

    def test_items_per_page(self):
        self.assertEqual(50, config.items_per_page('index.html.tmpl'))
        self.assertEqual(50, config.items_per_page('atom.xml.tmpl'))

    def test_encoding(self):
        self.assertEqual('utf-8', config.encoding('index.html.tmpl'))
        self.assertEqual('utf-8', config.encoding('atom.xml.tmpl'))

    # dictionaries

    def test_feed_options(self):
        self.assertEqual('one', config.feed_options('feed1')['name'])
        self.assertEqual('two', config.feed_options('feed2')['name'])

    def test_template_options(self):
        option = config.template_options('index.html.tmpl')
        self.assertEqual('7',  option['days_per_page'])
        self.assertEqual('50', option['items_per_page'])

    def test_filters(self):
        self.assertEqual(['foo','bar'], config.filters('feed2'))
        self.assertEqual(['foo'], config.filters('feed1'))

    # ints

    def test_timeout(self):
        self.assertEqual(30,
            config.feed_timeout())