~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_foreign_vcs/test_repository.py

  • Committer: Alexander Belchenko
  • Date: 2006-07-30 16:43:12 UTC
  • mto: (1711.2.111 jam-integration)
  • mto: This revision was merged to the branch mainline in revision 1906.
  • Revision ID: bialix@ukr.net-20060730164312-b025fd3ff0cee59e
rename  gpl.txt => COPYING.txt

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2009, 2010 Canonical Ltd
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,
23
 
    TestCaseWithTransport,
24
 
    )
25
 
 
26
 
 
27
 
class TestRepositoryFormat(TestCase):
28
 
 
29
 
    def test_format_string(self):
30
 
        self.assertRaises(NotImplementedError,
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)
40
 
 
41
 
 
42
 
class ForeignRepositoryFactory(object):
43
 
    """Factory of repository for ForeignRepositoryTests."""
44
 
 
45
 
    def make_repository(self, transport):
46
 
        """Create a new, valid, repository. May or may not contain
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
55
 
    bits of the API and returns semi-reasonable values, that are
56
 
    at least of the expected types and in the expected ranges.
57
 
    """
58
 
 
59
 
    # XXX: Some of these tests could be moved into a common testcase for
60
 
    # both native and foreign repositories.
61
 
 
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):
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"))