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
|
# Copyright 2009 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Tests of the branch interface."""
__metaclass__ = type
from unittest import TestLoader
from bzrlib.branch import BranchFormat as BzrBranchFormat
from bzrlib.bzrdir import BzrDirFormat
from bzrlib.repository import format_registry as repo_format_registry
from lp.code.bzr import (
BranchFormat,
ControlFormat,
RepositoryFormat,
)
from lp.testing import TestCase
class TestFormatSupport(TestCase):
"""Ensure the launchpad format list is up-to-date.
While ideally we would ensure that the lists of markers were the same,
early branch and repo formats did not use markers. (The branch/repo
was implied by the control dir format.)
"""
def test_control_format_complement(self):
self.bzrlib_is_subset(BzrDirFormat._formats.keys(), ControlFormat)
def test_branch_format_complement(self):
self.bzrlib_is_subset(BzrBranchFormat._formats.keys(), BranchFormat)
def test_repository_format_complement(self):
self.bzrlib_is_subset(repo_format_registry.keys(), RepositoryFormat)
def bzrlib_is_subset(self, bzrlib_formats, launchpad_enum):
"""Ensure the bzr format marker list is a subset of launchpad."""
bzrlib_format_strings = set(bzrlib_formats)
launchpad_format_strings = set(format.title for format
in launchpad_enum.items)
self.assertEqual(
set(), bzrlib_format_strings.difference(launchpad_format_strings))
def test_repositoryDescriptions(self):
self.checkDescriptions(RepositoryFormat)
def test_branchDescriptions(self):
self.checkDescriptions(BranchFormat)
def test_controlDescriptions(self):
self.checkDescriptions(ControlFormat)
def checkDescriptions(self, format_enums):
for item in format_enums.items:
description = item.description
if description.endswith('\n'):
description = description[:-1]
self.assertTrue(len(description.split('\n')) == 1,
item.description)
def test_suite():
return TestLoader().loadTestsFromName(__name__)
|