| 1 | # -*- Mode: Python; test-case-name: moap.test.test_commands_doap -*- |
|---|
| 2 | # vi:si:et:sw=4:sts=4:ts=4 |
|---|
| 3 | |
|---|
| 4 | import os |
|---|
| 5 | import StringIO |
|---|
| 6 | |
|---|
| 7 | from moap.test import common |
|---|
| 8 | |
|---|
| 9 | from moap.util import log |
|---|
| 10 | |
|---|
| 11 | from moap.command import doap |
|---|
| 12 | |
|---|
| 13 | class 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 |
|---|
| 44 | project: Mach |
|---|
| 45 | short description: mach makes chroots |
|---|
| 46 | created: 2002-06-06 |
|---|
| 47 | homepage: http://thomas.apestaart.org/projects/mach/ |
|---|
| 48 | bug database: https://apestaart.org/thomas/trac/newticket |
|---|
| 49 | download page: http://thomas.apestaart.org/projects/mach/ |
|---|
| 50 | Latest release: version 0.9.0 'Cambria' on branch 2. |
|---|
| 51 | """ % self.doap |
|---|
| 52 | self.assertEquals(self.stdout.getvalue(), ref) |
|---|
| 53 | |
|---|
| 54 | class 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 |
|---|
| 68 | project: Mach |
|---|
| 69 | short description: mach makes chroots |
|---|
| 70 | created: 2002-06-06 |
|---|
| 71 | homepage: http://thomas.apestaart.org/projects/mach/ |
|---|
| 72 | bug database: https://apestaart.org/thomas/trac/newticket |
|---|
| 73 | download page: http://thomas.apestaart.org/projects/mach/ |
|---|
| 74 | Latest 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) |
|---|