~michael.nelson/lazr.restful/663155-fix-django-settings-import

« back to all changes in this revision

Viewing changes to src/lazr/restful/testing/webservice.py

  • Committer: Benji York
  • Date: 2010-09-06 19:40:04 UTC
  • mfrom: (141.1.7 bug-413174)
  • Revision ID: benji.york@canonical.com-20100906194004-0f3a5gyf3pob2b0j
[r=gary][bug=413174] Add the ability to decorate exceptions such that
their message will be relayed to the web service client

Show diffs side-by-side

added added

removed removed

Lines of Context:
98
98
class FakeResponse:
99
99
    """Simple response wrapper object."""
100
100
    def __init__(self):
101
 
        self.status = 599
102
 
        self.headers = {}
 
101
        self.reset()
103
102
 
104
103
    def setStatus(self, new_status):
105
104
        self.status = new_status
115
114
        """Return the response status code."""
116
115
        return self.status
117
116
 
 
117
    def reset(self):
 
118
        """Set response values back to their initial state."""
 
119
        self.status = 599
 
120
        self.headers = {}
 
121
        self.result = ''
 
122
 
 
123
    def setResult(self, result):
 
124
        if result is None:
 
125
            result = ''
 
126
 
 
127
        if not isinstance(result, basestring):
 
128
            raise ValueError('only strings and None results are handled')
 
129
 
 
130
        self.result = result
 
131
 
118
132
 
119
133
class FakeRequest:
120
134
    """Simple request object for testing purpose."""
136
150
        self.query_string_params = {}
137
151
        self.method = 'GET'
138
152
        self.URL = 'http://api.example.org/'
 
153
        self.headers = {}
139
154
 
140
155
 
141
156
    def getTraversalStack(self):