~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_selftest.py

  • Committer: Robert Collins
  • Date: 2006-07-20 13:00:31 UTC
  • mto: (1852.9.1 Tree.compare().)
  • mto: This revision was merged to the branch mainline in revision 1890.
  • Revision ID: robertc@robertcollins.net-20060720130031-d26103a427ea10f3
StartĀ treeĀ implementationĀ tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
323
323
        self.assertEqual(tests[1].transport_readonly_server, server2)
324
324
 
325
325
 
 
326
class TestTreeProviderAdapter(TestCase):
 
327
    """Test the setup of tree_implementation tests."""
 
328
 
 
329
    def test_adapted_tests(self):
 
330
        # the tree implementation adapter is meant to setup one instance for
 
331
        # each working tree format, and one additional instance that will
 
332
        # use the default wt format, but create a revision tree for the tests.
 
333
        # this means that the wt ones should have the workingtree_to_test_tree
 
334
        # attribute set to 'return_parameter' and the revision one set to
 
335
        # revision_tree_from_workingtree.
 
336
 
 
337
        from bzrlib.tests.tree_implementations import (
 
338
            TreeTestProviderAdapter,
 
339
            return_parameter,
 
340
            revision_tree_from_workingtree
 
341
            )
 
342
        from bzrlib.workingtree import WorkingTreeFormat
 
343
        input_test = TestTreeProviderAdapter(
 
344
            "test_adapted_tests")
 
345
        server1 = "a"
 
346
        server2 = "b"
 
347
        formats = [("c", "C"), ("d", "D")]
 
348
        adapter = TreeTestProviderAdapter(server1, server2, formats)
 
349
        suite = adapter.adapt(input_test)
 
350
        tests = list(iter(suite))
 
351
        self.assertEqual(3, len(tests))
 
352
        default_format = WorkingTreeFormat.get_default_format()
 
353
        self.assertEqual(tests[0].workingtree_format, formats[0][0])
 
354
        self.assertEqual(tests[0].bzrdir_format, formats[0][1])
 
355
        self.assertEqual(tests[0].transport_server, server1)
 
356
        self.assertEqual(tests[0].transport_readonly_server, server2)
 
357
        self.assertEqual(tests[0].workingtree_to_test_tree, return_parameter)
 
358
        self.assertEqual(tests[1].workingtree_format, formats[1][0])
 
359
        self.assertEqual(tests[1].bzrdir_format, formats[1][1])
 
360
        self.assertEqual(tests[1].transport_server, server1)
 
361
        self.assertEqual(tests[1].transport_readonly_server, server2)
 
362
        self.assertEqual(tests[1].workingtree_to_test_tree, return_parameter)
 
363
        self.assertEqual(tests[2].workingtree_format, default_format)
 
364
        self.assertEqual(tests[2].bzrdir_format, default_format._matchingbzrdir)
 
365
        self.assertEqual(tests[2].transport_server, server1)
 
366
        self.assertEqual(tests[2].transport_readonly_server, server2)
 
367
        self.assertEqual(tests[2].workingtree_to_test_tree,
 
368
            revision_tree_from_workingtree)
 
369
 
 
370
 
326
371
class TestTestCaseWithTransport(TestCaseWithTransport):
327
372
    """Tests for the convenience functions TestCaseWithTransport introduces."""
328
373