/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to tests/test_treemodel.py

  • Committer: Vincent Ladeuil
  • Date: 2008-05-05 18:16:46 UTC
  • mto: (487.1.1 gtk)
  • mto: This revision was merged to the branch mainline in revision 490.
  • Revision ID: v.ladeuil+lp@free.fr-20080505181646-n95l8ltw2u6jtr26
Fix bug #187283 fix replacing _() by _i18n().

* genpot.sh 
Remove duplication. Add the ability to specify the genrated pot
file on command-line for debugging purposes.

* po/olive-gtk.pot:
Regenerated.

* __init__.py, branch.py, branchview/treeview.py, checkout.py,
commit.py, conflicts.py, diff.py, errors.py, initialize.py,
merge.py, nautilus-bzr.py, olive/__init__.py, olive/add.py,
olive/bookmark.py, olive/guifiles.py, olive/info.py,
olive/menu.py, olive/mkdir.py, olive/move.py, olive/remove.py,
olive/rename.py, push.py, revbrowser.py, status.py, tags.py:
Replace all calls to _() by calls to _i18n(), the latter being
defined in __init__.py and imported in the other modules from
there. This fix the problem encountered countless times when
running bzr selftest and getting silly error messages about
boolean not being callables.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2011 Curtis Hovey <sinzui.is@verizon.net>
2
 
#
3
 
# This program is free software; you can redistribute it and/or modify
4
 
# it under the terms of the GNU General Public License as published by
5
 
# the Free Software Foundation; either version 2 of the License, or
6
 
# (at your option) any later version.
7
 
#
8
 
# This program is distributed in the hope that it will be useful,
9
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 
# GNU General Public License for more details.
12
 
#
13
 
# You should have received a copy of the GNU General Public License
14
 
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
 
 
17
 
"""Test the BranchTreeModel functionality."""
18
 
 
19
 
from time import (
20
 
    strftime,
21
 
    localtime,
22
 
    )
23
 
 
24
 
from bzrlib import (
25
 
    tests,
26
 
    )
27
 
 
28
 
from bzrlib.plugins.gtk.branchview.treemodel import BranchTreeModel
29
 
 
30
 
 
31
 
class BranchTreeModelTestCase(tests.TestCaseWithMemoryTransport):
32
 
 
33
 
    def make_test_branch(self, revid, message=None, committer=None):
34
 
        builder = self.make_branch_builder('test')
35
 
        builder.build_snapshot(
36
 
            revid, None, [('add', ('', 'root-id', 'directory', None))],
37
 
            message=message, committer=committer)
38
 
        return builder.get_branch()
39
 
 
40
 
    def test_init(self):
41
 
        branch = self.make_test_branch('A')
42
 
        revision = branch.repository.get_revision('A')
43
 
        branch.tags.set_tag('2.0', revision.revision_id)
44
 
        model = BranchTreeModel(branch, [])
45
 
        self.assertEqual(branch, model.branch)
46
 
        self.assertEqual(branch.repository, model.repository)
47
 
        self.assertEqual({'A': [u'2.0']}, model.tags)
48
 
        self.assertEqual({}, model.revisions)
49
 
        self.assertEqual([], model.line_graph_data)
50
 
 
51
 
    def test_add_tag_create(self):
52
 
        branch = self.make_test_branch('A')
53
 
        revision = branch.repository.get_revision('A')
54
 
        model = BranchTreeModel(branch, [])
55
 
        model.add_tag('2.0', revision.revision_id)
56
 
        self.assertEqual({'A': [u'2.0']}, model.tags)
57
 
 
58
 
    def test_add_tag_append(self):
59
 
        branch = self.make_test_branch('A')
60
 
        revision = branch.repository.get_revision('A')
61
 
        branch.tags.set_tag('2.0', revision.revision_id)
62
 
        model = BranchTreeModel(branch, [])
63
 
        model.add_tag('2.1', revision.revision_id)
64
 
        self.assertEqual({'A': ['2.0', '2.1']}, model.tags)
65
 
 
66
 
    def test_line_graph_item_to_model_row(self):
67
 
        branch = self.make_test_branch(
68
 
            'A', message='badger', committer='fnord')
69
 
        revision = branch.repository.get_revision('A')
70
 
        branch.tags.set_tag('2.0', revision.revision_id)
71
 
        model = BranchTreeModel(branch, [])
72
 
        data_item = (
73
 
            revision.revision_id, (1, 0), (5, 6, 0.5), ('B'), ('C'), [12, 34])
74
 
        row = model._line_graph_item_to_model_row(0, data_item)
75
 
        self.assertEqual(revision.revision_id, row[0], 'Wrong revid.')
76
 
        self.assertEqual((1, 0), row[1], 'Wrong node.')
77
 
        self.assertEqual((5, 6, 0.5), row[2], 'Wrong lines.')
78
 
        self.assertEqual([], row[3], 'Wrong last_lines.')
79
 
        self.assertEqual('12.34', row[4], 'Wrong revno.')
80
 
        self.assertEqual('badger', row[5], 'Wrong summary.')
81
 
        self.assertEqual('badger', row[6], 'Wrong message.')
82
 
        self.assertEqual('fnord', row[7], 'wrong committer.')
83
 
        self.assertEqual(
84
 
            strftime("%Y-%m-%d %H:%M", localtime(revision.timestamp)),
85
 
            row[8], 'Wrong timestamp.')
86
 
        self.assertEqual(revision, row[9], 'Wrong revision.')
87
 
        self.assertEqual(('B'), row[10], 'Wrong parents.')
88
 
        self.assertEqual(('C'), row[11], 'Wrong children.')
89
 
        self.assertEqual(['2.0'], row[12], 'Wrong tags.')
90
 
        self.assertEqual('fnord', row[13], 'Wrong authors.')
91
 
 
92
 
    def test_set_line_graph_data(self):
93
 
        branch = self.make_test_branch(
94
 
            'A', message='badger', committer='fnord')
95
 
        rev_id = branch.repository.get_revision('A').revision_id
96
 
        model = BranchTreeModel(branch, [])
97
 
        data = [(rev_id, (2, 0), (3, 4, 0.5), None, None, [1, 2])]
98
 
        model.set_line_graph_data(data)
99
 
        self.assertEqual(data, model.line_graph_data)
100
 
        tree_iter = model.get_iter_first()
101
 
        self.assertEqual(rev_id, model.get_value(tree_iter, 0))