~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_repository.py

  • Committer: Patch Queue Manager
  • Date: 2011-12-22 18:52:58 UTC
  • mfrom: (6213.1.55 feature-flags)
  • Revision ID: pqm@pqm.ubuntu.com-20111222185258-wgcba8590pbw5sf1
(jelmer) Add support for feature flags in bzr formats. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
153
153
            SampleRepositoryFormat.from_string(
154
154
                "Sample .bzr repository format."),
155
155
            SampleRepositoryFormat)
156
 
        self.assertRaises(ValueError,
 
156
        self.assertRaises(AssertionError,
157
157
            SampleRepositoryFormat.from_string,
158
158
                "Different .bzr repository format.")
159
159
 
164
164
                          repository.RepositoryFormatMetaDir.find_format,
165
165
                          dir)
166
166
 
 
167
    def test_find_format_with_features(self):
 
168
        tree = self.make_branch_and_tree('.', format='2a')
 
169
        tree.branch.repository.control_transport.put_bytes('format',
 
170
            tree.branch.repository._format.get_format_string() +
 
171
            "necessity name\n")
 
172
        found_format = repository.RepositoryFormatMetaDir.find_format(tree.bzrdir)
 
173
        self.assertIsInstance(found_format, repository.RepositoryFormatMetaDir)
 
174
        self.assertEquals(found_format.features.get("name"), "necessity")
 
175
        self.assertRaises(errors.MissingFeature, found_format.check_support_status,
 
176
            True)
 
177
        self.addCleanup(repository.RepositoryFormatMetaDir.unregister_feature,
 
178
            "name")
 
179
        repository.RepositoryFormatMetaDir.register_feature("name")
 
180
        found_format.check_support_status(True)
 
181
 
167
182
    def test_register_unregister_format(self):
168
183
        # Test deprecated format registration functions
169
184
        format = SampleRepositoryFormat()
1703
1718
        lazy = repository._LazyListJoin(['a'], ['b'])
1704
1719
        self.assertEqual("bzrlib.repository._LazyListJoin((['a'], ['b']))",
1705
1720
                         repr(lazy))
 
1721
 
 
1722
 
 
1723
class TestFeatures(tests.TestCaseWithTransport):
 
1724
 
 
1725
    def test_open_with_present_feature(self):
 
1726
        self.addCleanup(
 
1727
            repository.RepositoryFormatMetaDir.unregister_feature,
 
1728
            "makes-cheese-sandwich")
 
1729
        repository.RepositoryFormatMetaDir.register_feature(
 
1730
            "makes-cheese-sandwich")
 
1731
        repo = self.make_repository('.')
 
1732
        repo.lock_write()
 
1733
        repo._format.features["makes-cheese-sandwich"] = "required"
 
1734
        repo._format.check_support_status(False)
 
1735
        repo.unlock()
 
1736
 
 
1737
    def test_open_with_missing_required_feature(self):
 
1738
        repo = self.make_repository('.')
 
1739
        repo.lock_write()
 
1740
        repo._format.features["makes-cheese-sandwich"] = "required"
 
1741
        self.assertRaises(errors.MissingFeature,
 
1742
            repo._format.check_support_status, False)