bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
1864.7.3
by John Arbash Meinel
Test that the right thing happens when clone/sprout is done with an invalid parent |
1 |
# Copyright (C) 2006 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
16 |
||
17 |
"""Test branch responses when accessed over http"""
|
|
18 |
||
19 |
import os |
|
20 |
||
21 |
from bzrlib import branch, errors |
|
22 |
from bzrlib.tests.branch_implementations.test_branch import TestCaseWithBranch |
|
23 |
from bzrlib.transport.http import HttpServer |
|
24 |
||
25 |
||
26 |
class HTTPBranchTests(TestCaseWithBranch): |
|
27 |
"""Tests that use an HTTP server against each branch implementation""" |
|
28 |
||
29 |
def setUp(self): |
|
30 |
super(HTTPBranchTests, self).setUp() |
|
31 |
self.transport_readonly_server = HttpServer |
|
32 |
||
33 |
def get_parent_and_child(self): |
|
34 |
os.makedirs('parent/path/to') |
|
35 |
wt_a = self.make_branch_and_tree('parent/path/to/a') |
|
36 |
self.build_tree(['parent/path/to/a/one']) |
|
37 |
wt_a.add(['one']) |
|
38 |
wt_a.commit('commit one', rev_id='1') |
|
39 |
||
40 |
os.makedirs('child/path/to') |
|
41 |
branch_b = wt_a.bzrdir.sprout('child/path/to/b', revision_id='1').open_branch() |
|
42 |
self.assertEqual(wt_a.branch.base, branch_b.get_parent()) |
|
43 |
||
44 |
return wt_a.branch, branch_b |
|
45 |
||
46 |
def test_get_parent_invalid(self): |
|
47 |
self.get_parent_and_child() |
|
48 |
||
49 |
# Now change directory, and access the child through http
|
|
50 |
os.chdir('child/path/to') |
|
51 |
branch_b = branch.Branch.open(self.get_readonly_url('b')) |
|
52 |
self.assertRaises(errors.InaccessibleParent, branch_b.get_parent) |
|
53 |
||
54 |
def test_clone_invalid_parent(self): |
|
55 |
self.get_parent_and_child() |
|
56 |
||
57 |
# Now change directory, and access the child through http
|
|
58 |
os.chdir('child/path/to') |
|
59 |
branch_b = branch.Branch.open(self.get_readonly_url('b')) |
|
60 |
||
61 |
branch_c = branch_b.bzrdir.clone('c').open_branch() |
|
62 |
self.assertEqual(None, branch_c.get_parent()) |
|
63 |
||
64 |
def test_sprout_invalid_parent(self): |
|
65 |
self.get_parent_and_child() |
|
66 |
||
67 |
# Now change directory, and access the child through http
|
|
68 |
os.chdir('child/path/to') |
|
69 |
branch_b = branch.Branch.open(self.get_readonly_url('b')) |
|
70 |
||
71 |
branch_c = branch_b.bzrdir.sprout('c').open_branch() |
|
72 |
self.assertEqual(branch_b.base, branch_c.get_parent()) |