tests/test-hgweb-no-request-uri
changeset 5579 e15f7db0f0ee
child 5580 f429e0e067a8
equal deleted inserted replaced
5578:733b50883f73 5579:e15f7db0f0ee
       
     1 #!/bin/sh
       
     2 
       
     3 mkdir repo
       
     4 cd repo
       
     5 hg init
       
     6 echo foo > bar
       
     7 hg add bar
       
     8 hg commit -m "test" -d "0 0" -u "Testing"
       
     9 hg tip
       
    10 
       
    11 cat > request.py <<EOF
       
    12 from mercurial.hgweb import hgweb, hgwebdir
       
    13 from StringIO import StringIO
       
    14 import os, sys
       
    15 
       
    16 errors = StringIO()
       
    17 input = StringIO()
       
    18 
       
    19 def startrsp(headers, data):
       
    20 	print '---- HEADERS'
       
    21 	print headers
       
    22 	print '---- DATA'
       
    23 	print data
       
    24 	return output.write
       
    25 
       
    26 env = {
       
    27 	'wsgi.version': (1, 0),
       
    28 	'wsgi.url_scheme': 'http',
       
    29 	'wsgi.errors': errors,
       
    30 	'wsgi.input': input,
       
    31 	'wsgi.multithread': False,
       
    32 	'wsgi.multiprocess': False,
       
    33 	'wsgi.run_once': False,
       
    34 	'REQUEST_METHOD': 'GET',
       
    35 	'SCRIPT_NAME': '',
       
    36 	'SERVER_NAME': '127.0.0.1',
       
    37 	'SERVER_PORT': os.environ['HGPORT'],
       
    38 	'SERVER_PROTOCOL': 'HTTP/1.0'
       
    39 }
       
    40 
       
    41 output = StringIO()
       
    42 env['PATH_INFO'] = '/'
       
    43 env['QUERY_STRING'] = 'style=atom'
       
    44 hgweb('.', name = 'repo')(env, startrsp)
       
    45 print output.getvalue()
       
    46 print '---- ERRORS'
       
    47 print errors.getvalue()
       
    48 
       
    49 output = StringIO()
       
    50 env['PATH_INFO'] = '/file/tip/'
       
    51 env['QUERY_STRING'] = 'style=raw'
       
    52 hgweb('.', name = 'repo')(env, startrsp)
       
    53 print output.getvalue()
       
    54 print '---- ERRORS'
       
    55 print errors.getvalue()
       
    56 
       
    57 output = StringIO()
       
    58 env['PATH_INFO'] = '/'
       
    59 env['QUERY_STRING'] = 'style=raw'
       
    60 hgwebdir({'repo': '.'})(env, startrsp)
       
    61 print output.getvalue()
       
    62 print '---- ERRORS'
       
    63 print errors.getvalue()
       
    64 
       
    65 output = StringIO()
       
    66 env['PATH_INFO'] = '/repo/file/tip/'
       
    67 env['QUERY_STRING'] = 'style=raw'
       
    68 hgwebdir({'repo': '.'})(env, startrsp)
       
    69 print output.getvalue()
       
    70 print '---- ERRORS'
       
    71 print errors.getvalue()
       
    72 EOF
       
    73 
       
    74 python request.py | sed "s/http:\/\/127\.0\.0\.1:[0-9]*\//http:\/\/127.0.0.1\//"