1
# Copyright (C) 2008, 2009, 2010, 2016 Canonical Ltd
1
# Copyright (C) 2008 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
31
31
wt = self.make_branch_and_tree('.')
32
32
# Check definition of a new view
33
33
out, err = self.run_bzr('view a b c')
34
self.assertEqual(out, "Using 'my' view: a, b, c\n")
34
self.assertEquals(out, "Using 'my' view: a, b, c\n")
35
35
out, err = self.run_bzr('view e f --name foo')
36
self.assertEqual(out, "Using 'foo' view: e, f\n")
36
self.assertEquals(out, "Using 'foo' view: e, f\n")
37
37
# Check re-definition of an existing view
38
38
out, err = self.run_bzr('view p q')
39
self.assertEqual(out, "Using 'foo' view: p, q\n")
39
self.assertEquals(out, "Using 'foo' view: p, q\n")
40
40
out, err = self.run_bzr('view r s --name my')
41
self.assertEqual(out, "Using 'my' view: r, s\n")
41
self.assertEquals(out, "Using 'my' view: r, s\n")
42
42
# Check attempts to define the 'off' view are prevented
43
43
out, err = self.run_bzr('view a --name off', retcode=3)
44
44
self.assertContainsRe(err, "Cannot change the 'off' pseudo view")
47
47
wt = self.make_branch_and_tree('.')
48
48
# Check list of the current view
49
49
out, err = self.run_bzr('view')
50
self.assertEqual(out, "No current view.\n")
50
self.assertEquals(out, "No current view.\n")
51
51
self.run_bzr('view a b c')
52
52
out, err = self.run_bzr('view')
53
self.assertEqual(out, "'my' view is: a, b, c\n")
53
self.assertEquals(out, "'my' view is: a, b, c\n")
54
54
# Check list of a named view
55
55
self.run_bzr('view e f --name foo')
56
56
out, err = self.run_bzr('view --name my')
57
self.assertEqual(out, "'my' view is: a, b, c\n")
57
self.assertEquals(out, "'my' view is: a, b, c\n")
58
58
out, err = self.run_bzr('view --name foo')
59
self.assertEqual(out, "'foo' view is: e, f\n")
59
self.assertEquals(out, "'foo' view is: e, f\n")
60
60
# Check list of all views
61
61
out, err = self.run_bzr('view --all')
62
self.assertEqual(out.splitlines(), [
62
self.assertEquals(out.splitlines(), [
75
75
self.assertContainsRe(err, "No current view to delete")
76
76
self.run_bzr('view a b c')
77
77
out, err = self.run_bzr('view --delete')
78
self.assertEqual(out, "Deleted 'my' view.\n")
78
self.assertEquals(out, "Deleted 'my' view.\n")
79
79
# Check delete of a named view
80
80
self.run_bzr('view e f --name foo')
81
81
out, err = self.run_bzr('view --name foo --delete')
82
self.assertEqual(out, "Deleted 'foo' view.\n")
82
self.assertEquals(out, "Deleted 'foo' view.\n")
83
83
# Check delete of all views
84
84
out, err = self.run_bzr('view --delete --all')
85
self.assertEqual(out, "Deleted all views.\n")
85
self.assertEquals(out, "Deleted all views.\n")
86
86
# Check delete of an unknown view
87
87
out, err = self.run_bzr('view --delete --name bar', retcode=3)
88
88
self.assertContainsRe(err, "No such view")
99
99
self.run_bzr('view a b c')
100
100
self.run_bzr('view e f --name foo')
101
101
out, err = self.run_bzr('view --switch my')
102
self.assertEqual(out, "Using 'my' view: a, b, c\n")
102
self.assertEquals(out, "Using 'my' view: a, b, c\n")
103
103
# Check switching off the current view does not delete it
104
104
out, err = self.run_bzr('view --switch off')
105
self.assertEqual(out, "Disabled 'my' view.\n")
105
self.assertEquals(out, "Disabled 'my' view.\n")
106
106
# Check error reporting when attempt to switch off again
107
107
out, err = self.run_bzr('view --switch off', retcode=3)
108
108
self.assertContainsRe(err, "No current view to disable")