~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_parent.py

  • Committer: John Arbash Meinel
  • Date: 2005-11-30 15:43:57 UTC
  • mto: (1185.50.1 jam-integration)
  • mto: This revision was merged to the branch mainline in revision 1518.
  • Revision ID: john@arbash-meinel.com-20051130154357-614206b3a7b83cd0
Refactored bzrlib/ui.py into a module with the possibility for multiple ui forms.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
 
18
18
import os
19
 
 
 
19
from bzrlib.tests import TestCaseInTempDir
20
20
from bzrlib.branch import Branch
21
 
import bzrlib.errors
22
 
from bzrlib.osutils import abspath, realpath, getcwd
23
 
from bzrlib.urlutils import local_path_from_url, local_path_to_url, escape
24
 
from bzrlib.tests import TestCaseWithTransport
 
21
from bzrlib.clone import copy_branch
25
22
 
26
23
 
27
24
"""Tests for Branch parent URL"""
28
25
 
29
26
 
30
 
class TestParent(TestCaseWithTransport):
31
 
 
 
27
class TestParent(TestCaseInTempDir):
32
28
    def test_no_default_parent(self):
33
29
        """Branches should have no parent by default"""
34
 
        b = self.make_branch('.')
 
30
        b = Branch.initialize(u'.')
35
31
        self.assertEquals(b.get_parent(), None)
36
32
        
 
33
    
37
34
    def test_set_get_parent(self):
38
 
        """Set, re-get and reset the parent"""
39
 
        b = self.make_branch('.')
40
 
        url = 'http://bazaar-vcs.org/bzr/bzr.dev'
 
35
        """Set and then re-get the parent"""
 
36
        b = Branch.initialize(u'.')
 
37
        url = 'http://bazaar-ng.org/bzr/bzr.dev'
41
38
        b.set_parent(url)
42
39
        self.assertEquals(b.get_parent(), url)
43
 
        self.assertEqual(b.control_files.get('parent').read().strip('\n'), url)
44
 
 
45
 
        b.set_parent(None)
46
 
        self.assertEquals(b.get_parent(), None)
47
 
 
48
 
        b.set_parent('../other_branch')
49
 
        cwd = getcwd()
50
 
 
51
 
        self.assertEquals(b.get_parent(), local_path_to_url('../other_branch'))
52
 
        path = local_path_to_url('../yanb')
53
 
        b.set_parent(path)
54
 
        self.assertEqual(b.control_files.get('parent').read().strip('\n'), 
55
 
            '../yanb')
56
 
        self.assertEqual(b.get_parent(), path)
57
 
 
58
 
 
59
 
        self.assertRaises(bzrlib.errors.InvalidURL, b.set_parent, u'\xb5')
60
 
        b.set_parent(escape(u'\xb5'))
61
 
        self.assertEqual(b.control_files.get('parent').read().strip('\n'), 
62
 
            '%C2%B5')
63
 
 
64
 
        self.assertEqual(b.get_parent(), b.base + '%C2%B5')
 
40
 
 
41
    def test_branch_sets_parent(self):
 
42
        """The branch command should set the new branch's parent"""
 
43
        from bzrlib.commands import run_bzr
 
44
 
 
45
        os.mkdir('from')
 
46
        branch_from = Branch.initialize('from')
 
47
        file('from/foo', 'wt').write('contents of foo')
 
48
        branch_from.working_tree().add('foo')
 
49
        branch_from.working_tree().commit('initial commit')
 
50
        
 
51
        os.mkdir('to')
 
52
        copy_branch(branch_from, 'to', None)
 
53
 
 
54
        branch_to = Branch.open('to')
 
55
        abspath = os.path.abspath('from')
 
56
        self.assertEquals(branch_to.get_parent(), abspath)
 
57
        
65
58