/loggerhead/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/loggerhead/trunk

« back to all changes in this revision

Viewing changes to loggerhead/tests/test_corners.py

  • Committer: Michael Hudson
  • Date: 2008-06-18 08:18:01 UTC
  • mto: This revision was merged to the branch mainline in revision 164.
  • Revision ID: michael.hudson@canonical.com-20080618081801-hurh19gq94tgbidg
convert the tests over to paste-style
(so much nicer!)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
import re
2
1
import os
3
2
 
4
 
import cherrypy
5
 
from turbogears import testutil
6
 
 
7
3
from loggerhead.tests.test_simple import BasicTests
8
4
 
 
5
 
9
6
class TestCornerCases(BasicTests):
10
7
    """Tests that excercise various corner cases."""
11
8
 
23
20
        self.tree.add(filename)
24
21
        self.tree.commit(message=commit_msg)
25
22
 
26
 
 
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.
30
 
        """
31
 
        self.createBranch()
32
 
 
33
 
        msg = 'a very exciting commit message'
34
 
        self.addFileAndCommit('myfilename', msg)
35
 
 
36
 
        self.setUpLoggerhead()
37
 
 
38
 
        testutil.create_request('/project/branch/changes')
39
 
        assert msg in cherrypy.response.body[0]
40
 
 
41
 
        from bzrlib.upgrade import upgrade
42
 
        from bzrlib.bzrdir import format_registry
43
 
        upgrade(self.bzrbranch, format_registry.make_bzrdir('dirstate-tags'))
44
 
 
45
 
        testutil.create_request('/project/branch/changes')
46
 
        assert msg in cherrypy.response.body[0]
47
 
 
48
 
 
49
23
    def test_revision_only_changing_execute_bit(self):
50
24
        """Check that a commit that only changes the execute bit of a file
51
25
        does not break the rendering."""
60
34
        newrevid = self.tree.commit(message='make something executable')
61
35
 
62
36
        # Check that it didn't break things.
63
 
        self.setUpLoggerhead()
64
 
        testutil.create_request('/project/branch/revision/'+newrevid)
65
 
        assert 'executable' in cherrypy.response.body[0]
66
 
 
 
37
        app = self.setUpLoggerhead()
 
38
        res = app.get('/revision/'+newrevid)
 
39
        res.mustcontain('executable')
67
40
 
68
41
    def test_empty_commit_message(self):
69
42
        """Check that an empty commit message does not break the rendering."""
73
46
        self.addFileAndCommit('myfilename', '')
74
47
 
75
48
        # Check that it didn't break things.
76
 
        self.setUpLoggerhead()
77
 
        testutil.create_request('/project/branch/changes')
 
49
        app = self.setUpLoggerhead()
 
50
        res = app.get('/changes')
78
51
        # It's not much of an assertion, but we only really care about
79
52
        # "assert not crashed".
80
 
        assert 'myfilename' in cherrypy.response.body[0]
81
 
 
 
53
        res.mustcontain('myfilename')
82
54
 
83
55
    def test_whitespace_only_commit_message(self):
84
56
        """Check that a whitespace-only commit message does not break the
89
61
        self.addFileAndCommit('myfilename', '   ')
90
62
 
91
63
        # Check that it didn't break things.
92
 
        self.setUpLoggerhead()
93
 
        testutil.create_request('/project/branch/changes')
 
64
        app = self.setUpLoggerhead()
 
65
        res = app.get('/changes')
94
66
        # It's not much of an assertion, but we only really care about
95
67
        # "assert not crashed".
96
 
        assert 'myfilename' in cherrypy.response.body[0]
97
 
 
98
 
    def test_revision_size_limit(self):
99
 
        self.createBranch()
100
 
        msg = 'a very exciting commit message'
101
 
        self.addFileAndCommit('myfilename', msg)
102
 
 
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')
107
 
 
108
 
        self.setUpLoggerhead()
109
 
        cherrypy.root._config['line_count_limit'] = 50
110
 
        testutil.create_request('/project/branch/revision/'+newrevid)
111
 
 
112
 
        match = re.search(
113
 
            'Diff of [0-9]+ lines is too long to display richly -- limit '
114
 
            'is 50 lines\\.',
115
 
            cherrypy.response.body[0]
116
 
            )
117
 
 
118
 
        assert match is not None
 
68
        res.mustcontain('myfilename')
 
69
 
 
70
#    def test_revision_size_limit(self):
 
71
#        self.createBranch()
 
72
#        msg = 'a very exciting commit message'
 
73
#        self.addFileAndCommit('myfilename', msg)
 
74
#
 
75
#        file_in_branch = open(os.path.join(self.bzrbranch, 'myfilename'), 'w')
 
76
#        file_in_branch.write('\n'.join(['line']*100))
 
77
#        file_in_branch.close()
 
78
#        newrevid = self.tree.commit(message='touch 100 lines')
 
79
#
 
80
#        self.setUpLoggerhead()
 
81
#        cherrypy.root._config['line_count_limit'] = 50
 
82
#        testutil.create_request('/project/branch/revision/'+newrevid)
 
83
#
 
84
#        match = re.search(
 
85
#            'Diff of [0-9]+ lines is too long to display richly -- limit '
 
86
#            'is 50 lines\\.',
 
87
#            cherrypy.response.body[0]
 
88
#            )
 
89
#
 
90
#        assert match is not None