DXR is a code search and navigation tool aimed at making sense of large projects. It supports full-text and regex searches as well as structural queries.

Untracked file

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
"""The test case itsself, and associated stuff"""

import string

class BaseTest:
    def __init__(self):
        self.res = -1
        self.reason = None
    
    def parse_config(self, config):
        self.files = []

        for line in config.readlines():
            line = string.strip(line)
            self.files.append({'file': line, 'read': 0})

    baseName = 'index'

    def verify_request(self, req):
        """Check that the request is valid.

        Also needs to update any internal 'read' stuff"""
        
        ## XXXXX
        ## This needs to be done using exceptions, maybe
        ## XXXXX
        
        for i in self.files:
            if i['file'] == req.fname:
                if i['read'] == 1:
                    self.res = 0
                    self.reason = "File %s was read twice" % (req.fname)
                    return 0
                i['read'] = 1
                break
            elif i['read'] == 0:
                self.res = 0
                self.reason = "File %s requested, expected %s" % (req.fname, i['file'])
                return 0

        ### Simplistic for now...
        res = req.headers.getheader('Host')

        return res

    def result(self):
        if self.res == -1:
            for i in self.files:
                if i['read'] == 0:
                    self.res = 0
                    self.reason = "%s not read" % (i['file'])
                    return self.res, self.reason
            self.res = 1
            
        return self.res, self.reason

tester = BaseTest