/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
1
# Copyright (C) 2008, 2009, 2010, 2016 Canonical Ltd
3586.1.16 by Ian Clatworthy
added blackbox tests for the view command
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
6670.4.12 by Jelmer Vernooij
Move inventorytree to breezy.bzr.
19
from breezy.bzr import bzrdir
6622.1.34 by Jelmer Vernooij
Rename brzlib => breezy.
20
from breezy.tests import TestCaseWithTransport
21
from breezy.workingtree import WorkingTree
3586.1.16 by Ian Clatworthy
added blackbox tests for the view command
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')
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
34
        self.assertEqual(out, "Using 'my' view: a, b, c\n")
3586.1.16 by Ian Clatworthy
added blackbox tests for the view command
35
        out, err = self.run_bzr('view e f --name foo')
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
36
        self.assertEqual(out, "Using 'foo' view: e, f\n")
3586.1.16 by Ian Clatworthy
added blackbox tests for the view command
37
        # Check re-definition of an existing view
38
        out, err = self.run_bzr('view p q')
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
39
        self.assertEqual(out, "Using 'foo' view: p, q\n")
3586.1.16 by Ian Clatworthy
added blackbox tests for the view command
40
        out, err = self.run_bzr('view r s --name my')
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
41
        self.assertEqual(out, "Using 'my' view: r, s\n")
3586.1.16 by Ian Clatworthy
added blackbox tests for the view command
42
        # Check attempts to define the 'off' view are prevented
43
        out, err = self.run_bzr('view a --name off', retcode=3)
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
44
        self.assertContainsRe(err, "Cannot change the 'off' pseudo view")
3586.1.16 by Ian Clatworthy
added blackbox tests for the view command
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')
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
50
        self.assertEqual(out, "No current view.\n")
3586.1.16 by Ian Clatworthy
added blackbox tests for the view command
51
        self.run_bzr('view a b c')
52
        out, err = self.run_bzr('view')
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
53
        self.assertEqual(out, "'my' view is: a, b, c\n")
3586.1.16 by Ian Clatworthy
added blackbox tests for the view command
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')
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
57
        self.assertEqual(out, "'my' view is: a, b, c\n")
3586.1.16 by Ian Clatworthy
added blackbox tests for the view command
58
        out, err = self.run_bzr('view --name foo')
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
59
        self.assertEqual(out, "'foo' view is: e, f\n")
3586.1.16 by Ian Clatworthy
added blackbox tests for the view command
60
        # Check list of all views
61
        out, err = self.run_bzr('view --all')
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
62
        self.assertEqual(out.splitlines(), [
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
63
            "Views defined:",
64
            "=> foo                  e, f",
65
            "   my                   a, b, c",
3586.1.16 by Ian Clatworthy
added blackbox tests for the view command
66
            ])
67
        # Check list of an unknown view
68
        out, err = self.run_bzr('view --name bar', retcode=3)
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
69
        self.assertContainsRe(err, "No such view")
3586.1.16 by Ian Clatworthy
added blackbox tests for the view command
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)
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
75
        self.assertContainsRe(err, "No current view to delete")
3586.1.16 by Ian Clatworthy
added blackbox tests for the view command
76
        self.run_bzr('view a b c')
77
        out, err = self.run_bzr('view --delete')
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
78
        self.assertEqual(out, "Deleted 'my' view.\n")
3586.1.16 by Ian Clatworthy
added blackbox tests for the view command
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')
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
82
        self.assertEqual(out, "Deleted 'foo' view.\n")
3586.1.16 by Ian Clatworthy
added blackbox tests for the view command
83
        # Check delete of all views
84
        out, err = self.run_bzr('view --delete --all')
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
85
        self.assertEqual(out, "Deleted all views.\n")
3586.1.16 by Ian Clatworthy
added blackbox tests for the view command
86
        # Check delete of an unknown view
87
        out, err = self.run_bzr('view --delete --name bar', retcode=3)
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
88
        self.assertContainsRe(err, "No such view")
3586.1.16 by Ian Clatworthy
added blackbox tests for the view command
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,
7143.15.2 by Jelmer Vernooij
Run autopep8.
92
                              "Both --delete and --switch specified")
3586.1.16 by Ian Clatworthy
added blackbox tests for the view command
93
        out, err = self.run_bzr('view --delete a b c', retcode=3)
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
94
        self.assertContainsRe(err, "Both --delete and a file list specified")
3586.1.16 by Ian Clatworthy
added blackbox tests for the view command
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')
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
102
        self.assertEqual(out, "Using 'my' view: a, b, c\n")
3586.1.16 by Ian Clatworthy
added blackbox tests for the view command
103
        # Check switching off the current view does not delete it
104
        out, err = self.run_bzr('view --switch off')
6614.1.3 by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual.
105
        self.assertEqual(out, "Disabled 'my' view.\n")
3586.1.16 by Ian Clatworthy
added blackbox tests for the view command
106
        # Check error reporting when attempt to switch off again
107
        out, err = self.run_bzr('view --switch off', retcode=3)
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
108
        self.assertContainsRe(err, "No current view to disable")
3586.1.16 by Ian Clatworthy
added blackbox tests for the view command
109
        # Check bad usage is reported to the user
110
        out, err = self.run_bzr('view --switch x --all', retcode=3)
7027.4.1 by Jelmer Vernooij
Use StringIOWithEncoding on Python3.
111
        self.assertContainsRe(err, "Both --switch and --all specified")