/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/tests/blackbox/test_reference.py

  • Committer: Jelmer Vernooij
  • Date: 2018-05-19 13:16:11 UTC
  • mto: (6968.4.3 git-archive)
  • mto: This revision was merged to the branch mainline in revision 6972.
  • Revision ID: jelmer@jelmer.uk-20180519131611-l9h9ud41j7qg1m03
Move tar/zip to breezy.archive.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2009 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
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
16
 
 
17
 
 
18
from breezy import (
 
19
    controldir,
 
20
    )
 
21
from breezy.bzr import (
 
22
    branch as _mod_bzrbranch,
 
23
    )
 
24
from breezy.tests import TestCaseWithTransport
 
25
 
 
26
 
 
27
class TestReference(TestCaseWithTransport):
 
28
 
 
29
    def get_default_format(self):
 
30
        format = controldir.format_registry.make_controldir('1.9')
 
31
        format.set_branch_format(_mod_bzrbranch.BzrBranchFormat8())
 
32
        return format
 
33
 
 
34
    def test_no_args_lists(self):
 
35
        branch = self.make_branch('branch')
 
36
        branch.set_reference_info('path', 'http://example.org', b'file-id')
 
37
        branch.set_reference_info('lath', 'http://example.org/2', b'file-id2')
 
38
        out, err = self.run_bzr('reference', working_dir='branch')
 
39
        lines = out.splitlines()
 
40
        self.assertEqual('lath http://example.org/2', lines[0])
 
41
        self.assertEqual('path http://example.org', lines[1])
 
42
 
 
43
    def make_tree_with_reference(self):
 
44
        tree = self.make_branch_and_tree('tree')
 
45
        self.build_tree(['tree/newpath'])
 
46
        tree.add('newpath', b'file-id')
 
47
        tree.branch.set_reference_info('newpath', 'http://example.org', b'file-id')
 
48
        tree.branch.set_reference_info('lath', 'http://example.org/2',
 
49
                b'file-id2')
 
50
        return tree
 
51
 
 
52
    def test_uses_working_tree_location(self):
 
53
        tree = self.make_tree_with_reference()
 
54
        out, err = self.run_bzr('reference', working_dir='tree')
 
55
        self.assertContainsRe(out, 'newpath http://example.org\n')
 
56
 
 
57
    def test_uses_basis_tree_location(self):
 
58
        tree = self.make_tree_with_reference()
 
59
        tree.commit('add newpath')
 
60
        tree.controldir.destroy_workingtree()
 
61
        out, err = self.run_bzr('reference', working_dir='tree')
 
62
        self.assertContainsRe(out, 'newpath http://example.org\n')
 
63
 
 
64
    def test_one_arg_displays(self):
 
65
        tree = self.make_tree_with_reference()
 
66
        out, err = self.run_bzr('reference newpath', working_dir='tree')
 
67
        self.assertEqual('newpath http://example.org\n', out)
 
68
 
 
69
    def test_one_arg_uses_containing_tree(self):
 
70
        tree = self.make_tree_with_reference()
 
71
        out, err = self.run_bzr('reference tree/newpath')
 
72
        self.assertEqual('newpath http://example.org\n', out)
 
73
 
 
74
    def test_two_args_sets(self):
 
75
        tree = self.make_branch_and_tree('tree')
 
76
        self.build_tree(['tree/file'])
 
77
        tree.add('file', b'file-id')
 
78
        out, err = self.run_bzr('reference tree/file http://example.org')
 
79
        location, file_id = tree.branch.get_reference_info('file')
 
80
        self.assertEqual('http://example.org', location)
 
81
        self.assertEqual(b'file-id', file_id)
 
82
        self.assertEqual('', out)
 
83
        self.assertEqual('', err)
 
84
 
 
85
    def test_missing_file(self):
 
86
        tree = self.make_branch_and_tree('tree')
 
87
        out, err = self.run_bzr('reference file http://example.org',
 
88
                                working_dir='tree', retcode=3)
 
89
        self.assertEqual('brz: ERROR: file is not versioned.\n', err)