~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 02:01:49 UTC
  • Revision ID: robertc@robertcollins.net-20050929020149-1ff16722c6a01b2c
reenable remotebranch tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
from bzrlib.fetch import greedy_fetch
25
25
 
26
26
from bzrlib.selftest import TestCaseInTempDir
27
 
from bzrlib.selftest.HTTPTestUtil import TestCaseWithWebserver
28
27
 
29
28
 
30
29
def has_revision(branch, revision_id):
55
54
    assert not has_revision(br_a, br_b.revision_history()[6])
56
55
    assert has_revision(br_a, br_b.revision_history()[5])
57
56
 
58
 
    # When a non-branch ancestor is missing, it should be unlisted...
59
 
    # as its not reference from the inventory weave.
60
 
    br_b4 = new_branch('br_4')
61
 
    count, failures = greedy_fetch(br_b4, br_b)
62
 
    self.assertEqual(count, 7)
63
 
    self.assertEqual(failures, [])
 
57
    # When a non-branch ancestor is missing, it should be a failure, not
 
58
    # exception
 
59
    print ("CANNOT TEST MISSING NON REVISION_HISTORY ANCESTORS WITHOUT"
 
60
           " GHOSTS")
 
61
#    br_a4 = new_branch('br_a4')
 
62
#    count, failures = greedy_fetch(br_a4, br_a)
 
63
#    self.assertEqual(count, 6)
 
64
#    self.assertEqual(failures, set((br_b.revision_history()[4],
 
65
#                                    br_b.revision_history()[5]))) 
64
66
 
65
67
    self.assertEqual(greedy_fetch(writable_a, br_b)[0], 1)
66
68
    assert has_revision(br_a, br_b.revision_history()[3])
99
101
class TestFetch(TestCaseInTempDir):
100
102
 
101
103
    def test_fetch(self):
 
104
        
102
105
        #highest indices a: 5, b: 7
103
106
        br_a, br_b = make_branches()
104
107
        fetch_steps(self, br_a, br_b, br_a)
105
 
 
106
 
 
107
 
class TestHttpFetch(TestCaseWithWebserver):
108
 
 
109
 
    def setUp(self):
110
 
        super(TestHttpFetch, self).setUp()
111
 
        self.weblogs = []
112
 
 
113
 
    def test_fetch(self):
114
 
        #highest indices a: 5, b: 7
115
 
        br_a, br_b = make_branches()
116
 
        br_rem_a = Branch.open(self.get_remote_url(br_a._transport.base))
117
 
        fetch_steps(self, br_rem_a, br_b, br_a)
118
 
 
119
 
    def log(self, *args):
120
 
        """Capture web server log messages for introspection."""
121
 
        super(TestHttpFetch, self).log(*args)
122
 
        if args[0].startswith("webserver"):
123
 
            self.weblogs.append(args[0])
124
 
 
125
 
    def test_weaves_are_retrieved_once(self):
126
 
        self.build_tree(("source/", "source/file", "target/"))
127
 
        branch = Branch.initialize("source")
128
 
        branch.add(["file"], ["id"])
129
 
        branch.commit("added file")
130
 
        print >>open("source/file", 'w'), "blah"
131
 
        branch.commit("changed file")
132
 
        target = Branch.initialize("target/")
133
 
        source = Branch.open(self.get_remote_url("source/"))
134
 
        source.weave_store.enable_cache = False
135
 
        self.assertEqual(greedy_fetch(target, source), (2, []))
136
 
        weave_suffix = 'weaves/id.weave HTTP/1.1" 200 -'
137
 
        self.assertEqual(1,
138
 
            len([log for log in self.weblogs if log.endswith(weave_suffix)]))