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

Revision 228, 2.5 KB checked in by thomas, 6 years ago (diff)
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.rss = os.path.join(os.path.dirname(__file__), 'rss',
20            'mach.rss')
21        self.stdout = StringIO.StringIO()
22        self.command = doap.Doap(stdout=self.stdout)
23
24    def testIcal(self):
25        ret = self.command.parse(['-f', self.doap, 'ical'])
26        ref = open(self.ical).read()
27        self.assertEquals(self.stdout.getvalue(), ref)
28
29    def testRss(self):
30        ret = self.command.parse(['-f', self.doap, 'rss'])
31        ref = open(self.rss).read()
32        self.assertEquals(self.stdout.getvalue(), ref)
33
34    def testShow(self):
35        ret = self.command.parse(['-f', self.doap, 'show'])
36        ref = u"""DOAP file:         %s
37project:           Mach
38short description: mach makes chroots
39created:           2002-06-06
40homepage:          http://thomas.apestaart.org/projects/mach/
41bug database:      https://apestaart.org/thomas/trac/newticket
42download page:     http://thomas.apestaart.org/projects/mach/
43Latest release:    version 0.9.0 'Cambria' on branch 2.
44""" % self.doap
45        self.assertEquals(self.stdout.getvalue(), ref)
46
47class TestDoapUnspecified(common.TestCase):
48    # we don't specify the doap file, let doap find it on its own
49    def setUp(self):
50        self._cwd = os.getcwd()
51        doapdir = os.path.join(os.path.dirname(__file__), 'doap')
52        os.chdir(doapdir)
53        self.stdout = StringIO.StringIO()
54        self.command = doap.Doap(stdout=self.stdout)
55
56    def testShow(self):
57        doap = os.path.join(os.path.dirname(__file__), 'doap',
58            'mach.doap')
59        ret = self.command.parse(['show'])
60        ref = u"""DOAP file:         %s
61project:           Mach
62short description: mach makes chroots
63created:           2002-06-06
64homepage:          http://thomas.apestaart.org/projects/mach/
65bug database:      https://apestaart.org/thomas/trac/newticket
66download page:     http://thomas.apestaart.org/projects/mach/
67Latest release:    version 0.9.0 'Cambria' on branch 2.
68""" % doap
69        self.assertEquals(self.stdout.getvalue(), ref)
70
71    def tearDown(self):
72        os.chdir(self._cwd)
Note: See TracBrowser for help on using the repository browser.