1
from loggerhead.tests.test_simple import BasicTests
4
5
from turbogears import testutil
7
from loggerhead.tests.test_simple import BasicTests
7
9
class TestCornerCases(BasicTests):
10
"""Tests that excercise various corner cases."""
12
def addFileAndCommit(self, filename, commit_msg):
13
"""Make a trivial commit that has 'msg' as its commit message.
15
The commit adds a file called 'myfilename' containing the string
18
f = open(os.path.join(self.bzrbranch, filename), 'w')
23
self.tree.add(filename)
24
self.tree.commit(message=commit_msg)
9
27
def test_survive_over_upgrade(self):
28
"""Check that running 'bzr upgrade' on a branch does not break an
29
instance of loggerhead that's already looked at it.
10
31
self.createBranch()
12
f = open(os.path.join(self.bzrbranch, 'myfilename'), 'w')
17
self.tree.add('myfilename')
18
33
msg = 'a very exciting commit message'
19
self.tree.commit(message=msg)
34
self.addFileAndCommit('myfilename', msg)
21
36
self.setUpLoggerhead()
30
45
testutil.create_request('/project/branch/changes')
31
46
assert msg in cherrypy.response.body[0]
33
49
def test_revision_only_changing_execute_bit(self):
50
"""Check that a commit that only changes the execute bit of a file
51
does not break the rendering."""
34
52
self.createBranch()
36
f = open(os.path.join(self.bzrbranch, 'myfilename'), 'w')
41
self.tree.add('myfilename')
54
# Just a commit to have a file to change the execute bit of.
42
55
msg = 'a very exciting commit message'
43
self.tree.commit(message=msg)
56
self.addFileAndCommit('myfilename', msg)
58
# Make a commit that changes the execute bit of 'myfilename'.
45
59
os.chmod(os.path.join(self.bzrbranch, 'myfilename'), 0755)
47
60
newrevid = self.tree.commit(message='make something executable')
62
# Check that it didn't break things.
49
63
self.setUpLoggerhead()
52
64
testutil.create_request('/project/branch/revision/'+newrevid)
53
65
assert 'executable' in cherrypy.response.body[0]
68
def test_empty_commit_message(self):
69
"""Check that an empty commit message does not break the rendering."""
72
# Make a commit that has an empty message.
73
self.addFileAndCommit('myfilename', '')
75
# Check that it didn't break things.
76
self.setUpLoggerhead()
77
testutil.create_request('/project/branch/changes')
78
# It's not much of an assertion, but we only really care about
79
# "assert not crashed".
80
assert 'myfilename' in cherrypy.response.body[0]
83
def test_whitespace_only_commit_message(self):
84
"""Check that a whitespace-only commit message does not break the
88
# Make a commit that has a whitespace only message.
89
self.addFileAndCommit('myfilename', ' ')
91
# Check that it didn't break things.
92
self.setUpLoggerhead()
93
testutil.create_request('/project/branch/changes')
94
# It's not much of an assertion, but we only really care about
95
# "assert not crashed".
96
assert 'myfilename' in cherrypy.response.body[0]
98
def test_revision_size_limit(self):
100
msg = 'a very exciting commit message'
101
self.addFileAndCommit('myfilename', msg)
103
file_in_branch = open(os.path.join(self.bzrbranch, 'myfilename'), 'w')
104
file_in_branch.write('\n'.join(['line']*100))
105
file_in_branch.close()
106
newrevid = self.tree.commit(message='touch 100 lines')
108
self.setUpLoggerhead()
109
cherrypy.root._config['line_count_limit'] = 50
110
testutil.create_request('/project/branch/revision/'+newrevid)
113
'Diff of [0-9]+ lines is too long to display richly -- limit '
115
cherrypy.response.body[0]
118
assert match is not None