示例#1
0
文件: rest.py 项目: amatuerone/haas
    def _do_request(self, data):
        """Make a request to the endpoint with `data` in the body.

        `data` should be a string -- the server will expect valid json, but
        we want to write test cases with invalid input as well.
        """
        req = Request(wsgi_mkenv('POST', '/give-me-an-e', data=data))
        return rest.request_handler(req)
示例#2
0
文件: rest.py 项目: amatuerone/haas
    def test_call_once(self):
        # We define an API call that increments a counter each time the
        # function is called, then invoke it via HTTP. Finally, we verify that
        # the counter is equal to 1, indicating that the function was called
        # the correct number of times.

        @rest.rest_call('POST', '/increment')
        def increment():
            """Increment a counter each time this function is called."""
            self.num_calls += 1

        rest.request_handler(Request(wsgi_mkenv('POST', '/increment')))
        assert self.num_calls == 1
示例#3
0
文件: rest.py 项目: amatuerone/haas
 def request(self):
     return wsgi_mkenv('GET', '/some_error')
示例#4
0
文件: rest.py 项目: amatuerone/haas
 def request(self):
     return wsgi_mkenv('POST', '/product',
                         data=json.dumps({'x': 2, 'y': 7}))
示例#5
0
文件: rest.py 项目: amatuerone/haas
 def request(self):
     return wsgi_mkenv('POST', '/func/foo',
                       data=json.dumps({'bar': 'bonnie', 'baz': 'clyde'}))
示例#6
0
文件: rest.py 项目: amatuerone/haas
 def request(self):
     return wsgi_mkenv('GET', '/foo')
示例#7
0
文件: rest.py 项目: amatuerone/haas
 def request(self):
     return wsgi_mkenv('GET', '/func/alice/bob')