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