3586.1.16
by Ian Clatworthy
added blackbox tests for the view command |
1 |
# Copyright (C) 2008 Canonical Ltd
|
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
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
3586.1.16
by Ian Clatworthy
added blackbox tests for the view command |
16 |
|
17 |
"""Tests for the view command"""
|
|
18 |
||
19 |
from bzrlib import bzrdir |
|
20 |
from bzrlib.tests import TestCaseWithTransport |
|
21 |
from bzrlib.workingtree import WorkingTree |
|
22 |
||
23 |
||
24 |
class TestViewUI(TestCaseWithTransport): |
|
25 |
||
26 |
def test_view_command_help(self): |
|
27 |
out, err = self.run_bzr('help view') |
|
28 |
self.assertContainsRe(out, 'Manage filtered views') |
|
29 |
||
30 |
def test_define_view(self): |
|
5546.1.1
by Andrew Bennetts
Remove RepositoryFormatCHK1 and RepositoryFormatCHK2. |
31 |
wt = self.make_branch_and_tree('.') |
3586.1.16
by Ian Clatworthy
added blackbox tests for the view command |
32 |
# Check definition of a new view
|
33 |
out, err = self.run_bzr('view a b c') |
|
34 |
self.assertEquals(out, "Using 'my' view: a, b, c\n") |
|
35 |
out, err = self.run_bzr('view e f --name foo') |
|
36 |
self.assertEquals(out, "Using 'foo' view: e, f\n") |
|
37 |
# Check re-definition of an existing view
|
|
38 |
out, err = self.run_bzr('view p q') |
|
39 |
self.assertEquals(out, "Using 'foo' view: p, q\n") |
|
40 |
out, err = self.run_bzr('view r s --name my') |
|
41 |
self.assertEquals(out, "Using 'my' view: r, s\n") |
|
42 |
# Check attempts to define the 'off' view are prevented
|
|
43 |
out, err = self.run_bzr('view a --name off', retcode=3) |
|
44 |
self.assertContainsRe(err, "Cannot change the 'off' pseudo view") |
|
45 |
||
46 |
def test_list_view(self): |
|
5546.1.1
by Andrew Bennetts
Remove RepositoryFormatCHK1 and RepositoryFormatCHK2. |
47 |
wt = self.make_branch_and_tree('.') |
3586.1.16
by Ian Clatworthy
added blackbox tests for the view command |
48 |
# Check list of the current view
|
49 |
out, err = self.run_bzr('view') |
|
50 |
self.assertEquals(out, "No current view.\n") |
|
51 |
self.run_bzr('view a b c') |
|
52 |
out, err = self.run_bzr('view') |
|
53 |
self.assertEquals(out, "'my' view is: a, b, c\n") |
|
54 |
# Check list of a named view
|
|
55 |
self.run_bzr('view e f --name foo') |
|
56 |
out, err = self.run_bzr('view --name my') |
|
57 |
self.assertEquals(out, "'my' view is: a, b, c\n") |
|
58 |
out, err = self.run_bzr('view --name foo') |
|
59 |
self.assertEquals(out, "'foo' view is: e, f\n") |
|
60 |
# Check list of all views
|
|
61 |
out, err = self.run_bzr('view --all') |
|
62 |
self.assertEquals(out.splitlines(), [ |
|
63 |
"Views defined:", |
|
64 |
"=> foo e, f", |
|
65 |
" my a, b, c", |
|
66 |
])
|
|
67 |
# Check list of an unknown view
|
|
68 |
out, err = self.run_bzr('view --name bar', retcode=3) |
|
69 |
self.assertContainsRe(err, "No such view") |
|
70 |
||
71 |
def test_delete_view(self): |
|
5546.1.1
by Andrew Bennetts
Remove RepositoryFormatCHK1 and RepositoryFormatCHK2. |
72 |
wt = self.make_branch_and_tree('.') |
3586.1.16
by Ian Clatworthy
added blackbox tests for the view command |
73 |
# Check delete of the current view
|
74 |
out, err = self.run_bzr('view --delete', retcode=3) |
|
75 |
self.assertContainsRe(err, "No current view to delete") |
|
76 |
self.run_bzr('view a b c') |
|
77 |
out, err = self.run_bzr('view --delete') |
|
78 |
self.assertEquals(out, "Deleted 'my' view.\n") |
|
79 |
# Check delete of a named view
|
|
80 |
self.run_bzr('view e f --name foo') |
|
81 |
out, err = self.run_bzr('view --name foo --delete') |
|
82 |
self.assertEquals(out, "Deleted 'foo' view.\n") |
|
83 |
# Check delete of all views
|
|
84 |
out, err = self.run_bzr('view --delete --all') |
|
85 |
self.assertEquals(out, "Deleted all views.\n") |
|
86 |
# Check delete of an unknown view
|
|
87 |
out, err = self.run_bzr('view --delete --name bar', retcode=3) |
|
88 |
self.assertContainsRe(err, "No such view") |
|
89 |
# Check bad usage is reported to the user
|
|
90 |
out, err = self.run_bzr('view --delete --switch x', retcode=3) |
|
91 |
self.assertContainsRe(err, |
|
92 |
"Both --delete and --switch specified") |
|
93 |
out, err = self.run_bzr('view --delete a b c', retcode=3) |
|
94 |
self.assertContainsRe(err, "Both --delete and a file list specified") |
|
95 |
||
96 |
def test_switch_view(self): |
|
5546.1.1
by Andrew Bennetts
Remove RepositoryFormatCHK1 and RepositoryFormatCHK2. |
97 |
wt = self.make_branch_and_tree('.') |
3586.1.16
by Ian Clatworthy
added blackbox tests for the view command |
98 |
# Check switching to a named view
|
99 |
self.run_bzr('view a b c') |
|
100 |
self.run_bzr('view e f --name foo') |
|
101 |
out, err = self.run_bzr('view --switch my') |
|
102 |
self.assertEquals(out, "Using 'my' view: a, b, c\n") |
|
103 |
# Check switching off the current view does not delete it
|
|
104 |
out, err = self.run_bzr('view --switch off') |
|
105 |
self.assertEquals(out, "Disabled 'my' view.\n") |
|
106 |
# Check error reporting when attempt to switch off again
|
|
107 |
out, err = self.run_bzr('view --switch off', retcode=3) |
|
108 |
self.assertContainsRe(err, "No current view to disable") |
|
109 |
# Check bad usage is reported to the user
|
|
110 |
out, err = self.run_bzr('view --switch x --all', retcode=3) |
|
111 |
self.assertContainsRe(err, "Both --switch and --all specified") |