~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-24 11:26:40 UTC
  • mto: (1852.9.1 Tree.compare().)
  • mto: This revision was merged to the branch mainline in revision 1892.
  • Revision ID: robertc@robertcollins.net-20060724112640-be0b51262ce4a2b6
Implement an InterTreeTestProvider and a trivial test_compare test case.

Show diffs side-by-side

added added

removed removed

Lines of Context:
369
369
            revision_tree_from_workingtree)
370
370
 
371
371
 
 
372
class TestInterTreeProviderAdapter(TestCase):
 
373
    """A group of tests that test the InterTreeTestAdapter."""
 
374
 
 
375
    def test_adapted_tests(self):
 
376
        # check that constructor parameters are passed through to the adapted
 
377
        # test.
 
378
        # for InterTree tests we want the machinery to bring up two trees in
 
379
        # each instance: the base one, and the one we are interacting with.
 
380
        # because each optimiser can be direction specific, we need to test
 
381
        # each optimiser in its chosen direction.
 
382
        # unlike the TestProviderAdapter we dont want to automatically add a
 
383
        # parameterised one for WorkingTree - the optimisers will tell us what
 
384
        # ones to add.
 
385
        from bzrlib.tests.tree_implementations import (
 
386
            return_parameter,
 
387
            revision_tree_from_workingtree
 
388
            )
 
389
        from bzrlib.tests.intertree_implementations import (
 
390
            InterTreeTestProviderAdapter,
 
391
            )
 
392
        from bzrlib.workingtree import WorkingTreeFormat2, WorkingTreeFormat3
 
393
        input_test = TestInterTreeProviderAdapter(
 
394
            "test_adapted_tests")
 
395
        server1 = "a"
 
396
        server2 = "b"
 
397
        format1 = WorkingTreeFormat2()
 
398
        format2 = WorkingTreeFormat3()
 
399
        formats = [(str, format1, format2, False, True),
 
400
            (int, format2, format1, False, True)]
 
401
        adapter = InterTreeTestProviderAdapter(server1, server2, formats)
 
402
        suite = adapter.adapt(input_test)
 
403
        tests = list(iter(suite))
 
404
        self.assertEqual(2, len(tests))
 
405
        self.assertEqual(tests[0].intertree_class, formats[0][0])
 
406
        self.assertEqual(tests[0].workingtree_format, formats[0][1])
 
407
        self.assertEqual(tests[0].workingtree_to_test_tree, formats[0][2])
 
408
        self.assertEqual(tests[0].workingtree_format_to, formats[0][3])
 
409
        self.assertEqual(tests[0].workingtree_to_test_tree_to, formats[0][4])
 
410
        self.assertEqual(tests[0].transport_server, server1)
 
411
        self.assertEqual(tests[0].transport_readonly_server, server2)
 
412
        self.assertEqual(tests[1].intertree_class, formats[1][0])
 
413
        self.assertEqual(tests[1].workingtree_format, formats[1][1])
 
414
        self.assertEqual(tests[1].workingtree_to_test_tree, formats[1][2])
 
415
        self.assertEqual(tests[1].workingtree_format_to, formats[1][3])
 
416
        self.assertEqual(tests[1].workingtree_to_test_tree_to, formats[1][4])
 
417
        self.assertEqual(tests[1].transport_server, server1)
 
418
        self.assertEqual(tests[1].transport_readonly_server, server2)
 
419
 
372
420
class TestTestCaseWithTransport(TestCaseWithTransport):
373
421
    """Tests for the convenience functions TestCaseWithTransport introduces."""
374
422