1
# Copyright (C) 2009, 2010 Canonical Ltd
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.
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.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
"""Tests specific to Repository implementations that use foreign VCS'es."""
21
from bzrlib.tests import (
23
TestCaseWithTransport,
27
class TestRepositoryFormat(TestCase):
29
def test_format_string(self):
30
self.assertRaises(NotImplementedError,
31
self.repository_format.get_format_string)
33
def test_network_name(self):
34
self.assertIsInstance(self.repository_format.network_name(),
37
def test_format_description(self):
38
self.assertIsInstance(self.repository_format.get_format_description(),
42
class ForeignRepositoryFactory(object):
43
"""Factory of repository for ForeignRepositoryTests."""
45
def make_repository(self, transport):
46
"""Create a new, valid, repository. May or may not contain
48
raise NotImplementedError(self.make_repository)
51
class ForeignRepositoryTests(TestCaseWithTransport):
52
"""Basic tests for foreign repository implementations.
54
These tests mainly make sure that the implementation covers the required
55
bits of the API and returns semi-reasonable values, that are
56
at least of the expected types and in the expected ranges.
59
# XXX: Some of these tests could be moved into a common testcase for
60
# both native and foreign repositories.
62
repository_factory = None # Set to an instance of ForeignRepositoryFactory by the scenario
64
def make_repository(self):
65
return self.repository_factory.make_repository(self.get_transport())
67
def test_make_working_trees(self):
68
"""Test that Repository.make_working_trees() returns a boolean."""
69
repo = self.make_repository()
70
self.assertIsInstance(repo.make_working_trees(), bool)
72
def test_get_physical_lock_status(self):
73
"""Test that a new repository is not locked by default."""
74
repo = self.make_repository()
75
self.assertFalse(repo.get_physical_lock_status())
77
def test_is_shared(self):
78
"""Test that is_shared() returns a bool."""
79
repo = self.make_repository()
80
self.assertIsInstance(repo.is_shared(), bool)
82
def test_gather_stats(self):
83
"""Test that gather_stats() will at least return a dictionary
84
with the required keys."""
85
repo = self.make_repository()
86
stats = repo.gather_stats()
87
self.assertIsInstance(stats, dict)
88
self.assertTrue(stats.has_key("revisions"))