~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_fetch.py

  • Committer: mbp at sourcefrog
  • Date: 2006-11-21 01:08:52 UTC
  • mfrom: (2004.1.42 bzr.urllib.keepalive)
  • mto: This revision was merged to the branch mainline in revision 2146.
  • Revision ID: mbp@sourcefrog.net-20061121010852-838b560632acc36c
merge urllib keepalive etc

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
import os
 
18
import re
18
19
import sys
19
20
 
20
21
from bzrlib import bzrdir, repository
236
237
 
237
238
    def _count_log_matches(self, target, logs):
238
239
        """Count the number of times the target file pattern was fetched in an http log"""
239
 
        log_pattern = '%s HTTP/1.1" 200 - "-" "bzr/%s' % \
240
 
            (target, bzrlib.__version__)
 
240
        get_succeeds_re = re.compile(
 
241
            '.*"GET .*%s HTTP/1.1" 20[06] - "-" "bzr/%s' %
 
242
            (     target,                    bzrlib.__version__))
241
243
        c = 0
242
244
        for line in logs:
243
 
            # TODO: perhaps use a regexp instead so we can match more
244
 
            # precisely?
245
 
            if line.find(log_pattern) > -1:
 
245
            if get_succeeds_re.match(line):
246
246
                c += 1
247
247
        return c
248
248
 
257
257
        target = BzrDir.create_branch_and_repo("target/")
258
258
        source = Branch.open(self.get_readonly_url("source/"))
259
259
        self.assertEqual(target.fetch(source), (2, []))
260
 
        log_pattern = '%%s HTTP/1.1" 200 - "-" "bzr/%s' % bzrlib.__version__
261
260
        # this is the path to the literal file. As format changes 
262
261
        # occur it needs to be updated. FIXME: ask the store for the
263
262
        # path.