1
2
3
4 import os
5 import tempfile
6
7
8 try:
9 from twisted.trial import unittest
10 except ImportError:
11 import unittest
12
13 from moap.util import log
14 log.init()
15
18
19 log.debug('unittest', "%s.setUp() for %s" % (
20 self.__class__.__name__,
21 getattr(self, '_testMethodName', getattr(
22 self, 'caseMethodName', "[unknown method]"))))
23
25 log.debug('unittest', "%s.tearDown() for %s" % (
26 self.__class__.__name__,
27 getattr(self, '_testMethodName', getattr(
28 self, 'caseMethodName', "[unknown method]"))))
29
32 """
33 Create a svn repository we can use for testing.
34
35 @rtype: str
36 """
37 repodir = self.createDirectory('repo')
38 log.debug('unittest', 'creating temp repo in %s' % repodir)
39 value = os.system('svnadmin create %s' % repodir)
40 self.assertEquals(value, 0, "Could not execute svnadmin")
41 return repodir
42
44 """
45 Create a "live" area where we can store files for testing.
46
47 @rtype: str
48 """
49 livedir = self.createDirectory('live')
50 log.debug('unittest', 'creating live area in %s' % livedir)
51 value = os.system('mkdir -p %s' % livedir)
52
53 self.assertEquals(value, 0, "Could not create %s" % livedir)
54 return livedir
55
57 """
58 Create a directory using the given name as part of the name.
59
60 @rtype: str
61 """
62 return tempfile.mkdtemp(suffix=".%s.svn.test" % name)
63
65 path = os.path.join(self.livedir, livePath)
66 handle = open(path, "w")
67 handle.write(data)
68 handle.close()
69 return path
70
75
79