~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_repository.py

(jelmer) Add a common base class BzrDirMetaComponentFormat for all formats
 living in bzr meta directories. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
92
92
                              old_format.__class__)
93
93
 
94
94
 
95
 
class SampleRepositoryFormat(repository.RepositoryFormat):
 
95
class SampleRepositoryFormat(repository.RepositoryFormatMetaDir):
96
96
    """A sample format
97
97
 
98
98
    this format is initializable, unsupported to aid in testing the
99
99
    open and open(unsupported=True) routines.
100
100
    """
101
101
 
102
 
    def get_format_string(self):
 
102
    @classmethod
 
103
    def get_format_string(cls):
103
104
        """See RepositoryFormat.get_format_string()."""
104
105
        return "Sample .bzr repository format."
105
106
 
137
138
            dir = format._matchingbzrdir.initialize(url)
138
139
            format.initialize(dir)
139
140
            t = transport.get_transport_from_path(url)
140
 
            found_format = repository.RepositoryFormat.find_format(dir)
 
141
            found_format = repository.RepositoryFormatMetaDir.find_format(dir)
141
142
            self.assertIsInstance(found_format, format.__class__)
142
143
        check_format(repository.format_registry.get_default(), "bar")
143
144
 
144
145
    def test_find_format_no_repository(self):
145
146
        dir = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
146
147
        self.assertRaises(errors.NoRepositoryPresent,
147
 
                          repository.RepositoryFormat.find_format,
 
148
                          repository.RepositoryFormatMetaDir.find_format,
148
149
                          dir)
149
150
 
 
151
    def test_from_string(self):
 
152
        self.assertIsInstance(
 
153
            SampleRepositoryFormat.from_string(
 
154
                "Sample .bzr repository format."),
 
155
            SampleRepositoryFormat)
 
156
        self.assertRaises(ValueError,
 
157
            SampleRepositoryFormat.from_string,
 
158
                "Different .bzr repository format.")
 
159
 
150
160
    def test_find_format_unknown_format(self):
151
161
        dir = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
152
162
        SampleRepositoryFormat().initialize(dir)
153
163
        self.assertRaises(UnknownFormatError,
154
 
                          repository.RepositoryFormat.find_format,
 
164
                          repository.RepositoryFormatMetaDir.find_format,
155
165
                          dir)
156
166
 
157
167
    def test_register_unregister_format(self):
438
448
 
439
449
class TestRepositoryFormat1(knitrepo.RepositoryFormatKnit1):
440
450
 
441
 
    def get_format_string(self):
 
451
    @classmethod
 
452
    def get_format_string(cls):
442
453
        return "Test Format 1"
443
454
 
444
455
 
445
456
class TestRepositoryFormat2(knitrepo.RepositoryFormatKnit1):
446
457
 
447
 
    def get_format_string(self):
 
458
    @classmethod
 
459
    def get_format_string(cls):
448
460
        return "Test Format 2"
449
461
 
450
462