~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/testfetch.py

  • Committer: Robert Collins
  • Date: 2005-09-29 00:24:44 UTC
  • Revision ID: robertc@robertcollins.net-20050929002444-76fe66e99fb9bcd5
reinstate testfetch test case

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
        return False
35
35
 
36
36
 
37
 
 
38
37
class TestFetch(TestCaseInTempDir):
39
 
    def SKIPPED_old_test_fetch(self):
40
 
        """obsolete: new commit code depends on parents being present
41
 
        so the test data no longer suits this test."""
 
38
 
 
39
    def test_fetch(self):
42
40
        
43
41
        def new_branch(name):
44
42
            os.mkdir(name)
58
56
        assert len(br_b.revision_history()) == 7
59
57
        assert greedy_fetch(br_b, br_a, br_a.revision_history()[3])[0] == 1
60
58
        assert has_revision(br_b, br_a.revision_history()[3])
61
 
        assert not has_revision(br_a, br_b.revision_history()[3])
62
 
        assert not has_revision(br_a, br_b.revision_history()[4])
 
59
        assert not has_revision(br_a, br_b.revision_history()[6])
 
60
        assert has_revision(br_a, br_b.revision_history()[5])
63
61
 
64
62
        # When a non-branch ancestor is missing, it should be a failure, not
65
63
        # exception
66
 
        br_a4 = new_branch('br_a4')
67
 
        count, failures = greedy_fetch(br_a4, br_a)
68
 
        assert count == 6
69
 
        assert failures == set((br_b.revision_history()[4],
70
 
                                br_b.revision_history()[5])) 
 
64
        print ("CANNOT TEST MISSING NON REVISION_HISTORY ANCESTORS WITHOUT"
 
65
               " GHOSTS")
 
66
#        br_a4 = new_branch('br_a4')
 
67
#        count, failures = greedy_fetch(br_a4, br_a)
 
68
#        self.assertEqual(count, 6)
 
69
#        self.assertEqual(failures, set((br_b.revision_history()[4],
 
70
#                                        br_b.revision_history()[5]))) 
71
71
 
72
 
        assert greedy_fetch(br_a, br_b)[0] == 4
 
72
        self.assertEqual(greedy_fetch(br_a, br_b)[0], 1)
73
73
        assert has_revision(br_a, br_b.revision_history()[3])
74
74
        assert has_revision(br_a, br_b.revision_history()[4])
75
75
 
83
83
        assert greedy_fetch(br_a2, br_a)[0] == 9
84
84
        assert has_revision(br_a2, br_b.revision_history()[4])
85
85
        assert has_revision(br_a2, br_a.revision_history()[3])
 
86
        assert has_revision(br_a2, br_a.revision_history()[2])
86
87
 
87
88
        br_a3 = new_branch('br_a3')
88
89
        assert greedy_fetch(br_a3, br_a2)[0] == 0
89
90
        for revno in range(4):
90
91
            assert not has_revision(br_a3, br_a.revision_history()[revno])
91
 
        assert greedy_fetch(br_a3, br_a2, br_a.revision_history()[2])[0] == 3
 
92
        self.assertEqual(greedy_fetch(br_a3, br_a2, br_a.revision_history()[2])[0], 3)
92
93
        fetched = greedy_fetch(br_a3, br_a2, br_a.revision_history()[3])[0]
93
94
        assert fetched == 3, "fetched %d instead of 3" % fetched
94
95
        # InstallFailed should be raised if the branch is missing the revision
100
101
        br_a2.append_revision('a-b-c')
101
102
        self.assertRaises(bzrlib.errors.InstallFailed, greedy_fetch, br_a3,
102
103
                          br_a2)
103
 
 
104
 
 
105
 
 
106
 
if __name__ == '__main__':
107
 
    import unittest
108
 
    unittest.main()
109