File: test_rlists.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 (49 lines) | stat: -rw-r--r-- 1,477 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/env python

import unittest, os, shutil
from planet import config, opml
from os.path import split
from glob import glob
from ConfigParser import ConfigParser

workdir = os.path.join('tests', 'work', 'config', 'cache')

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

    def tearDown(self):
        shutil.rmtree(workdir)
        os.removedirs(os.path.split(workdir)[0])

    # administrivia

    def test_feeds(self):
        feeds = [split(feed)[1] for feed in config.subscriptions()]
        feeds.sort()
        self.assertEqual(['testfeed0.atom', 'testfeed1a.atom',
            'testfeed2.atom', 'testfeed3.rss'], feeds)

    # dictionaries

    def test_feed_options(self):
        feeds = dict([(split(feed)[1],feed) for feed in config.subscriptions()])
        feed1 = feeds['testfeed1a.atom']
        self.assertEqual('one', config.feed_options(feed1)['name'])

        feed2 = feeds['testfeed2.atom']
        self.assertEqual('two', config.feed_options(feed2)['name'])

    # dictionaries

    def test_cache(self):
        cache = glob(os.path.join(workdir,'lists','*'))
        self.assertEqual(1,len(cache))

        parser = ConfigParser()
        parser.read(cache[0])

        feeds = [split(feed)[1] for feed in parser.sections()]
        feeds.sort()
        self.assertEqual(['opml.xml', 'testfeed0.atom', 'testfeed1a.atom',
            'testfeed2.atom', 'testfeed3.rss'], feeds)