3
from subprocess import call
4
from tempfile import mkdtemp
5
from trac.tests.functional import *
6
from trac.util.datefmt import format_date, utc
9
class TestEmptyRepo(FunctionalTwillTestCaseSetup):
11
"""Check empty repository"""
12
browser_url = self._tester.url + '/browser'
15
# This tests the current behavior; I'm not sure it's the best
17
tc.follow('Last Change')
18
tc.find('Error: No such changeset')
20
tc.follow('Revision Log')
21
tc.notfind('Error: Nonexistent path')
24
class TestRepoCreation(FunctionalTwillTestCaseSetup):
26
"""Create a directory tree in the repository"""
27
# This should probably use the svn bindings...
29
for component in ('component1', 'component2'):
30
directories.append(component)
31
for subdir in ('branches', 'tags', 'trunk'):
32
directories.append('/'.join([component, subdir]))
33
commit_message = 'Create component trees.'
34
self._tester.svn_mkdir(directories, commit_message)
36
browser_url = self._tester.url + '/browser'
41
tc.follow('Last Change')
42
tc.url(self._tester.url + '/changeset/1/')
43
tc.find(commit_message)
44
for directory in directories:
47
tc.follow('Revision Log')
48
# (Note that our commit log message is short enough to avoid
50
tc.find(commit_message)
52
# (Note that our commit log message is short enough to avoid
54
tc.find(commit_message)
55
tc.formvalue('prefs', 'ticket', False)
56
tc.formvalue('prefs', 'milestone', False)
57
tc.formvalue('prefs', 'wiki', False)
60
# (Note that our commit log message is short enough to avoid
62
tc.find(commit_message)
65
class RegressionTestRev6017(FunctionalTwillTestCaseSetup):
67
"""Test for regression of the plugin reload fix in r6017"""
68
# Setup the DeleteTicket plugin
69
plugin = open(os.path.join(self._testenv.command_cwd, 'sample-plugins',
70
'workflow', 'DeleteTicket.py')).read()
71
open(os.path.join(self._testenv.tracdir, 'plugins', 'DeleteTicket.py'),
73
env = self._testenv.get_trac_environment()
74
prevconfig = env.config.get('ticket', 'workflow')
75
env.config.set('ticket', 'workflow',
76
prevconfig + ',DeleteTicketActionController')
78
env = self._testenv.get_trac_environment() # reloads the environment
80
loaded_components = env.compmgr.__metaclass__._components
81
delete_plugins = [c for c in loaded_components
82
if 'DeleteTicketActionController' in c.__name__]
84
self.assertEqual(len(delete_plugins), 1,
85
"Plugin loaded more than once.")
88
# Remove the DeleteTicket plugin
89
env.config.set('ticket', 'workflow', prevconfig)
91
self._testenv.restart()
92
for ext in ('py', 'pyc', 'pyo'):
93
filename = os.path.join(self._testenv.tracdir, 'plugins',
94
'DeleteTicket.%s' % ext)
95
if os.path.exists(filename):
99
class RegressionTestTicket3833a(FunctionalTestCaseSetup):
101
"""Test for regression of http://trac.edgewall.org/ticket/3833 a"""
102
# Assume the logging is already set to debug.
103
traclogfile = open(os.path.join(self._testenv.tracdir, 'log',
105
# Seek to the end of file so we only look at new log output
106
traclogfile.seek(0, 2)
107
# Verify that logging is on initially
108
env = self._testenv.get_trac_environment()
110
env.log.debug("RegressionTestTicket3833 debug1")
111
debug1 = traclogfile.read()
112
self.assertNotEqual(debug1.find("RegressionTestTicket3833 debug1"), -1,
113
'Logging off when it should have been on.\n%r' % debug1)
115
class RegressionTestTicket3833b(FunctionalTestCaseSetup):
117
"""Test for regression of http://trac.edgewall.org/ticket/3833 b"""
118
# Turn logging off, try to log something, and verify that it does
120
traclogfile = open(os.path.join(self._testenv.tracdir, 'log',
122
# Seek to the end of file so we only look at new log output
123
traclogfile.seek(0, 2)
124
env = self._testenv.get_trac_environment()
126
env.config.set('logging', 'log_level', 'INFO')
128
env = self._testenv.get_trac_environment()
129
env.log.debug("RegressionTestTicket3833 debug2")
130
env.log.info("RegressionTestTicket3833 info2")
131
debug2 = traclogfile.read()
132
self.assertNotEqual(debug2.find("RegressionTestTicket3833 info2"), -1,
133
'Logging at info failed.\n%r' % debug2)
134
self.assertEqual(debug2.find("RegressionTestTicket3833 debug2"), -1,
135
'Logging still on when it should have been off.\n%r' % debug2)
137
class RegressionTestTicket3833c(FunctionalTestCaseSetup):
139
"""Test for regression of http://trac.edgewall.org/ticket/3833 c"""
140
# Turn logging back on, try to log something, and verify that it
142
traclogfile = open(os.path.join(self._testenv.tracdir, 'log',
144
# Seek to the end of file so we only look at new log output
145
traclogfile.seek(0, 2)
146
env = self._testenv.get_trac_environment()
148
env.config.set('logging', 'log_level', 'DEBUG')
152
env = self._testenv.get_trac_environment()
154
env.log.debug("RegressionTestTicket3833 debug3")
155
env.log.info("RegressionTestTicket3833 info3")
157
debug3 = traclogfile.read()
159
success = debug3.find("RegressionTestTicket3833 debug3") != -1
161
# Ok, the testcase failed, but we really need logging enabled.
162
self._testenv.restart()
163
env.log.debug("RegressionTestTicket3833 fixup3")
164
fixup3 = traclogfile.read()
165
message = 'Logging still off when it should have been on.\n' \
166
'%r\n%r' % (debug3, fixup3)
167
self.assert_(success, message)
170
class RegressionTestTicket5572(FunctionalTwillTestCaseSetup):
172
"""Test for regression of http://trac.edgewall.org/ticket/5572"""
173
# TODO: this ticket (implemented in r6011) adds a new feature to
174
# make the progress bar more configurable. We need to test this
175
# new configurability.
178
def functionalSuite():
179
suite = FunctionalTestSuite()
180
# These basic tests of the repository need to occur before other things so
181
# that we have a repository to work with.
182
suite.addTest(TestEmptyRepo())
183
suite.addTest(TestRepoCreation())
188
suite = functionalSuite()
190
suite.addTest(RegressionTestRev6017())
191
suite.addTest(RegressionTestTicket3833a())
192
suite.addTest(RegressionTestTicket3833b())
193
suite.addTest(RegressionTestTicket3833c())
194
suite.addTest(RegressionTestTicket5572())
196
import trac.versioncontrol.tests
197
trac.versioncontrol.tests.functionalSuite(suite)
198
import trac.ticket.tests
199
trac.ticket.tests.functionalSuite(suite)
200
import trac.prefs.tests
201
trac.prefs.tests.functionalSuite(suite)
202
import trac.wiki.tests
203
trac.wiki.tests.functionalSuite(suite)
204
import trac.timeline.tests
205
trac.timeline.tests.functionalSuite(suite)
210
if __name__ == '__main__':
211
unittest.main(defaultTest='suite')