def testResponseNotFound(self): expectBody = '{"request":"/","response":"not-found"}' conn = HttpConnection() response = conn.send("GET / HTTP/1.1") conn.close() self.assertTrue(expectBody in response)
def testRequestForSystem(self): expectBody = '{"request":"/SYSTEM","response":{"version":"0.0.1.1"}}' conn = HttpConnection() response = conn.send("GET /SYSTEM HTTP/1.1") conn.close() self.assertTrue(expectBody in response)
def testFirefoxRequest(self): for i in range(300): now = time.time() conn = HttpConnection() response = conn.send(Firefox.request) conn.close() self.assertLess((time.time() - now), 0.005) self.assertTrue(Firefox.expectBody in response)
def testCharacterEncodingSpecified(self): expectField = 'Content-Type: application/json; charset=utf-8' conn = HttpConnection() response = conn.send("GET / HTTP/1.1") conn.close() self.assertTrue(expectField.lower() in response.lower())
def testChromeRequest(self): for i in range(300): now = time.time() conn = HttpConnection() response = conn.send(Chrome.request) conn.close() # # Each request should takes less than 5 thousandths of # of a second. This isn't a functional requirement, it's # just to flag up code changes that impact performance. # self.assertLess((time.time() - now), 0.005) self.assertTrue(Chrome.expectBody in response)