~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/test_parent.py

  • Committer: Robert Collins
  • Date: 2005-09-27 07:24:40 UTC
  • mfrom: (1185.1.41)
  • Revision ID: robertc@robertcollins.net-20050927072440-1bf4d99c3e1db5b3
pair programming worx... merge integration and weave

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
 
18
18
import os
19
 
 
20
 
from bzrlib.branch import Branch
21
 
from bzrlib.osutils import abspath, realpath
22
 
from bzrlib.tests import TestCaseWithTransport
 
19
from bzrlib.selftest import TestCaseInTempDir
 
20
from bzrlib.branch import Branch, copy_branch
23
21
 
24
22
 
25
23
"""Tests for Branch parent URL"""
26
24
 
27
25
 
28
 
class TestParent(TestCaseWithTransport):
29
 
 
 
26
class TestParent(TestCaseInTempDir):
30
27
    def test_no_default_parent(self):
31
28
        """Branches should have no parent by default"""
32
 
        b = self.make_branch('.')
 
29
        b = Branch.initialize('.')
33
30
        self.assertEquals(b.get_parent(), None)
34
31
        
 
32
    
35
33
    def test_set_get_parent(self):
36
 
        """Set, re-get and reset the parent"""
37
 
        b = self.make_branch('.')
 
34
        """Set and then re-get the parent"""
 
35
        b = Branch.initialize('.')
38
36
        url = 'http://bazaar-ng.org/bzr/bzr.dev'
39
37
        b.set_parent(url)
40
38
        self.assertEquals(b.get_parent(), url)
41
 
        b.set_parent(None)
42
 
        self.assertEquals(b.get_parent(), None)
 
39
 
 
40
    def test_branch_sets_parent(self):
 
41
        """The branch command should set the new branch's parent"""
 
42
        from bzrlib.commands import run_bzr
 
43
 
 
44
        os.mkdir('from')
 
45
        branch_from = Branch.initialize('from')
 
46
        file('from/foo', 'wt').write('contents of foo')
 
47
        branch_from.add('foo')
 
48
        branch_from.commit('initial commit')
 
49
        
 
50
        os.mkdir('to')
 
51
        copy_branch(branch_from, 'to', None)
 
52
 
 
53
        branch_to = Branch.open('to')
 
54
        abspath = os.path.abspath('from')
 
55
        self.assertEquals(branch_to.get_parent(), abspath)
 
56
        
 
57