tests/test_utils.py
changeset 2914 4f821debda33
parent 1765 2c7137e62a01
equal deleted inserted replaced
2913:764b8812d3e8 2914:4f821debda33
    17 """
    17 """
    18 
    18 
    19 
    19 
    20 __authors__ = [
    20 __authors__ = [
    21   '"Augie Fackler" <durin42@gmail.com>',
    21   '"Augie Fackler" <durin42@gmail.com>',
       
    22   '"Sverre Rabbelier" <sverre@rabbelier.nl>',
    22   ]
    23   ]
       
    24 
       
    25 
       
    26 from soc.modules import callback
    23 
    27 
    24 
    28 
    25 class MockRequest(object):
    29 class MockRequest(object):
    26   """Shared dummy request object to mock common aspects of a request.
    30   """Shared dummy request object to mock common aspects of a request.
       
    31 
       
    32   Before using the object, start should be called, when done (and
       
    33   before calling start on a new request), end should be called.
    27   """
    34   """
       
    35 
    28   def __init__(self, path=None):
    36   def __init__(self, path=None):
    29     self.REQUEST = self.GET = self.POST = {}
    37     """Creates a new empty request object.
       
    38 
       
    39     self.REQUEST, self.GET and self.POST are set to an empty
       
    40     dictionary, and path to the value specified.
       
    41     """
       
    42 
       
    43     self.REQUEST = {}
       
    44     self.GET = {}
       
    45     self.POST = {}
    30     self.path = path
    46     self.path = path
       
    47 
       
    48   def start(self):
       
    49     """Readies the core for a new request.
       
    50     """
       
    51 
       
    52     core = callback.getCore()
       
    53     core.startNewRequest(self)
       
    54 
       
    55   def end(self):
       
    56     """Finishes up the current request.
       
    57     """
       
    58 
       
    59     core = callback.getCore()
       
    60     core.endRequest(self, False)