source: trunk/moap/test/test_commands_doap.py @ 230

Revision 230, 2.8 KB checked in by thomas, 6 years ago (diff)
  • moap/command/doap.py (Rss.do): break into two lines
  • moap/doap/rss.py (doapsToRss, createdToPubDate, cheetah_toRss): Make the two template language's output as similar as possible.
  • moap/test/Makefile.am:
  • moap/test/rss/mach.rss.cheetah:
  • moap/test/rss/mach.rss.genshi: Add two rss feeds based on the two templating languages.
  • moap/test/test_commands_doap.py (TestDoapMach?.setUp, TestDoapMach?.testRssGenshi, TestDoapMach?.testRssCheetah): Add tests for the specific template languages. Coverage: 72 % ( 844 / 1157)
Line 
1# -*- Mode: Python; test-case-name: moap.test.test_commands_doap -*-
2# vi:si:et:sw=4:sts=4:ts=4
3
4import os
5import StringIO
6
7from moap.test import common
8
9from moap.util import log
10
11from moap.command import doap
12
13class TestDoapMach(common.TestCase):
14    def setUp(self):
15        self.doap = os.path.join(os.path.dirname(__file__), 'doap',
16            'mach.doap')
17        self.ical = os.path.join(os.path.dirname(__file__), 'ical',
18            'mach.ical')
19        self.grss = os.path.join(os.path.dirname(__file__), 'rss',
20            'mach.rss.genshi')
21        self.crss = os.path.join(os.path.dirname(__file__), 'rss',
22            'mach.rss.cheetah')
23        self.stdout = StringIO.StringIO()
24        self.command = doap.Doap(stdout=self.stdout)
25
26    def testIcal(self):
27        ret = self.command.parse(['-f', self.doap, 'ical'])
28        ref = open(self.ical).read()
29        self.assertEquals(self.stdout.getvalue(), ref)
30
31    def testRssGenshi(self):
32        ret = self.command.parse(['-f', self.doap, 'rss'])
33        ref = open(self.grss).read()
34        self.assertEquals(self.stdout.getvalue(), ref)
35
36    def testRssCheetah(self):
37        ret = self.command.parse(['-f', self.doap, 'rss', '-t', 'cheetah'])
38        ref = open(self.crss).read()
39        self.assertEquals(self.stdout.getvalue(), ref)
40
41    def testShow(self):
42        ret = self.command.parse(['-f', self.doap, 'show'])
43        ref = u"""DOAP file:         %s
44project:           Mach
45short description: mach makes chroots
46created:           2002-06-06
47homepage:          http://thomas.apestaart.org/projects/mach/
48bug database:      https://apestaart.org/thomas/trac/newticket
49download page:     http://thomas.apestaart.org/projects/mach/
50Latest release:    version 0.9.0 'Cambria' on branch 2.
51""" % self.doap
52        self.assertEquals(self.stdout.getvalue(), ref)
53
54class TestDoapUnspecified(common.TestCase):
55    # we don't specify the doap file, let doap find it on its own
56    def setUp(self):
57        self._cwd = os.getcwd()
58        doapdir = os.path.join(os.path.dirname(__file__), 'doap')
59        os.chdir(doapdir)
60        self.stdout = StringIO.StringIO()
61        self.command = doap.Doap(stdout=self.stdout)
62
63    def testShow(self):
64        doap = os.path.join(os.path.dirname(__file__), 'doap',
65            'mach.doap')
66        ret = self.command.parse(['show'])
67        ref = u"""DOAP file:         %s
68project:           Mach
69short description: mach makes chroots
70created:           2002-06-06
71homepage:          http://thomas.apestaart.org/projects/mach/
72bug database:      https://apestaart.org/thomas/trac/newticket
73download page:     http://thomas.apestaart.org/projects/mach/
74Latest release:    version 0.9.0 'Cambria' on branch 2.
75""" % doap
76        self.assertEquals(self.stdout.getvalue(), ref)
77
78    def tearDown(self):
79        os.chdir(self._cwd)
Note: See TracBrowser for help on using the repository browser.