Example #1
0
 def testMany(self):
     cnn = None
     try:
         cnn = HTTPConnection()
         cnn.connect(('localhost', 9090))
         response = cnn.perform(cnn.get('/many'))
         self.assertEquals('blaat' * 10, response.body)
     finally:
         if cnn: cnn.close()
Example #2
0
    def testWebJSON(self):

        cnn = None
        try:
            cnn = HTTPConnection()
            cnn.connect(('localhost', 9090))
            response = cnn.perform(cnn.get('/json'))
            status = response.status
            self.assertEquals('HTTP/1.1 200 OK', status)
            self.assertEquals('application/json; charset=UTF-8',
                              response.get_header('Content-Type'))
            self.assertEquals('9', response.get_header('Content-Length'))
            self.assertEquals("[1,2,3,4]", response.body)
        finally:
            if cnn: cnn.close()
Example #3
0
    def testWeb(self):

        cnn = None
        try:
            cnn = HTTPConnection()
            cnn.connect(('localhost', 9090))
            response = cnn.perform(cnn.get('/hello'))
            status = response.status
            self.assertEquals('HTTP/1.1 200 OK', status)
            self.assertEquals('text/html; charset=UTF-8',
                              response.get_header('Content-Type'))
            self.assertEquals('13', response.get_header('Content-Length'))
            self.assertEquals(u"Héllo World!",
                              ''.join(response).decode('UTF-8'))
        finally:
            if cnn: cnn.close()
Example #4
0
    def testWebTimeout(self):

        cnn = None
        try:
            cnn = HTTPConnection()
            cnn.connect(('localhost', 9090))

            request = cnn.get('/timeout')
            request.add_header('Timeout', 1.0)
            response = cnn.perform(request)
            status = response.status
            self.assertEquals('HTTP/1.1 500 Internal Server Error', status)
            self.assertEquals('text/plain',
                              response.get_header('Content-Type'))

        finally:
            if cnn: cnn.close()