4797.32.2
by John Arbash Meinel
merge 2.1, resolving NEWS conflict. |
1 |
# Copyright (C) 2009, 2010 Canonical Ltd
|
4585.1.11
by Jelmer Vernooij
Add tests for foreign repository formats. |
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
16 |
||
17 |
||
18 |
"""Tests specific to Repository implementations that use foreign VCS'es."""
|
|
19 |
||
20 |
||
21 |
from bzrlib.tests import ( |
|
22 |
TestCase, |
|
4585.1.16
by Jelmer Vernooij
Add some more basic tests for the repository API. |
23 |
TestCaseWithTransport, |
4585.1.11
by Jelmer Vernooij
Add tests for foreign repository formats. |
24 |
)
|
25 |
||
26 |
||
27 |
class TestRepositoryFormat(TestCase): |
|
28 |
||
29 |
def test_format_string(self): |
|
4585.1.19
by Jelmer Vernooij
Add note about moving tests from per_foreign_vcs into common repository tests. |
30 |
self.assertRaises(NotImplementedError, |
4585.1.11
by Jelmer Vernooij
Add tests for foreign repository formats. |
31 |
self.repository_format.get_format_string) |
32 |
||
33 |
def test_network_name(self): |
|
34 |
self.assertIsInstance(self.repository_format.network_name(), |
|
35 |
str) |
|
36 |
||
37 |
def test_format_description(self): |
|
38 |
self.assertIsInstance(self.repository_format.get_format_description(), |
|
39 |
str) |
|
4585.1.16
by Jelmer Vernooij
Add some more basic tests for the repository API. |
40 |
|
41 |
||
42 |
class ForeignRepositoryFactory(object): |
|
43 |
"""Factory of repository for ForeignRepositoryTests."""
|
|
44 |
||
45 |
def make_repository(self, transport): |
|
4585.1.19
by Jelmer Vernooij
Add note about moving tests from per_foreign_vcs into common repository tests. |
46 |
"""Create a new, valid, repository. May or may not contain
|
4585.1.16
by Jelmer Vernooij
Add some more basic tests for the repository API. |
47 |
data."""
|
48 |
raise NotImplementedError(self.make_repository) |
|
49 |
||
50 |
||
51 |
class ForeignRepositoryTests(TestCaseWithTransport): |
|
52 |
"""Basic tests for foreign repository implementations.
|
|
53 |
||
54 |
These tests mainly make sure that the implementation covers the required
|
|
4585.1.19
by Jelmer Vernooij
Add note about moving tests from per_foreign_vcs into common repository tests. |
55 |
bits of the API and returns semi-reasonable values, that are
|
4585.1.16
by Jelmer Vernooij
Add some more basic tests for the repository API. |
56 |
at least of the expected types and in the expected ranges.
|
57 |
"""
|
|
4585.1.19
by Jelmer Vernooij
Add note about moving tests from per_foreign_vcs into common repository tests. |
58 |
|
59 |
# XXX: Some of these tests could be moved into a common testcase for
|
|
60 |
# both native and foreign repositories.
|
|
61 |
||
4585.1.16
by Jelmer Vernooij
Add some more basic tests for the repository API. |
62 |
repository_factory = None # Set to an instance of ForeignRepositoryFactory by the scenario |
63 |
||
64 |
def make_repository(self): |
|
65 |
return self.repository_factory.make_repository(self.get_transport()) |
|
66 |
||
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) |
|
71 |
||
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()) |
|
76 |
||
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) |
|
81 |
||
82 |
def test_gather_stats(self): |
|
4585.1.19
by Jelmer Vernooij
Add note about moving tests from per_foreign_vcs into common repository tests. |
83 |
"""Test that gather_stats() will at least return a dictionary
|
4585.1.16
by Jelmer Vernooij
Add some more basic tests for the repository API. |
84 |
with the required keys."""
|
85 |
repo = self.make_repository() |
|
86 |
stats = repo.gather_stats() |
|
87 |
self.assertIsInstance(stats, dict) |