def test_GET_after_PUT(self): client = http.HttpClient() for i in range(10): path = self.URI_BASE + '/file.%(i)d.txt' % locals() client.PUT(path, self.RESPONSE + str(i)) self.assertEquals(client.GET(path), self.RESPONSE + str(i))
def test_unauthenticated_POST(self): client = http.HttpClient() path = self.URI_BASE + '/auth' self.assertRaises(http.Unauthorized, client.POST, path, self.DUMMYDATA)
def test_PUT(self): client = http.HttpClient() path = self.URI_BASE + '/noauth' self.assertEquals(client.PUT(path, self.DUMMYDATA), 'PUT OK')
def test_POST(self): client = http.HttpClient() path = self.URI_BASE + '/noauth' self.assertEquals(client.POST(path, self.DUMMYDATA), self.DUMMYDATA.encode('rot13'))
def test_authenticated_POST(self): client = http.HttpClient(self.USERNAME, self.PASSWORD) path = self.URI_BASE + '/auth' self.assertEquals(client.POST(path, self.DUMMYDATA), self.DUMMYDATA.encode('rot13'))
def test_authenticated_GET(self): client = http.HttpClient(self.USERNAME, self.PASSWORD) path = self.URI_BASE + '/auth' self.assertEquals(client.GET(path), self.RESPONSE)
def test_unauthenticated_GET(self): client = http.HttpClient() path = self.URI_BASE + '/auth' self.assertRaises(http.Unauthorized, client.GET, path)
def test_GET(self): client = http.HttpClient() path = self.URI_BASE + '/noauth' self.assertEquals(client.GET(path), self.RESPONSE)
def test_BadRequest(self): client = http.HttpClient() path = self.URI_BASE + '/badrequest' self.assertRaises(http.BadRequest, client.GET, path)
def test_Unauthorized(self): client = http.HttpClient('invalid-username', 'invalid-password') path = self.URI_BASE + '/auth' self.assertRaises(http.Unauthorized, client.GET, path)
def test_NotFound(self): client = http.HttpClient() path = self.URI_BASE + '/notfound' self.assertRaises(http.NotFound, client.GET, path)
def test_UnknownResponse(self): client = http.HttpClient() path = self.URI_BASE + '/invaliderror' self.assertRaises(http.UnknownResponse, client.GET, path)