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