Implemented SvnWorkingTreeDir.needs_format_conversion().
[jelmer/subvertpy.git] / tests / test_checkout.py
1 # Copyright (C) 2006-2007 Jelmer Vernooij <jelmer@samba.org>
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 """Checkout tests."""
18
19 from bzrlib.bzrdir import BzrDir
20 from bzrlib.errors import NoRepositoryPresent
21 from bzrlib.tests import TestCase
22
23 from convert import SvnConverter
24 from bzrlib.plugins.svn.workingtree import (SvnWorkingTreeFormat, 
25                                             SvnWorkingTreeDirFormat)
26 from tests import TestCaseWithSubversionRepository
27
28 class TestWorkingTreeFormat(TestCase):
29     def setUp(self):
30         super(TestWorkingTreeFormat, self).setUp()
31         self.format = SvnWorkingTreeFormat()
32
33     def test_get_format_desc(self):
34         self.assertEqual("Subversion Working Copy", 
35                          self.format.get_format_description())
36
37     def test_initialize(self):
38         self.assertRaises(NotImplementedError, self.format.initialize, None)
39
40     def test_open(self):
41         self.assertRaises(NotImplementedError, self.format.open, None)
42
43 class TestCheckoutFormat(TestCase):
44     def setUp(self):
45         super(TestCheckoutFormat, self).setUp()
46         self.format = SvnWorkingTreeDirFormat()
47
48     def test_get_converter(self):
49         self.assertIsInstance(self.format.get_converter(), SvnConverter)
50
51
52 class TestCheckout(TestCaseWithSubversionRepository):
53     def test_not_for_writing(self):
54         self.make_client("d", "dc")
55         x = self.create_branch_convenience("dc/foo")
56         self.assertFalse(hasattr(x.repository, "uuid"))
57
58     def test_open_repository(self):
59         self.make_client("d", "dc")
60         x = self.open_checkout_bzrdir("dc")
61         self.assertRaises(NoRepositoryPresent, x.open_repository)
62
63     def test_find_repository(self):
64         self.make_client("d", "dc")
65         x = self.open_checkout_bzrdir("dc")
66         self.assertTrue(hasattr(x.find_repository(), "uuid"))
67
68     def test_needs_format_conversion_default(self):
69         self.make_client("d", "dc")
70         x = self.open_checkout_bzrdir("dc")
71         self.assertTrue(x.needs_format_conversion())
72
73     def test_needs_format_conversion_self(self):
74         self.make_client("d", "dc")
75         x = self.open_checkout_bzrdir("dc")
76         self.assertFalse(x.needs_format_conversion(SvnWorkingTreeDirFormat()))
77