1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# Copyright (C) 2009, 2010 Canonical Ltd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
"""Tests specific to Repository implementations that use foreign VCS'es."""
from bzrlib.tests import (
TestCase,
TestCaseWithTransport,
)
class TestRepositoryFormat(TestCase):
def test_format_string(self):
self.assertRaises(NotImplementedError,
self.repository_format.get_format_string)
def test_network_name(self):
self.assertIsInstance(self.repository_format.network_name(),
str)
def test_format_description(self):
self.assertIsInstance(self.repository_format.get_format_description(),
str)
class ForeignRepositoryFactory(object):
"""Factory of repository for ForeignRepositoryTests."""
def make_repository(self, transport):
"""Create a new, valid, repository. May or may not contain
data."""
raise NotImplementedError(self.make_repository)
class ForeignRepositoryTests(TestCaseWithTransport):
"""Basic tests for foreign repository implementations.
These tests mainly make sure that the implementation covers the required
bits of the API and returns semi-reasonable values, that are
at least of the expected types and in the expected ranges.
"""
# XXX: Some of these tests could be moved into a common testcase for
# both native and foreign repositories.
repository_factory = None # Set to an instance of ForeignRepositoryFactory by the scenario
def make_repository(self):
return self.repository_factory.make_repository(self.get_transport())
def test_make_working_trees(self):
"""Test that Repository.make_working_trees() returns a boolean."""
repo = self.make_repository()
self.assertIsInstance(repo.make_working_trees(), bool)
def test_get_physical_lock_status(self):
"""Test that a new repository is not locked by default."""
repo = self.make_repository()
self.assertFalse(repo.get_physical_lock_status())
def test_is_shared(self):
"""Test that is_shared() returns a bool."""
repo = self.make_repository()
self.assertIsInstance(repo.is_shared(), bool)
def test_gather_stats(self):
"""Test that gather_stats() will at least return a dictionary
with the required keys."""
repo = self.make_repository()
stats = repo.gather_stats()
self.assertIsInstance(stats, dict)
|