Package moap :: Package test :: Module test_commands_doap
[hide private]
[frames] | no frames]

Source Code for Module moap.test.test_commands_doap

 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 twisted.trial import unittest 
 8   
 9  from moap.test import common 
10   
11  from moap.util import log 
12   
13  from moap.command import doap 
14   
15 -class TestDoapMach(common.TestCase):
16 - def setUp(self):
17 self.doap = os.path.join(os.path.dirname(__file__), 'doap', 18 'mach.doap') 19 self.ical = os.path.join(os.path.dirname(__file__), 'ical', 20 'mach.ics') 21 self.grss = os.path.join(os.path.dirname(__file__), 'rss', 22 'mach.rss.genshi') 23 self.crss = os.path.join(os.path.dirname(__file__), 'rss', 24 'mach.rss.cheetah') 25 self.stdout = StringIO.StringIO() 26 self.command = doap.Doap(stdout=self.stdout)
27
28 - def testIcal(self):
29 ret = self.command.parse(['-f', self.doap, 'ical']) 30 ref = open(self.ical).read() 31 self.assertEquals(self.stdout.getvalue(), ref)
32
33 - def testRssGenshi(self):
34 try: 35 import genshi 36 except ImportError: 37 raise unittest.SkipTest("No genshi module, skipping.") 38 39 ret = self.command.parse(['-f', self.doap, 'rss']) 40 ref = open(self.grss).read() 41 self.assertEquals(self.stdout.getvalue(), ref)
42
43 - def testRssCheetah(self):
44 try: 45 import Cheetah 46 except ImportError: 47 raise unittest.SkipTest("No Cheetah module, skipping.") 48 ret = self.command.parse(['-f', self.doap, 'rss', '-t', 'cheetah']) 49 ref = open(self.crss).read() 50 self.assertEquals(self.stdout.getvalue(), ref)
51
52 - def testShow(self):
53 ret = self.command.parse(['-f', self.doap, 'show']) 54 ref = u"""DOAP file: %s 55 project: Mach 56 short description: mach makes chroots 57 created: 2002-06-06 58 homepage: http://thomas.apestaart.org/projects/mach/ 59 bug database: https://apestaart.org/thomas/trac/newticket 60 download page: http://thomas.apestaart.org/projects/mach/ 61 Latest release: version 0.9.0 'Cambria' on branch 2. 62 """ % self.doap 63 self.assertEquals(self.stdout.getvalue(), ref)
64
65 -class TestDoapUnspecified(common.TestCase):
66 # we don't specify the doap file, let doap find it on its own
67 - def setUp(self):
68 self._cwd = os.getcwd() 69 doapdir = os.path.join(os.path.dirname(__file__), 'doap') 70 os.chdir(doapdir) 71 self.stdout = StringIO.StringIO() 72 self.command = doap.Doap(stdout=self.stdout)
73
74 - def testShow(self):
75 doap = os.path.join(os.path.dirname(__file__), 'doap', 76 'mach.doap') 77 ret = self.command.parse(['show']) 78 ref = u"""DOAP file: %s 79 project: Mach 80 short description: mach makes chroots 81 created: 2002-06-06 82 homepage: http://thomas.apestaart.org/projects/mach/ 83 bug database: https://apestaart.org/thomas/trac/newticket 84 download page: http://thomas.apestaart.org/projects/mach/ 85 Latest release: version 0.9.0 'Cambria' on branch 2. 86 """ % doap 87 self.assertEquals(self.stdout.getvalue(), ref)
88
89 - def tearDown(self):
90 os.chdir(self._cwd)
91 92 try: 93 import RDF 94 except ImportError: 95 TestDoapMach.skip = "No rdf module, skipping." 96 TestDoapUnspecified.skip = "No rdf module, skipping." 97