/loggerhead/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/loggerhead/trunk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import os

from loggerhead.tests.test_simple import BasicTests


class TestCornerCases(BasicTests):
    """Tests that excercise various corner cases."""

    def addFileAndCommit(self, filename, commit_msg):
        """Make a trivial commit that has 'msg' as its commit message.

        The commit adds a file called 'myfilename' containing the string
        'foo'.
        """
        self.build_tree_contents([(filename, 'foo')])
        self.tree.add(filename)
        self.tree.commit(message=commit_msg)

    def test_revision_only_changing_execute_bit(self):
        """Check that a commit that only changes the execute bit of a file
        does not break the rendering."""
        self.createBranch()

        # Just a commit to have a file to change the execute bit of.
        msg = 'a very exciting commit message'
        self.addFileAndCommit('myfilename', msg)

        # Make a commit that changes the execute bit of 'myfilename'.
        os.chmod('myfilename', 0755)
        newrevid = self.tree.commit(message='make something executable')

        # Check that it didn't break things.
        app = self.setUpLoggerhead()
        res = app.get('/revision/'+newrevid)
        res.mustcontain('executable')

    def test_revision_escapes_commit_message(self):
        """XXX."""
        self.createBranch()

        msg = '<b>hi</b>'
        self.addFileAndCommit('myfilename', msg)
        app = self.setUpLoggerhead()
        res = app.get('/revision/1')
        self.assertFalse(msg in res.body)

    def test_empty_commit_message(self):
        """Check that an empty commit message does not break the rendering."""
        self.createBranch()

        # Make a commit that has an empty message.
        self.addFileAndCommit('myfilename', '')

        # Check that it didn't break things.
        app = self.setUpLoggerhead()
        res = app.get('/changes')
        # It's not much of an assertion, but we only really care about
        # "assert not crashed".
        res.mustcontain('1')

    def test_whitespace_only_commit_message(self):
        """Check that a whitespace-only commit message does not break the
        rendering."""
        self.createBranch()

        # Make a commit that has a whitespace only message.
        self.addFileAndCommit('myfilename', '   ')

        # Check that it didn't break things.
        app = self.setUpLoggerhead()
        res = app.get('/changes')
        # It's not much of an assertion, but we only really care about
        # "assert not crashed".
        res.mustcontain('1')