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 log.debug('unittest', "%s.setUp() for %s" % (
19 self.__class__.__name__, self._testMethodName))
20
22 log.debug('unittest', "%s.tearDown() for %s" % (
23 self.__class__.__name__, self._testMethodName))
24
27 """
28 Create a svn repository we can use for testing.
29
30 @rtype: str
31 """
32 repodir = self.createDirectory('repo')
33 log.debug('unittest', 'creating temp repo in %s' % repodir)
34 value = os.system('svnadmin create %s' % repodir)
35 self.assertEquals(value, 0, "Could not execute svnadmin")
36 return repodir
37
39 """
40 Create a "live" area where we can store files for testing.
41
42 @rtype: str
43 """
44 livedir = self.createDirectory('live')
45 log.debug('unittest', 'creating live area in %s' % livedir)
46 value = os.system('mkdir -p %s' % livedir)
47
48 self.assertEquals(value, 0, "Could not create %s" % livedir)
49 return livedir
50
52 """
53 Create a directory using the given name as part of the name.
54
55 @rtype: str
56 """
57 return tempfile.mkdtemp(suffix=".%s.svn.test" % name)
58
60 path = os.path.join(self.livedir, livePath)
61 handle = open(path, "w")
62 handle.write(data)
63 handle.close()
64 return path
65
67 path = os.path.join(self.livedir, livePath)
68 os.mkdir(path)
69 return path
70
74