~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_repository.py

  • Committer: Martin Packman
  • Date: 2012-01-05 10:44:12 UTC
  • mfrom: (6424 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6427.
  • Revision ID: martin.packman@canonical.com-20120105104412-z03fi9m43h946fvs
Merge bzr.dev to resolve conflicts

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.update_feature_flags({"name": "necessity"})
 
170
        found_format = repository.RepositoryFormatMetaDir.find_format(tree.bzrdir)
 
171
        self.assertIsInstance(found_format, repository.RepositoryFormatMetaDir)
 
172
        self.assertEquals(found_format.features.get("name"), "necessity")
 
173
        self.assertRaises(errors.MissingFeature, found_format.check_support_status,
 
174
            True)
 
175
        self.addCleanup(repository.RepositoryFormatMetaDir.unregister_feature,
 
176
            "name")
 
177
        repository.RepositoryFormatMetaDir.register_feature("name")
 
178
        found_format.check_support_status(True)
 
179
 
167
180
    def test_register_unregister_format(self):
168
181
        # Test deprecated format registration functions
169
182
        format = SampleRepositoryFormat()
1703
1716
        lazy = repository._LazyListJoin(['a'], ['b'])
1704
1717
        self.assertEqual("bzrlib.repository._LazyListJoin((['a'], ['b']))",
1705
1718
                         repr(lazy))
 
1719
 
 
1720
 
 
1721
class TestFeatures(tests.TestCaseWithTransport):
 
1722
 
 
1723
    def test_open_with_present_feature(self):
 
1724
        self.addCleanup(
 
1725
            repository.RepositoryFormatMetaDir.unregister_feature,
 
1726
            "makes-cheese-sandwich")
 
1727
        repository.RepositoryFormatMetaDir.register_feature(
 
1728
            "makes-cheese-sandwich")
 
1729
        repo = self.make_repository('.')
 
1730
        repo.lock_write()
 
1731
        repo._format.features["makes-cheese-sandwich"] = "required"
 
1732
        repo._format.check_support_status(False)
 
1733
        repo.unlock()
 
1734
 
 
1735
    def test_open_with_missing_required_feature(self):
 
1736
        repo = self.make_repository('.')
 
1737
        repo.lock_write()
 
1738
        repo._format.features["makes-cheese-sandwich"] = "required"
 
1739
        self.assertRaises(errors.MissingFeature,
 
1740
            repo._format.check_support_status, False)