~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_repository.py

  • Committer: Jelmer Vernooij
  • Date: 2011-11-24 03:05:23 UTC
  • mto: This revision was merged to the branch mainline in revision 6404.
  • Revision ID: jelmer@samba.org-20111124030523-zug6ls78xy95jnco
Feature support in repository.

Show diffs side-by-side

added added

removed removed

Lines of Context:
115
115
    def open(self, a_bzrdir, _found=False):
116
116
        return "opened repository."
117
117
 
 
118
    @classmethod
 
119
    def from_string(cls, format_string):
 
120
        return cls()
 
121
 
118
122
 
119
123
class SampleExtraRepositoryFormat(repository.RepositoryFormat):
120
124
    """A sample format that can not be used in a metadir
137
141
            dir = format._matchingbzrdir.initialize(url)
138
142
            format.initialize(dir)
139
143
            t = transport.get_transport_from_path(url)
140
 
            found_format = repository.RepositoryFormat.find_format(dir)
 
144
            found_format = repository.MetaDirRepositoryFormat.find_format(dir)
141
145
            self.assertIsInstance(found_format, format.__class__)
142
146
        check_format(repository.format_registry.get_default(), "bar")
143
147
 
144
148
    def test_find_format_no_repository(self):
145
149
        dir = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
146
150
        self.assertRaises(errors.NoRepositoryPresent,
147
 
                          repository.RepositoryFormat.find_format,
 
151
                          repository.MetaDirRepositoryFormat.find_format,
148
152
                          dir)
149
153
 
150
154
    def test_find_format_unknown_format(self):
151
155
        dir = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
152
156
        SampleRepositoryFormat().initialize(dir)
153
157
        self.assertRaises(UnknownFormatError,
154
 
                          repository.RepositoryFormat.find_format,
 
158
                          repository.MetaDirRepositoryFormat.find_format,
155
159
                          dir)
156
160
 
 
161
    def test_find_format_with_features(self):
 
162
        tree = self.make_branch_and_tree('.', format='2a')
 
163
        tree.branch.repository.control_transport.put_bytes('format',
 
164
            tree.branch.repository._format.get_format_string() +
 
165
            "feature\tnecessity\n")
 
166
        found_format = repository.MetaDirRepositoryFormat.find_format(tree.bzrdir)
 
167
        self.assertIsInstance(found_format, repository.MetaDirRepositoryFormat)
 
168
        self.assertEquals(
 
169
            found_format.features.get_feature("feature"),
 
170
            "necessity")
 
171
 
157
172
    def test_register_unregister_format(self):
158
173
        # Test deprecated format registration functions
159
174
        format = SampleRepositoryFormat()
438
453
 
439
454
class TestRepositoryFormat1(knitrepo.RepositoryFormatKnit1):
440
455
 
441
 
    def get_format_string(self):
 
456
    @classmethod
 
457
    def get_format_string(cls):
442
458
        return "Test Format 1"
443
459
 
444
460
 
445
461
class TestRepositoryFormat2(knitrepo.RepositoryFormatKnit1):
446
462
 
447
 
    def get_format_string(self):
 
463
    @classmethod
 
464
    def get_format_string(cls):
448
465
        return "Test Format 2"
449
466
 
450
467