~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to tests/test_rspush.py

  • Committer: Aaron Bentley
  • Date: 2007-12-22 02:01:03 UTC
  • Revision ID: aaron.bentley@utoronto.ca-20071222020103-ggjszok7n974e1l2
Update branches, multi-pull to new APIs, create trees

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2007 Aaron Bentley
 
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
 
 
18
from bzrlib.bzrdir import BzrDir
 
19
from bzrlib.tests import TestCaseWithTransport
 
20
 
 
21
from bzrlib.plugins.bzrtools.bzrtools import rspush, NotStandalone
 
22
 
 
23
 
 
24
class MockRSync(object):
 
25
 
 
26
    def __init__(self):
 
27
        self.calls = []
 
28
 
 
29
    def __call__(self, source, target, **kwargs):
 
30
        self.calls.append((source, target, kwargs))
 
31
        if target.endswith('revision-history'):
 
32
            output = open(target, 'wb')
 
33
            output.close()
 
34
 
 
35
 
 
36
class TestRSPush(TestCaseWithTransport):
 
37
 
 
38
    def test_rspush_locking(self):
 
39
        tree = self.make_branch_and_tree('tree', format='dirstate-tags')
 
40
        tree.commit('some changes')
 
41
        mock_rsync = MockRSync()
 
42
        rspush(tree, 'example.org:foo', _rsync=mock_rsync)
 
43
        rspush(tree, 'example.org:foo', working_tree = False,
 
44
               _rsync=mock_rsync)
 
45
        tree2 = self.make_branch_and_tree('tree2',
 
46
                                          format='pack-0.92')
 
47
        rspush(tree2, 'example.org:foo', _rsync=mock_rsync)
 
48
 
 
49
    def test_refuse_lightweight_checkout(self):
 
50
        branch = self.make_branch('tree')
 
51
        checkout = branch.create_checkout('checkout', lightweight=True)
 
52
        checkout.commit('some changes')
 
53
        mock_rsync = MockRSync()
 
54
        self.assertRaises(NotStandalone, rspush, checkout, 'example.org:foo',
 
55
                          _rsync=mock_rsync)
 
56
 
 
57
    def test_refuse_checkout(self):
 
58
        branch = self.make_branch('tree')
 
59
        checkout = branch.create_checkout('checkout')
 
60
        checkout.commit('some changes')
 
61
        mock_rsync = MockRSync()
 
62
        self.assertRaises(NotStandalone, rspush, checkout, 'example.org:foo',
 
63
                          _rsync=mock_rsync)
 
64
 
 
65
    def test_refuse_shared(self):
 
66
        repo = self.make_repository('repo', shared=True)
 
67
        bzrdir = BzrDir.open('repo')
 
68
        bzrdir.create_branch()
 
69
        bzrdir.create_workingtree()
 
70
        tree = bzrdir.open_workingtree()
 
71
        tree.commit('some changes')
 
72
        mock_rsync = MockRSync()
 
73
        self.assertRaises(NotStandalone, rspush, tree, 'example.org:foo',
 
74
                          _rsync=mock_rsync)